Hi Robert, When implementing the osg::ShaderComposer functionality I had in mind that ability to have a custom StateAttribute/ShaderAttribute::apply() compute the view dependent uniform state and apply this to the osg::State. The apply() method would get the modelview matrix from the osg::State and apply this to the local uniform before passing it on to osg::State.
Might this work for you? Robert. On 4 September 2013 09:56, Robert Milharcic <[email protected]>wrote: > Hi all, > > My goal is to replace shader generator with shader composer, so I spent a > few days playing with it. It proved to be very flexible and powerful tool > but unfortunately, it lacks the support for a key feature I would consider > necessary, and that is support for the "position state". Putting it > differently, shader composer is "blind" for position state attributes > (Light, ClipPlane, TexGen) stored within LightSource, ClipNode and > TexGenNode. I was able to workaround the problem with cull calbacks or with > custom cull visitor where I'm able to identify "positioned uniform" > multiply it with model-view matrix and then force shader composer to accept > the uniform and ShaderComponent attached to the state attribure. > Unfortnatelly, this workaround introduced some unnecessary code > complications and problems with uniform management and that is why I > strongly feel that the solution should be integrated into OSG core. > > I believe the implementation of such a feature should be straightforward > task and since I might be able to post the core solution @submissions for a > review, I am asking you for advice on how user interface should look. I > have two ideas for now: > > 1. easy to implement solution dedicated to LightSource, ClipNode and > TexGenNode. In addition to LightSource::setLight we could introduce two new > methods: LightSource::**addPositionedUniform(name, VecX) that will be > collected into PositionalStateContainer and get special treatment with > model-view matrix before applied at RenderStage and > LightSource::addUniform(osg::**Uniform*) to set other non-poisitioned > uniforms that won't be multiplied but applied in a same way before any > other attribure. > 2. general soution by introducing two new types of uniforms: > osg::PositionedUniform and "global? scene?" uniform, Both can be set at any > StateSet and will be applied at RenderStage before any other attribure. > 3. both solutions: First dedicated and after that general solution which > will replace internal logic of LightSource and others leaving the interface > as is. > 4. ? > > Best Regards > Robert Milharcic > ______________________________**_________________ > osg-users mailing list > osg-users@lists.**openscenegraph.org <[email protected]> > http://lists.openscenegraph.**org/listinfo.cgi/osg-users-** > openscenegraph.org<http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org> >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

