Tuesday, 29 March 2011

Odd Lighting

I'm having a few peculiar results with the latest model I've created.  I think it is showing up a limitation with my HLSL shader code.  I changed the code a while back to improve performance but I might have inadvertently changed from per pixel to per vertex lighting.


I'm going to compare my code to a few samples.  The following are some reminder links just on the subject of HLSL lighting:

http://www.neatware.com/lbstudio/web/hlsl.html
http://brooknovak.wordpress.com/2008/11/13/hlsl-per-pixel-point-light-using-phong-blinn-lighting-model/
http://www.dhpoware.com/demos/xnaPerPixelLighting.html
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Per-pixel_lighting.php

Note: The cause was due to normals interpolating round the corners at the bottom of the model.  I was not aware that if a face shares vertices with another face that this happened.  It does explain why most of my corners look rounded.  There is a modifier in Blender called 'Edge Split' which I used to fix the models.  This information was courtesy of @SigilXNA:
http://forums.create.msdn.com/forums/p/80555/487264.aspx

Note to self: Blender's Cube Projection or project from view, for UV Unwrap, is much easier to texture.  Create vertex groups for each side or section of the model and use Cube Projection to unwrap that group.

No comments: