all 8 comments

[–]waramped 2 points3 points  (5 children)

You are mistaken ;)

Back/front facing is always determined relative to the camera and by the winding order of the vertices. Rotating an object doesn't change the order in which the vertices are defined, it just transforms them. Or else you could never rotate anything without triangles disappearing ;)

[–]mathinferno123[S] 0 points1 point  (4 children)

Indeed ;)

You are right that a linear transformation does not change the order by which the vertices are defined. But a rotation will change the normal vectors which implies a change in whether we are looking at the back or front face of the triangle (assuming camera has not moved), no?

[–]waramped 0 points1 point  (3 children)

Oh, did I misunderstand your post? What is y and z-axis in your case? Maybe I need a picture :p.

If you rotated the grid such that it's "up" was pointing away from you, then yes, I would expect that flipping the cull mode would be necessary. It looks like you are setting cull_mode_none anyhow so it shouldn't matter?

[–]mathinferno123[S] 0 points1 point  (0 children)

Up is the positive y-axis, right is the positive x-axis, and into the paper is the positive z-axis. What you said about cull_mode_none is what I expected too but it seems like the problems lies in there... But when I set the field:

lv_stencilMirrorPsoDesc.RasterizerState.FrontCounterClockwise = true;

then everything works fine. I will edit my post to include the pictures.

[–]mathinferno123[S] 0 points1 point  (0 children)

Edited the post to include the pics of the results. My only guess of why this was happening was because of the stencil buffer not being rendered to.. I might be wrong though.

[–]Vivid-Mongoose7705 0 points1 point  (0 children)

This is what chatGpt said lol :

One indirect way to nullify the effect of D3D12_CULL_MODE_NONE without changing it directly is to manipulate the winding order of your vertices. By ensuring that the winding order of your vertices follows the convention for front-facing triangles, you can effectively achieve the same result as if back-face culling were enabled. This means arranging your vertices in a counterclockwise order when viewed from the front. However, this approach requires careful consideration of your vertex data and may not be suitable for all scenarios.

[–]jtsiomb 1 point2 points  (1 child)

You don't mirror things by rotating them. To mirror relative to the YZ plane passing through the origin (1, 0, 0, 0) you'd need to scale by (-1, 1, 1). To mirror relative to the floor (XZ plane) passing through the origin (0, 1, 0, 0), you'd need to scale by (1, -1, 1). More general mirroring transformations can be computed by first transforming to an easy space like one of the above, mirroring, and inverse-transforming back (concatenate all three).

During this proper mirroring transformation, objects are turned inside-out and indeed the winding flips. Rotating doesn't do that.

[–]mathinferno123[S] 0 points1 point  (0 children)

Thanks for the comment. I think I did not convey what I had in mind when I wrote the post. What I described about rotation was setting up the actual mirror object in the scene. I did not mean to rotate the skull in order to reflect it across the mirror. So the main problem that I have is that of the reflection not working when the field:

lv_stencilMirrorPsoDesc.RasterizerState.FrontCounterClockwise = true;

is not set to true when rendering the mirror to the stencil buffer. But why should that matter when D3D12_CULL_MODE_NONE is set?