Skip to main content
gamedev.net
🔒 Locked

DirectX Graphics Tutorial 4

Started by zz123zz Mar 16, 2005 at 12:01 PM 3 replies 1k views
Original Post
zz123zz
zz123zz
Hi there! I'm pretty new to DirectX (9) programming and I already have a huge problem with tutorial 4 (introducing lights, should show rotating cylinder). Actually everything work fine, except one little problem. When i run my program I get this: http://studhome.rrze.uni-erlangen.de/~spserett/cylinder.png (rotating) On the right part of the cylinder the backside of the shape gets painted. Once it rotated 180°, the left backside is shown. I'm pretty stuck there, as I already had a look at the sample code that came with DirectX and I can't find a real difference! Can anyone help? Thanks zz123zz
Neil Kerkin
Neil Kerkin
At first glance I would say you need to change your culling mode. Show us some code or let us know which tutorials you are using and you will probably get more help.
Stenky
Stenky
In addition to what Neil said, make sure your normals are pointing ourwards on your cylinder. It is possible the light is shining on the inside surface of the cylinder (the yellow part) which is a front-facing polygon and wouldn't be culled which would be the case if the normals were inverted.
S1CA
S1CA
Quote:
Original post by Stenky
In addition to what Neil said, make sure your normals are pointing ourwards on your cylinder. It is possible the light is shining on the inside surface of the cylinder (the yellow part) which is a front-facing polygon and wouldn't be culled which would be the case if the normals were inverted.


Yep. Incorrect normals (0 length, point the wrong way etc) could definitely cause bad lighting as in that screenshot.

Something I should point out: vertex normals are not used for backface culling in Direct3D. Backface culling is determined by the screen/camera space winding order of the vertex positions after transformation (i.e. graphics hardware effectively performs a partial cross product of two edges and a sign check).
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
zz123zz
zz123zz
I released that I was in the wrong culling mode. Had no culling activated. Changed that, now it works!

Thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.