Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D shader graph with uniform int array
Forum Updated to NodeBB v4.3 + New Features

Qt3D shader graph with uniform int array

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 202 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HappyFeet
    wrote on last edited by
    #1

    To be able to color clicks on a 3D surface I'd like to pass a uniform vec3 array containing the clicks and one containing the colors to a shader graph but don't know how to do so. Taking from QShaderLanguage it doesn't look like arrays are supported out of the box. I cheated a bit and created a new node like so:

            {
                "uuid": "{00000000-0000-0000-0000-000000000027}",
                "type": "input",
                "parameters": {
                    "name": "colors[10]",
                    "qualifier": {
                        "type": "QShaderLanguage::StorageQualifier",
                        "value": "QShaderLanguage::Uniform"
                    },
                    "type": {
                        "type": "QShaderLanguage::VariableType",
                        "value": "QShaderLanguage::Vec3"
                    }
                }
            },
    

    The problem is that I don't get anything rendered, only when I remove the [10] part from the nodes, the respective edges and my custom prototype (which is supposed to color the clicks). There aren't any errors it's just that nothing gets drawn. There are more details in my stackoverflow question.

    I have figured out one configuration which raises a shader compilation error which outputs the faulty shader code:

    ... [I removed the uninteresting part]
    
    #line 11
    uniform vec3 clicks[10];
    uniform vec3 colors[10];
    vec4 renderClicks(vec3 clicks[10], vec3 colors[10], vec4 currentColor) {
        return currentColor;
    }
    
    #line 15
    out vec4 fragColor;
    
    void main()
    {
        fragColor = (((renderClicks(clicks[10], colors[10], (((((((phongFunction(ka, kd, ks, shininess, worldPosition, normalize(((eyePosition - worldPosition))), normalize(worldNormal)))))))))))));
    }
    

    The problem is obviously that the name of the nodes are clicks[10] and colors[10] which get plugged into the function.

    Is there any way to to use a uniform vec3 array properly in a shader graph? Or do I have to fall back to e.g. using a Texture1D which I manually populate with the clicks and colors?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved