dhpoware logo
home products source demos contact us
navbar navbar
box top left corner box top right corner
Direct3D 9 HLSL Vertex Lighting Demo.

This is the first demo in the Direct3D 9 HLSL (High Level Shading Language) demo series. This demo implements the per-vertex Blinn-Phong lighting model that fixed function Direct3D uses with a series of HLSL shaders.

The purpose of this demo is to replicate the fixed function lighting model. Switching between the fixed function pipeline and the programmable pipeline should show no visible differences within the scene in this demo. The shaders presented in this demo will serve as the foundation for future Direct3D 9 HLSL demos.

A single Direct3D Effect File (.fx) is provided containing 3 techniques. There is a technique for each of the three fixed function lighting models: directional lighting, point lighting, and spotlight lighting.

The demo consists of a single textured cube centered at the world origin. The light source is fixed and located directly in front of the cube where the virtual camera is located in the scene. Note that the cube intentionally has a very low polygon count to emphasize the fact that realistic per-vertex lighting depends on sufficiently tessellated geometry.

This demo was built using the June 2010 update of the Microsoft DirectX SDK. The required end-user runtimes can be downloaded here.

1. The HLSL compiler in the June 2010 SDK no longer supports shader model 1.x. Therefore the demo requires shader model 2.0 or higher.
2. This demo requires the Visual C++ 2010 Library Runtimes. Download instructions can be found here.


zipfile Download executable, source, and Visual C++ 2010 solution files.

Change History:

10 July 2010.
Added missing .vcxproj.filters file to the project.

13 June 2010.
Updated solution to Microsoft Visual Studio 2010.

25 March 2008.
Fixed memory leak in CreateNullTexture() function where 'pSurface' was not being released.

2 February 2008.
Updated solution to Microsoft Visual Studio 2008.

27 December 2007.
Renamed file decal_map.dds to color_map.dds.

vertex_lighting.fx: Removed PS_INPUT structure. Reorder the layout of the VS_INPUT and VS_OUTPUT structures. Removed FX Composer specific annotations.

main.cpp: Rewritten to match the layout of more recent Direct3D demos. Improved font rendering by supporting ClearType quality when available.

2 January 2007.
main.cpp: Fixed a possible resource leak in LoadShader() function where the ID3DXBuffer pointer was not being released. The executable has been rebuilt using Visual C++ 2005 with Visual Studio 2005 Service Pack 1 applied.

1 January 2007.
main.cpp: Added event handler for the WM_SIZE message. Fixes an issue with the aspect ratio being incorrect after a full screen toggle.

box bottom left corner content box box bottom right corner
logo logo