Learn WP7 XNA Game Development (seven 3d basic light source)

Source: Internet
Author: User
Tags object reflection
The 3d model is applied to render the light source and can be implemented using the method under the Basiceffect class. This class can accomplish most of the complex rendering effects.

Lightingenabled--Sets whether to turn on light rendering. The default is false, that is, when the scene is rendered, use "a base light" a fixed light to illuminate each part of the object. If true, the effect of the lighting is used in the effect defined in Basiceffect.

enabledefaultlighting– uses the default light effect. If no light rendering is turned on, the function will also open automatically.

preferperpixellighting– turn on pixel light.

DirectionalLight0, DirectionalLight1, DirectionalLight2--Defines the directional light used when rendering. Each directional light contains parameters such as specular reflection, diffuse light, and direction of the light source. These properties are valid when the lightingenable is set to true.

Ambientlightcolor--The ambient reflection color of an object, expressed as a floating-point number between 1 and 0.

For lighting effects: it can be divided into pixel light and light by point.

Dot-per-point illumination: Is the default lighting, fast, slightly worse, for complex scenes.

Per-pixel illumination: slightly slower, the effect is good, for each pixel point for accurate color adjustment.

//固定的光照
effect.LightingEnabled = false;

//单向点光源
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = false;
effect.DirectionalLight1.Enabled = false;
effect.DirectionalLight2.Enabled = false;

//点光源
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = false;

//单向像素光源
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.DirectionalLight1.Enabled = false;
effect.DirectionalLight2.Enabled = false;

//像素光源
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;

Sample Download Address: http://www.52winphone.com/bbs/viewthread.php?tid=292&extra=page%3D1



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.