[osg-users] Disable light in shaders?

195 views
Skip to first unread message

Jaime

unread,
Jun 12, 2014, 5:20:33 AM6/12/14
to osg-...@lists.openscenegraph.org
Hi,

I want to disable specific lights with OSG, and it affects models with shaders. How can I do it?

What I have now, it is not working. I apply shaders with:

osg::StateSet* stateset = new osg::StateSet;
[...load shader...]
stateset->setAttributeAndModes(programObject, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
m_pDrawable->setStateSet(stateset);

In execution, I wanto to disable some lights, and this change has to affect shader (in the shader I have two lights). But, when I disable light in OSG, it doesn't work. I have tested with and no succes:
ss->setMode(GL_LIGHTING, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF);
ss->setMode(GL_LIGHTING, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF);
model->GetNode()->getOrCreateStateSet()->setMode(GL_LIGHT1, osg::StateAttribute::OFF);

If I test with "normal" models (without shaders), it works. But the problem is with shaders. Do I have to turn off light in OpenGL?

Thank you!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59711#59711





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

Robert Osfield

unread,
Jun 12, 2014, 5:52:16 AM6/12/14
to OpenSceneGraph Users
HI Jamie,

When using shaders it's the shader itself that controls the lighting
so the standard OpenGL lighting modes won't affect it.

If you want to toggle lighting in shaders you'll need to assign a
different shader or use a uniform that controls whether lighting is
applied or not.

Robert.

Jaime

unread,
Jun 16, 2014, 6:28:44 AM6/16/14
to osg-...@lists.openscenegraph.org

robertosfield wrote:
> HI Jamie,
>
> When using shaders it's the shader itself that controls the lighting
> so the standard OpenGL lighting modes won't affect it.
>
> If you want to toggle lighting in shaders you'll need to assign a
> different shader or use a uniform that controls whether lighting is
> applied or not.
>
> Robert.
>
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> ------------------
> Post generated by Mail2Forum


Thank you very much Robert! It worked! :D
I am using uniforms.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59753#59753
Reply all
Reply to author
Forward
0 new messages