I've been basing my code, in part, on the book I have - but the basic diffuse equation is simple enough to work out and implement for a point light.
Thing is, I messed it all up [grin]
I'm not 100% convinced it's fixed now, but I'm pretty sure it was just some n00b error of forgetting to keep values in the same coordinate space and a few +'s and -'s the wrong way around [rolleyes]
But the cool thing that I'm wanting to write about - and the reason I know why my shader was broken - is the DirectX SDK's shader debugger. That thing is absolutely frickin' amazing!! [grin]
I wonder if OpenGL has a similar tool for GLSL, cos if it doesn't they're really missing out [oh].
- Make sure all software is installed, SDK's and so on...
Launch the DirectX Control Panel
Switch to the debug runtime
Load up Visual C++ 7.0 and my shader project
Change my device init to use software vertex processing: D3DCREATE_SOFTWARE_VERTEXPROCESSING.
Make sure that D3DXSHADER_SKIPOPTIMIZATION and D3DXSHADER_DEBUG are specified when compiling the shader from a file
Load up the vertex shader code into VStudio (even has proper syntax highlighting)
Place breakpoints as you would normally when debugging with VStudio
Hit the "Debug" -> "Direct3D" -> "Start With Direct3D Debugging" menu item
Wait for the breakpoints to be triggered, and check the values
Steps 5 and 6 can be easily done with a #define based on the _DEBUG symbol so as to require no manual changes later on.
Tools like this, PIXfW, DXTEX and the HLSL compiler make the DX SDK rock - I almost get worried that they're making it too easy [grin]