a Problem with textures and models
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.
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
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
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.
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.
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
Chris Z.
ZeroFX Interactive
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement