[Interest] How to use serveral textures in a QSGSimpleMaterialShader

Martin Ertl qsmokeonthewater at gmail.com
Mon Jul 28 13:52:03 CEST 2014


Hi,

maybe someone is interested why the whole scene was broken with the custom
component.

It seems to be important that in the "updateState()" method the
"GL_TEXTURE0" is activated as last texture
(like contained in the image particle code).

Best regards,
Martin


2014-07-25 11:13 GMT+02:00 Martin Ertl <qsmokeonthewater at gmail.com>:

> Yes you're right, I'm using OpenGL ES 2 and I'm trying to create my own
> component with custom shaders. At the moment there are still some problems
> (my component seems to destroy the whole scene) but I think I did a mistake
> somewhere. I should compare with the qquickimageparticle
> <https://qt.gitorious.org/qt/qtdeclarative/source/4f69825c5bfd93b63f890a8188ece93af1283f1f:src/particles/qquickimageparticle.cpp#L207-297>
> what's the difference.
>
> Have a nice weekend,
> Martin
>
>
> 2014-07-24 11:51 GMT+02:00 Till Oliver Knoll <till.oliver.knoll at gmail.com>
> :
>
>> 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
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140728/86b37eb3/attachment.html>


More information about the Interest mailing list