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

RHI with OpenGL and D3D11 sometime use opposite normals

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2
    • Quick: 3D
    • None

    Description

      OpenGL adds a possible flip for the normals in the fragment shader, resulting in opposite normals from D3D11 

      OpenGL Generated Frag Shader

       

      void main()
        {
            float qt_objectOpacity = qt_material_properties.a;
            vec4 qt_vertColor = qt_varColor;
        
            vec3 qt_view_vector = normalize(qt_cameraPosition - qt_varWorldPos);
            vec3 qt_world_normal = normalize(qt_varNormal);
            vec3 qt_tangent = normalize(qt_varTangent);
            vec3 qt_binormal = normalize(qt_varBinormal);
       ※     const float qt_facing = gl_FrontFacing ? 1.0 : -1.0;
       ※ 
       ※     qt_world_normal *= qt_facing;
       ※  
       ※     qt_tangent *= qt_facing;
       ※     qt_binormal *= qt_facing;
            QT_SHARED_VARS qt_customShared;
            float qt_customSpecularAmount = 0.5;
            float qt_customSpecularRoughness = 0.0;
            float qt_customMetalnessAmount = 0.0;
            float qt_customFresnelPower = 5.0;
            vec4 qt_customBaseColor = vec4(1.0);
            vec3 qt_customEmissiveColor = vec3(0.0);
            vec2 qt_texCoord0 = qt_varTexCoord0;
            vec2 qt_texCoord1 = qt_varTexCoord1;
            qt_customMain(qt_customBaseColor, qt_customEmissiveColor, qt_customMetalnessAmount, 

      D3D11 Generated Frag Shader

       

       

      void main()
        {
            float qt_objectOpacity = qt_material_properties.a;
            vec4 qt_vertColor = qt_varColor;
        
            vec3 qt_view_vector = normalize(qt_cameraPosition - qt_varWorldPos);
            vec3 qt_world_normal = normalize(qt_varNormal);
            vec3 qt_tangent = normalize(qt_varTangent);
            vec3 qt_binormal = normalize(qt_varBinormal);
      ※                                                          
      ※  
      ※                                   
      ※  
      ※                              
      ※                               
            QT_SHARED_VARS qt_customShared;
            float qt_customSpecularAmount = 0.5;
            float qt_customSpecularRoughness = 0.0;
            float qt_customMetalnessAmount = 0.0;
            float qt_customFresnelPower = 5.0;
            vec4 qt_customBaseColor = vec4(1.0);
            vec3 qt_customEmissiveColor = vec3(0.0);
            vec2 qt_texCoord0 = qt_varTexCoord0;
            vec2 qt_texCoord1 = qt_varTexCoord1;
            qt_customMain(qt_customBaseColor, qt_customEmissiveColor, qt_customMetalnessAmount, qt_customSpecularRoughness, qt_customSpecularAmount, qt_customFresnelPower, qt_world_normal, qt_tangent, qt_binormal, qt_texCoord0, qt_texCoord1, qt_view_vector, qt_customShared); 

       

      OpenGL Frag Shader Debug Header

       

      >pointcloud.vert>pointcloud.frag:4f9ed4804f0bfa09847960666a90b852f7ca46d7;hasLighting=true;lightCount=1;specularModel=Default;;diffuseMap={;;;;};emissiveMap={;;;;};specularMap={;;;;};baseColorMap={;;;;};bumpMap={;;;;};specularAmountMap={;;;;};normalMap={;;;;};opacityMap={;;;;};roughnessMap={;;;;};metalnessMap={;;;;};occlusionMap={;;;;};translucencyMap={;;;;};heightMap={;;;;};opacityMap_channel=R;roughnessMap_channel=R;metalnessMap_channel=R;occlusionMap_channel=R;translucencyMap_channel=R;heightMap_channel=R;boneCount=0;isDoubleSided=true;alphaMode=Default;;vertexAttributes={position=true;;;;;;color=true}};morphTargetCount=0;morphTarget0Attributes={;;;;;;}};morphTarget1Attributes={;;;;;;}};morphTarget2Attributes={;;;;;;}};morphTarget3Attributes={;;;;;;}};morphTarget4Attributes={;;;;;;}};morphTarget5Attributes={;;;;;;}};morphTarget6Attributes={;;;;;;}};morphTarget7Attributes={;;;;;;}}

       

      D3D11 Frag Shader Debug Header

      • Does not have isDoubleSided=true;
      • Has usesPointsTopology=true;

      Attachments

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

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            mairtin.s Mairtin Steinkamp
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes