[Interest] [qt3d] Few questions about shader management with custom materials
Sean Harmer
sean.harmer at kdab.com
Tue Jun 21 14:49:07 CEST 2016
On Tuesday 21 June 2016 14:40:37 Xavier Bigand wrote:
> I have few more questions :
> - How Qt know the type of the uniform, does it parse the shader source?
We don't parse the source but rather use the introspection API to extract
uniform types, locations and other properties (needed for building UBOs).
> - How from the material class I can retrieve the model view projection
> matrix to update the corresponding uniform of the vertex shader? Maybe
> there is a signal that notify the material when the transform of the parent
> object changed?
No need. Qt 3D automatically sets some uniforms. I don't know if these are
documented yet but take a look at:
http://code.qt.io/cgit/qt/qt3d.git/tree/src/render/backend/renderview.cpp?h=5.7#n141
for the full list. So to get the model view projection compound matrix you can
just declare a uniform mat4 mvp; or uniform mat4 modelViewProjection; in your
shader and it will be set automatically for you.
At some point we may add some API to allow you to populate your own uniforms
with such calculated values. For now, use the names in the above link.
> - Our shaders works on all platforms (opengles/opengl), In this case can I
> remove the Technique or the graphicApiFilter to be sure that the same code
> runs everywhere?
You need at least one Technique. I *think* that if you don't specify a
graphics api filter it will select it - but you'll need to play to confirm.
Otherwise, just create a wrapper around Technique and instantiate it for both
GL and GL ES api filters.
> - Does qt3d use glsloptimizer on some platforms?
No. We don't do any "tinkering" with shader sources other than what
QOpenGLShaderProgram does (for ensuring highp etc are defined). Oh, the only
other thing we do is an include pragma. We use this for including the common
lighting code.
Cheers,
Sean
>
> 2016-06-21 11:26 GMT+02:00 Sean Harmer <sean.harmer at kdab.com>:
> > On Tuesday 21 June 2016 00:03:31 Xavier Bigand wrote:
> > > Thank you, it's super nice.
> > >
> > > Does qt3d cache the compilation of shaders between two executions of the
> > > application?
> >
> > Not yet. :)
> >
> > Sean
> >
> > > 2016-06-20 22:54 GMT+02:00 Sean Harmer <sean.harmer at kdab.com>:
> > > > Hi,
> > > >
> > > > On 20/06/2016 17:17, Xavier Bigand wrote:
> > > >
> > > > Hi,
> > > >
> > > > I am planning to use our custom materials with Qt3D, because will
> >
> > already
> >
> > > > have an uber shader for the lighting and shadowing of objects.
> > > > I think that I'll create one material called LightingMaterial that can
> > > > change the shader's sources depending of his properties, but in this
> >
> > case
> >
> > > > it seems that I'll instanciate too much shader programs.
> > > > Are shaderprograms automatically managed in sense of I can instanciate
> > > > many program with the same code?
> > > >
> > > >
> > > > Yes, the OpenGL shader programs are cached and hashed by the renderer.
> > > >
> > > > Cheers,
> > > >
> > > > Sean
> > > >
> > > >
> > > >
> > > > --
> > > > Xavier
> > > >
> > > >
> > > > _______________________________________________
> > > > Interest mailing
> > > > listInterest at qt-project.orghttp://
> >
> > lists.qt-project.org/mailman/listinfo/i
> >
> > > > nterest
> > > >
> > > >
> > > >
> > > > --
> > > > Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
> > > > KDAB (UK) Ltd, a KDAB Group company
> > > > Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
> > > > Mobile: +44 (0)7545 140604
> > > > KDAB - Qt Experts
> > > >
> > > >
> > > > _______________________________________________
> > > > Interest mailing list
> > > > Interest at qt-project.org
> > > > http://lists.qt-project.org/mailman/listinfo/interest
> >
> > --
> > Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
> > KDAB (UK) Ltd, a KDAB Group company
> > Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
> > Mobile: +44 (0)7545 140604
> > KDAB - Qt Experts
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts
More information about the Interest
mailing list