Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-78773

Support doubleSided rendering (needed for GLTF2)

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • None
    • None
    • Quick: 3D
    • None

      Currently we have support for disabling culling of back and front faces which is necessary to support the "doubleSided" property in GLTF2, there is a secondary requirement to get correct rendering:
      The doubleSided property specifies whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.
      To enable double sided lighting, we have to reverse the normals of fragments referencing a back-face.
      There are a couple of ways to do this, and I dont think we should do a few of them:
      We can generate two passes for materials marked as double-sided, one for the front-faces, and one for the back-faces. This is expensive and means double the draw calls and potentially duplicate geometry. I would prefer we not do this.
      We can use the "legacy" API of "gl_FrontFacing" in the fragment shader which indicates which face you are rendering. This is supposed to be "slow" however and tends to be discouraged in GPU vendor documentation. I don't think we should do this.
      We should be able to tell in the shader if a normal is facing towards the camera viewer or away from the camera, and based on that calculation deduce if a given fragment addresses a back-face or front-face. A good post describing this kind of solution is here:
      https://makc3d.wordpress.com/2015/09/17/alternative-to-gl_frontfacing/

      I mention this in the context of GLTF2 but in general any faceCulling disabled rendering should suffer the same fate. For example when we render a cube with a "Glass" material we should be able to see the edges of the other side of the Cube, however the "lighting" of the inside faces will be incorrect, because the lighting calculation is performed with using a normal facing the wrong direction.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            janichol Andy Nichols
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes