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

Weird behavior with Shaders with RHI OpenGL backend

    XMLWordPrintable

Details

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

    Description

      CURRENT BEHAVIOR

      When setting the RHI backend to OpenGL, either the vec4 in the MVP below is being copied by reference or the code is getting jumbled by the compiler.

      The result is that setting COLOR sets the same value to vertexColor, which should not happen.
      (Both COLOR and vertexColor become white)

      EXPECTED

      vertexColor should be a copy of the vertex color, COLOR/VAR_COLOR should be white.

       

      REPRODUCE

      Vertex Shader

       

      layout(location=10) flat out vec4 vertexColor; //flat has no influence here
      main() {
        vertexColor = COLOR;
        COLOR = vec4(1,1,1,1);
      } 

       

      Fragment Shader

       

      layout(location=10) flat in vec4 vertexColor;
      main() {
      // This equality check breaks in OpenGL
      // It will always return true, regardless of the original vertex color
         if (vertexColor == vec4(1,1,1,1){ 
          BASE_COLOR = (1, 0, 0, 1); 
        }
        else {
          BASE_COLOR = vertexColor;
        }
      } 

       

      RELATED

      The following Vert shader code fixes the issue

      layout(location=10) flat out vec4 vertexColor; //flat has no influence here
      main() {
        vertexColor.rgb = COLOR.rgb;
        vertexColor.a = 1;
        COLOR = vec4(1,1,1,1);
      } 

       

       

       

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            mairtin.s Mairtin Steinkamp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes