27060

Vertex Winding Order in DX11

I'm trying to draw a simple square with dx11, but the order of the indices of each triangle determines whether or not it shows up. I set the cull mode to none in the rasterizer state, but it doesn't seem to change anything.

If I specify the vertices of the first triangle to be 0, 1, 2 instead of 2, 1, 0 then the triangle doesn't show up. So my question is, do I need to order the vertices of a triangle in a specific way regardless of the cull mode?

P.S. I'm drawing a triangle list and not a strip.

UINT indices[] = {2, 1, 0, 1, 3, 0}; MeshVertex vertices[] = { { Vector3(1.0f, 1.0f, 0.0f)}, //Top Right { Vector3(-1.0f, -1.0f, 0.0f)}, //Bottom Left { Vector3(1.0f, -1.0f, 0.0f)}, //Bottom Right { Vector3(-1.0f, 1.0f, 0.0f)} //Top Left }; mesh = new Mesh(vertices, indices, 4, 6, shader);

Answer1:

So my question is, do I need to order the vertices of a triangle in a specific way regardless of the cull mode?

** Define/Draw your vertices in clockwise order, and don't change the default the cull mode.**

To determine whether a triangle can be displayed, you have to considering 2 factors

<ol> <li>The front face, or you call it winding order, by default Direct3D treat a vertices defined in clockwise order as a front face, and all faces other than front faces are back faces.</li> <li>The culling mode, by default, Direct3D will cull the back faces(the faces which vertices defined in counter-clockwise order).</li> </ol>

You can set the front face and culling mode in D3D11_RASTERIZER_DESC structure

The reason why you didn't see difference when you change the culling mode to NONE is because both triangle were in the same order and D3D11_CULL_NONE means didn't cull any faces.

If triangle 1 is in clockwise order and triangle 2 is in counter clockwise order, you will only see one triangle when you set the cull mode to D3D11_CULL_FRONT or D3D11_CULL_BACK, and see both when you set it to D3D11_CULL_NONE.

Recommend

  • Shortest path in a grid
  • Colour specific node in igraph
  • iOS 8.3 - Metal, found nil while unwrapping an Optional Value
  • How to negative match regex in JavaScript string replace? [duplicate]
  • Grails 3 - How to publish to Artifactory
  • Efficiently reading a csv file with windows newline on linux in Python
  • OpenGL - Object Transformations and VBOs
  • How to resolve this packager error on react native Android
  • Android: How to correctly use NotifyDataSetChanged with SimpleExpandableListAdapter?
  • Enumerating Controls on a Form
  • Installing PHP 7 on digitalocean
  • order post according to custom array position
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Zoom in and out of jPanel
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • Problems installing Yesod for Haskell
  • Debug.DrawLine not showing in the GameView
  • Mysterious problem with floating point in LISP - time axis generation
  • Change multiple background-images with jQuery
  • Avoid links criss cross / overlap in d3.js using force layout
  • Algorithm for a smudge tool?
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • What is the “return” in scheme?
  • Can Jackson SerializationFeature be overridden per field or class?
  • Sending data from AppleScript to FileMaker records
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Arrays break string types in Julia
  • Matrix multiplication with MKL
  • Android Studio and gradle
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Load html files in TinyMce
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Turn off referential integrity in Derby? is it possible?
  • Add sale price programmatically to product variations
  • Unable to use reactive element in my shiny app
  • Converting MP3 duration time
  • How do I use LINQ to get all the Items that have a particular SubItem?