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

Started by
4 comments, last by oreste 9 years, 8 months ago
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
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.

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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).

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Thanx got it!!!!!!

This topic is closed to new replies.

Advertisement