glsl - How do I create Uniform Object Buffers in Qt3d with PySide 6? - Stack Overflow

时间: 2025-01-06 admin 业界

I'm writing a 3d game level editor with PySide6, using Qt3d (not QML). I stumbled upon a problem - I don't know how to create a Uniform Buffer Objects with Qt3d. Basically I want to pass a list of lights to the shader programs.

Here are definitions of my UBOs:

struct SunInfo {
    vec3    direction;
    vec3    color;
    float   intensity;
}

struct LightInfo {
    vec3    position;
    vec3    rotation;
    vec3    color;
    float   cone_inner;
    float   cone_outer;
    float   radius;
}

uniform SunInfo sun;
uniform LightInfo lights[MAX_NUM_LIGHTS];

I tried searching through the examples on the internet... There's only explanation on how to create single value uniforms (QParameter). I tried it on the above single block SunLight - I created a QBuffer and assigned it to a QParameter with a "sun" name, but that didn't work. No errors - just no result. The shader works, if I pass the sun parameters as single values, but that won't be possible for an array of other lights.