ShaderEffect shader variable scope
-
Basically I have a component that looks something like this:
//Shader.qml ColumnLayout { property string fragPath (...) ShaderEffect { (...) id: shader fragmentShader: "shadereffects/" + fragPath + ".frag.qsb" } }
Let's say the shader that I want to use is supposed to display a single color, so we can call it "color", and it uses a property also called color that the fragment shader uses.
//main.qml Shader { property color color: Qt.rgba(0.5, 0.5, 0.5, 1.0) fragPath: "color" }
The problem I'm having is that the fragmentShader doesn't have access to all variables in the ShaderEffect's scope. So I get an error ("ShaderEffect: 'color' does not have a matching property") that color doesn't exist. In this case I could of course make another property called color that references the property color in the ColumnLayout or make an alias. But if I want to make another Shader with a different fragmentShader, that uses other variables, that won't work anymore. I would prefer to not have to rewrite the whole Shader component for every different ShaderEffect.
Is there any way I can make qml define the properties in Shader in the ShaderEffect instead? Is there for example something like
property alias content: shader.children
but for properties?