Set uniform and animate uniform variables



  • Hi,

    I am using Qt3D with plain C++. I can't figure out how to access uniform variables of custom materials with custom shaders.

    ```
    waveAnimation = new QPropertyAnimation(m_custom_material);
    waveAnimation->setTargetObject(m_custom_material);
    waveAnimation->setPropertyName("height");
    waveAnimation->setDuration(80);
    waveAnimation->setStartValue(QVariant::fromValue(0.f));
    waveAnimation->setEndValue(QVariant::fromValue(40.f));
    waveAnimation->setLoopCount(-1);
    waveAnimation->start();
    
    I found a class names QShaderData but the documentation was useless for me and I didn't achieve anything with try and error. 
    It would be awesome if some could give me a hint ...


  • Alright solved it


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How did you solve it ?



  • You can access the uniforms with the parameter classes. So for example:

    auto boneId = new Qt3DRender::QParameter();
    boneId->setName("uBoneId");
    boneId->setValue(QVariant(1));
    customMaterial->addParameter(boneId);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.