[osg-users] ShaderGen and OpenGL ES2

Thomas Hogarth thomas.hogarth at gmail.com
Mon Apr 18 12:47:08 PDT 2011


 Hi

Have been doing a little work on this, the main hurdles I faced where
getting hold of light / texture matrix information and adding the
GLES2 precision stuff. So for the moment I copied the original shadergen
func (ShaderGenCache::createStateSet) into my own material class for testing
as it had direct access to the materials texture matrix and that was the
main thing I needed at the time (if your not using them it won't matter, but
it's something I think should certainly be available).

So this won't work directly in osg as I added a few other bits as
experimentation, but how to handle the precision and applying the texture
matrix uniform is demonstrated.

Attached is my material class, it basically just wraps a stateset and
supplies some convenience functions. the function you're looking for
is ComposeShaderFromMaterialState
and any variable I have added to the generated shader is prefixed with hb_,
rather then osg_.

This is something I would like to get moved into core osg so would be happy
to lend advice, as might be a while till I find the time to do this myself.
The main issue I think is dynamic variables like texture matrices and light
position. If we want people to be able to update these on the fly without
having to redo the entire shadergen pass, then the uniforms would have to be
retained some how so that they could be updated anytime the light was moved
for example. This might be doable from the shader gen visitor, but updating
all the uniforms every frame could be expensive.

In the end though it would be nice just to get the existing gl2 version
working in gles2 just as a fallback for the examples. Think it would a big
help to anyone using gles2 for the first time.

Cheers
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20110418/fdc0e636/attachment-0004.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HogBoxMaterial.h
Type: text/x-chdr
Size: 12186 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20110418/fdc0e636/attachment-0004.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HogBoxMaterial.cpp
Type: text/x-c++src
Size: 31611 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20110418/fdc0e636/attachment-0004.cpp>


More information about the osg-users mailing list