Archived

This topic is now archived and is closed to further replies.

alpedrete

a Problem with textures and models

Recommended Posts

I am trying to make a game under C# using DirectX. Im making tests, and i try to render a pikachu. I render it with a texture for eyes and other details like the brown part of the tale. But the problem is that the pikachu looks like transparent because if you look it from the back you can see the eyes, and if you look it from one side you see the both eyes (one from visible side and one from the other side). I load it in MeshView and it looks perfect. I don`t know what happen but it something in my code. what is happening? P.D. sorry for the bad english.

Share this post


Link to post
Share on other sites
Sounds like the polygons are being rendered to face in the wrong direction. In OpenGL and DirectX, by default, only one side of a polygon is rendered. To determine which way the polygon faces the order in which the vertices are called matters. DirectX uses a counter-clockwise order while OpenGL uses a clockwise order (one uses a right-handed system and the other is left). If this is the cause of your problem there are two fixes. Reverse the order of you vertices when drawing polygons or disable backface culling. Backface culling is the term used when refering to the drawing of a face in only one direction. Anyways, try using the command:

m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

By not performing backface culling, you are effectively drawing twice as many polygons to the screen so you may notice a performance hit (depending on how many polys are on screen).

Good Luck.


Chris Z.
ZeroFX Interactive

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why would you tell someone to to that....

Use D3DCULL_CW or D3DCULL_CCW to set the right type of winding.


Only time you should use NONE is when some faces are CW and some are CCW...but really you should just edit the model to fix it.

Share this post


Link to post
Share on other sites
I''d tell someone that because in some cases - especially when working with exported meshes - there is not always a definite order to the vertices and the only way to be sure is to render both sides. From there you can narrow it down and fix the problem so you can use D3DCULL_CW or D3DCULL_CCW and/or fix the mesh. It''s a matter of finding the error first and then fixing it. And if I recall correctly I did metion the downside of D3DCULL_NONE. It is at the discretion of the programmer to use whatever means suits him best. I''m just here to give him options.


Chris Z.
ZeroFX Interactive

Share this post


Link to post
Share on other sites
I think that the problem here may be a Z buffer problem (i.e. you''re not using one), even with the correct winding order if you have no Z-Buffer then rendering can go wrong. Imagine that all is going well with your meshes polygon winding order, the system starts to render the various parts of the model that make up the mesh. First it renders the body, then the left eye, then the right eye. If you look at the model from behind then the eyes appear on top of the model because they were drawn after (and on top off) the body. Flipping on the Z-Buffer may help the problem...

Share this post


Link to post
Share on other sites