XNA 4.0 Per-Pixel Lighting Demo.
This Windows XNA application demonstrates per-pixel lighting. An effect (.fx) file is provided that implements per-pixel Blinn-Phong lighting using a series of HLSL shaders. The lighting models implemented are: per-pixel directional lighting, per-pixel point lighting, and per-pixel spotlight lighting.
Note:
1. This demo requires shader model 2.0 or higher support.
2. This demo is provided in source form only. No pre built binaries are supplied.
Download source, assets, and XNA Game Studio 4.0 solution files.
Change History:
15 January 2011.
Initial release of demo for XNA Game Studio 4.0. The previous XNA Game Studio 3.0 version of the demo is no longer supported and is now only available upon request.
16 November 2008.
Initial release of demo for XNA Game Studio 3.0. The previous XNA Game Studio 2.0 version of the demo is no longer supported and is now only available upon request.
10 April 2008.
blinn_phong.fx: Fixed a bug in the PS_PointLighting() and PS_SpotLighting() functions where the computed light attenuation was not being clamped.
27 January 2008.
Initial release of demo for XNA Game Studio 2.0. The original XNA Game Studio Express 1.0 Refresh version of the demo is no longer supported and is now only available upon request.
2 January 2008.
Renamed the per_pixel_blinn_phong.fx file to blinn_phong.fx.
Program.cs: Removed. Main method now inside of the Demo class.
blinn_phong.fx: Removed the use of the lit() intrinsic function. This has been replaced with the power variable that conditionally calculates the specular power. Removed the Light structure's attenuation member. Replaced this with a single floating point radius member. Replaced the attenuation calculations with an alternative model based on a light radius. Moved diffuse and specular calculations to the vertex shaders. Changed the vector outputs from the vertex shader to float3.
Demo.cs: Added Light and Material structures. Fixed cube geometry to use XNA's clockwise winding order. Refactored shader update code into a single UpdateEffect() method. This method now calculates all required matrices, updates required shader parameters, binds textures, and selects the current shader technique. Consolidated input handling into 2 new methods: ProcessKeyboard() and ProcessMouse(). Added text rendering support. Added DrawText() method. Added DrawCube() method. Added a simple frame rate counter.
24 January 2007.
Updated solution so that Content is no longer copied to the output directory. |