Skip to main content
GameDev.net gamedev.net
🔒 Locked

Shading/Normals

Started by Todd Casey Oct 12, 2000 at 12:23 PM 4 replies 250+ views
Original Post
Todd Casey
Todd Casey
I am using Direct3D to render 3D characters that I am generating at runtime from any TrueType font (like OpenGLs OutlineFonts). I have to use Direct3D so GL is not an option. I am using a polygon triangulation algorithm when generating the characters and some of the front and back meshes are constructed of many odd sized triangles. I am currently using vertex normals and gouraud shading but as you can see in the screen shot it doesn''t look very good (well it''s cool looking but I want a solid looking and not a marble looking object). Is there anything I can do to fix this? I would appreciate any help or information anyone can give me. Thanks. Screenshot 50.4KB Todd Casey
Coder10000
Coder10000
It looks like some of your vertex normals are reversed. There is algorithm to fix that.

Take the point which is most distant from the center of the letter and calc a new normal vector based upon all vertices around the point.

Do this with all other points, and your object should have all normals correct, or all reversed. In the 2nd case you''ll need to reverse them all afterwards.

Coder10000
Friday13
Friday13
Another possibility may be that some normals are shared between perpendicular edges. Consider a cube: in order to render it properly, you have to have 3 (THREE!!) normals at each corner point. If there''s just one normal in the corner point, the cube will pretend to be a sphere and render with weird artifacts of undesired smoothing, similar to yours. Make sure you have separate normals for the letter face edges and OTHER ones for side edges (which brings up the necessity of indexed normals)
Todd Casey
Todd Casey
I will give those solutions a try. They would be better (and easier) then adding a whole bunch of new polygons! Thanks for the great ideas!

Todd
Todd Casey
Todd Casey
I''ve never implemented a vertex normal list with Direct3D and I am wondering what is the best way to handle it.

D3DVERTEX VertList[numverts];
WORD VertIndices[numindices];
D3DVECTOR NormalList[numindices];

When I''m going to make my call to DrawIndexedPrimitive how do I handle using the different normals for the individual triangles. Do I need to manually construct my triangles (vert+normal) and then call DrawPrimitive which would allow me to draw 1 triangle at a time (or build my entire triangle list and then send it to DrawPrimitive. I know there has to be a better way of doing this. Thanks for any help.

Todd
Friday13
Friday13
I guess you will have to handle the ''face'' faces and ''side'' faces as completely different triangles, even if they are adjacent and have common points. Since you can''t refer to a point with the same XYZ but different normals by one single index, you will have to make two or more copies of that point, each with its own normal and its own index. This may become even more crucial if you decide to use textures with your letters (in wich case you will also have to have different sets of texture coordinates for the same point, depending on where it currently belongs - to ''face'' or to ''side'').

Now, while there''s no strict correspondence between point indices and normal indices in this situation, TRIANGLE numbers are the same for both points and normals. Each three points and corresponding three normals can be addressed by their respective triangle number. Thus, if there''s a list of point indices (three indices per triangle) and a list of normal indices (again, three normal indices per triangle), then:

address_of_needed_triplet_of_indices = start_of_index_array + my_triangle*3*sizeof(index)

for both point indices and normal indices.

Sorry for ''non-C++'' representation, that''s because I personally handle all this stuff in ASM.

Topic Locked

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

Sign in to reply to this topic.