• Advertisement
Sign in to follow this  

Rendering front and back faces of a triangle(each face being diff)

This topic is 1267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Windows 7 Dirext June 2010 VS 2013 Express Have a rotating triangle and am asked to chaNge code so that the back face of the triangle is rendered also. I achieve that using d3ddev-> SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) (d3ddev being a pointer to the drvice class LPDIRECT3DDEVICE9). The 3 vertices are defined each w/ a color (red, blue and green), on the back face i want only one color: white. How do i achieve this? Hints are welcome. I am a beginner, i.e. new to all this!!! Thanx Oreste

Share this post


Link to post
Share on other sites
Advertisement
You could simply set/change color value of those vertices to 255,255,255 (a.k.a. white) prior to drawing the back face. obviously remembering the original values before changing, and re-setting them back after back face has been rendered. Edited by RoundPotato

Share this post


Link to post
Share on other sites

In the pixel shader, if input semantic VFACE is negative, use a white output color.

If you are not using shaders, use shaders.

 

Otherwise you have to draw it twice with different vertex colors.

 

 

L. Spiro

Edited by L. Spiro

Share this post


Link to post
Share on other sites
Shaders are coming up in my tutorial so i don't understand that aspect yet. But in both replies i read that i have to draw the triangle twice w/ diff colors and that's the rub (this is obviously exposing my ignorance in the matter). The vertices are defined w/ the CUSTOMVERTEX struct: CUSTOMVERTEX vertices[]= { {(3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255)}, {...................................}, {............................... },} } Do i have to repeat this w/ the vertices defined in counter-clockwise order (and the color set to 255, 255, 255 AND modifying the size of the vertex buffer?? (clockwise order is the default in DirectX and has not been changed in the code).

Share this post


Link to post
Share on other sites

Do i have to repeat this w/ the vertices defined in counter-clockwise order (and the color set to 255, 255, 255 AND modifying the size of the vertex buffer?? (clockwise order is the default in DirectX and has not been changed in the code).

Yes.


L. Spiro

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement