[Interest] How to use serveral textures in a QSGSimpleMaterialShader

Till Oliver Knoll till.oliver.knoll at gmail.com
Thu Jul 24 11:51:28 CEST 2014


Am 24.07.2014 um 11:25 schrieb Martin Ertl <qsmokeonthewater at gmail.com>:

> ...
> -> define 'which texture unit a given "uniform sampler2D tex" refers to' by calling
>         program()->setUniformValue("uTex0", 0);
>         program()->setUniformValue("uTex1", 1);
>         ...

Or use the "layout syntax" in the shader itself, so you can skip setting the "value" ("texture unit selector") of the uniforms (like you do above), like so:

>> layout (binding = 0) uniform sampler2D foo;
>> layout (binding = 1) uniform sampler2D bar;
>> etc.

Works at least with recent OpenGL versions (and off course only if you write the shaders yourself ;)).

But by now I realise that the "SG" prefix probably stands for "Scene Graph" (which you are probably extending with your own objects), so you're with OpenGL ES 2 I guess (which probably won't digest above shader "layout" syntax).

Cheers,
  Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140724/07fd408a/attachment.html>


More information about the Interest mailing list