[osg-users] Is it possible to pass uniform from node's StateSet to the deferred pass fragment shader?

28 views
Skip to first unread message

michael kapelko

unread,
Mar 31, 2016, 10:06:54 PM3/31/16
to OpenSceneGraph Users
Hi.
Currently I have a forward pass fragment shader ( https://github.com/OGStudio/editor/blob/master/pipeline/pass1.frag ) with uniforms "useNormalMap", "useGlowMap" which define if certain draw buffers should be filled with bumps and glows.
I provide those uniforms with NODE->getOrCreateStateSet()->addUniform(), it works perfectly fine.

I also have a deferred pass fragment shader ( https://github.com/OGStudio/editor/blob/master/pipeline/pass2.frag ) with uniforms that I provide with PASS->getOrCreateStateSet()->addUniform(), it works perfectly fine.

Now I tried to provide a new uniform to the deferred pass fragment shader with NODE->getOrCreateStateSet()->addUniform(), and it does not work. Only PASS approach works for the deferred pass fragment shader.
Is it possible to pass uniform value from the NODE's StateSet to the deferred pass fragment shader? Am I missing something?
Thanks.

Sebastian Messerschmidt

unread,
Apr 1, 2016, 3:42:37 AM4/1/16
to OpenSceneGraph Users
Hi Michael,

You can set the uniform to the Camera node for the pass to make it per pass. If you set the uniform down in the camera's subgraph at node-level and you don't use OVERRIDE or PROTECTED in between the node's uniform should overwrite the state above. In your case it should simply work.
I personally usually use the pragmatic shader composition for things like normal-mapping etc. since it is static for the given mesh and will work pretty well if you have nodes in different passes. So basically you set the shader program to the pass-camera and set the defines per node.

Cheers
Sebastian

Thanks.


_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply all
Reply to author
Forward
0 new messages