glsl - Passing QML Array to ShaderEffect -
i try render grid different colors each field, depending on input. in imagination suitable input array:
property var fields: [0, 1, 0, 1, 0, 1, 0, 1, 0]
might appropriate describe 3x3 (colorful) chess board.
the corresponding shadereffect
this:
shadereffect { width: 600 height: 600 property var fields: [0, 1, 0, 1, 0, 1, 0, 1, 0] fragmentshader: " varying highp vec2 qt_texcoord0; uniform highp int fields[9]; void main() { highp int field = int(floor(qt_texcoord0.x * 3.0) + (floor(qt_texcoord0.y * 3.0) * 3.0)); gl_fragcolor = vec4(fields[field], field / 9.0, 0.0, 1.0); } " }
but value fields[field]
seems 0
though field proven not be.
how can array working in shader? have it, access wrong?
Comments
Post a Comment