Announcement

Collapse
No announcement yet.

How to pass arrays to GLSL shaders

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to pass arrays to GLSL shaders

    I tried to pass an array of float vectors to a fragment shader with the following code:

    C++ Code
    SoShaderParameterArray4f *sBewObjUV;
    ...
    sBewObjUV = new SoShaderParameterArray4f;
    sBewObjUV->ref();
    sBewObjUV->name = "sBewObjUV";
    ...
    myVert->parameter.set1Value(13, sBewObjUV);

    GLSL Shader Fragment Code
    uniform vec4 sBewObjUV[256];

    The result was, that the Shader (which was runnig pretty well before) failed compilation. The following compiler error has been displayed:
    "Inventor error in SoGLSLangProgram::execute(): linkage failed"

    Does anybody know about the right way to pass arrays into a shader? I am actually using OIV 6.4.3.

    Many thanks in advance

    slv

  • #2
    Re: How to pass arrays to GLSL shaders

    What you're doing looks reasonable (at least the lines of code that you included). We use this parameter class internally, so it definitely works.

    You should probably check that you're actually putting 256 values into the array (since that's the declaration in the shader), but to be honest I don't remember if that's a requirement. You may also get some additional info by setting the environment variable OIV_GLSL_DEBUG. If all else fails, please send a small test program that fails.

    Regards,
    Mike

    Comment


    • #3
      Re:Re: How to pass arrays to GLSL shaders

      Thanks for your reply.

      the code works now. I detected another problem in my shader. I tried to use a for next loop to run through the 256 values, which includes some "if - then" statements. The shader does not compile with the maximum value set to 256, but with a value of 64 or 128 it runs well. Are there any restrictions enrolling loops an branches while compilation ?

      Many Greetings

      Comment


      • #4
        GLSL limits

        Originally posted by slv View Post
        Are there any restrictions enrolling loops an branches while compilation ?
        Yes there are, but it depends on your hardware (and driver) version, not on anything in Open Inventor.

        Mike

        Comment


        • #5
          the maximum value is 255 not 256 i think it may be aproblem

          Comment

          Working...
          X