[osg-users] Cannot set custom shader for a node

2012-11-16 Thread michael kapelko
Hi.
I'm using SoftShadowMap scene and I want to assign custom shader to one of
the nodes, but it doesn't work.

I do it like that:

osg::ref_ptrosg::Shader frag = new osg::Shader(osg::Shader::FRAGMENT,
code);
osg::StateSet *ss = box-getOrCreateStateSet();
osg::ShaderAttribute *sa = new osg::ShaderAttribute;
sa-setType(osg::StateAttribute::FRAGMENTPROGRAM);
ss-setAttribute(sa);
sa-addShader(frag.get());

The complete code is here: http://pastie.org/5387472

As seen from the code, I tried to enable shader composition, but that
didn't help me.

Am I doing it wrong?
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Cannot set custom shader for a node

2012-11-16 Thread Robert Osfield
Hi Michael,

It's probably a bit premature to use the OSG's shader composition work, you
could try and use but it's very much bleeding edge.  For non experimental
work I would recommend using the standard
osg::Program/osg::Shader/osg::Uniform functionality.  See the osgshader
example for inspiration.
Robert.

On 16 November 2012 13:42, michael kapelko korn...@gmail.com wrote:

 Hi.
 I'm using SoftShadowMap scene and I want to assign custom shader to one of
 the nodes, but it doesn't work.

 I do it like that:

 osg::ref_ptrosg::Shader frag = new osg::Shader(osg::Shader::FRAGMENT,
 code);
 osg::StateSet *ss = box-getOrCreateStateSet();
 osg::ShaderAttribute *sa = new osg::ShaderAttribute;
 sa-setType(osg::StateAttribute::FRAGMENTPROGRAM);
 ss-setAttribute(sa);
 sa-addShader(frag.get());

 The complete code is here: http://pastie.org/5387472

 As seen from the code, I tried to enable shader composition, but that
 didn't help me.

 Am I doing it wrong?

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


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