Jump to content

  • Log In with Google      Sign In   
  • Create Account

Cull mode inverted for some reason?


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
8 replies to this topic

#1   Members   -  Reputation: 1084

Like
0Likes
Like

Posted 09 March 2014 - 05:24 PM

I've been learning basic 3D engine programming and finally got to a stage where I have a very simple engine running, displaying a bunch of spinning rainbow cubes. I had built a similar demo a little while ago, but this is the first time the code has been properly integrated into some semblance of an engine, with different areas properly segregated and so forth.

 

I'm experiencing a weird issue where I have to set CullMode.Front by default, or all of the back faces render, while the front faces are ignored. Obviously this is backwards to what should actually by happening but I'm having trouble figuring out why. Any suggestions would be appreciated.

 

All the code is on Github if you want to take a look. Here's the part where I'm setting the cull mode.


Edited by axefrog, 09 March 2014 - 05:28 PM.


#2   Members   -  Reputation: 1815

Like
0Likes
Like

Posted 09 March 2014 - 05:47 PM

Maybe the winding order of your triangles is inverted (clockwise instead of counterclockwise or vice versa)?



#3   Members   -  Reputation: 1084

Like
0Likes
Like

Posted 09 March 2014 - 06:09 PM

Maybe the winding order of your triangles is inverted (clockwise instead of counterclockwise or vice versa)?

 

Just checked and the vertex indices for the triangles appear to be specified in counterclockwise winding order.

https://github.com/axefrog/game-dev-learning/blob/master/Grasshopper/Grasshopper.Engine/Geometry/Primitives/Cube.cs#L34



#4   Crossbones+   -  Reputation: 24090

Like
4Likes
Like

Posted 09 March 2014 - 06:50 PM

Then you have found your own problem it would seem.

 

The D3D11_RASTERIZER_DESC::FrontCounterClockwise member defaults to FALSE.

 

 

L. Spiro



#5   Members   -  Reputation: 1084

Like
0Likes
Like

Posted 10 March 2014 - 01:09 AM

Then you have found your own problem it would seem.

 

The D3D11_RASTERIZER_DESC::FrontCounterClockwise member defaults to FALSE.

 

 

L. Spiro

Ah thanks! I'm assuming counterclockwise is the standard most engines use? I'm confused why the default settings for the rasterizer description put the winding direction at odds with cull mode...



#6   Crossbones+   -  Reputation: 24090

Like
0Likes
Like

Posted 10 March 2014 - 02:08 AM

It’s not. First you define which direction defines a front face (clockwise or counter clockwise) and then you decide whether you want to cull front faces or back faces. I personally use clockwise, but whether one is used more than the other or by whom one is used is rather arbitrary—there is no reason to pick one over the other except that that is how your toolchain works.


L. Spiro

#7   Members   -  Reputation: 1084

Like
0Likes
Like

Posted 10 March 2014 - 03:33 AM

It’s not. First you define which direction defines a front face (clockwise or counter clockwise) and then you decide whether you want to cull front faces or back faces. I personally use clockwise, but whether one is used more than the other or by whom one is used is rather arbitrary—there is no reason to pick one over the other except that that is how your toolchain works.


L. Spiro

Ah, thanks, that's helpful. I wonder if it's a bug in SharpDX for configuring the Rasterizer.Default() method to have the winding order mismatched with the cull mode.


Edited by axefrog, 10 March 2014 - 03:34 AM.


#8   Members   -  Reputation: 1815

Like
0Likes
Like

Posted 10 March 2014 - 04:03 AM

That doesn't make sense. How can it be mismatched if it's arbitrary?



#9   Crossbones+   -  Reputation: 24090

Like
0Likes
Like

Posted 10 March 2014 - 04:16 AM

I said the decision on which to use is fairly arbitrary, even though there might or might not be a most-common direction (CW/CCW).


L. Spiro






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS