Hi Robert,
Modifying the example won't help much here.
The fact is, that with shadercomposition you don't have direct access to
the generated osg::Program.
But without one cannot do this on the program:
addBindAttribLocation
addBindFragDataLocation
addBindUniformBlock
which might be needed per program if one wants to perform tangentspace
normalmapping or uses GL3 to and needs to setup the FragmentBind locations.
So my idea was to create a custom ShaderComposer like this:
#pragma once
#include <osg/ShaderComposer>
class CustomShaderComposer : public osg::ShaderComposer
{
public:
virtual osg::Program* getOrCreateProgram( const
osg::ShaderComponents& shaderComponents )
{
return = osg::ShaderComposer::getOrCreateProgram(shaderComponents);
}
virtual osg::Shader* composeMain( const
osg::ShaderComposer::Shaders& shaders )
{
return osg::ShaderComposer::composeMain(shaders);
}
virtual void addShaderToProgram(osg::Program* program, const
osg::ShaderComposer::Shaders& shaders )
{
return osg::ShaderComposer::addShaderToProgram(program, shaders);
}
};
and set it to the viewer camera stateset by calling
getState()->setShaderComposer(new CustomShaderComposer());
This works fine, but you never gain access to the "provoking"
ShaderAttribute in none of the functions.
I sure can access the generated program in the getOrCreateProgram, but I
cannot distinguish between those programs which need to get the bindings
set.
Hopefully this explanation was a bit clearer.
cheers
Sebastian
Hi Sebastian,
I'm struggling to understand specifically what your setup is and the
issues you are trying to tackle, and I'm a little cold of the shader
composer internals as I'm focused on other work right so not in a good
position to provide guidance. I suspect others will be in a similar
boat unless they've tackled something very similar to how you are
going about things.
Perhaps the best way forward would be to create a small example, or
small modification of the osgshadercomposer example that illustrates
the issue you are trying to tackle in a way that others can try out.
Cheers,
Robert.
On 26 November 2013 16:52, Sebastian Messerschmidt
<[email protected]
<mailto:[email protected]>> wrote:
Hi
I found my way through the source and overwritten the
ShaderComposer class.
Here I reimplemented the getOrCreateProgram and the
addShaderToProgram functions to inspect the data here.
Unfortunately there seems to be no way to access the original
ShaderAttribute from here. My
idea was to add the bindings in the shader composer via a custom
ShaderAttribute class, which would transport the bindings.
I would have applied them after the program was composed.
Would be possible to change the getOrCreateProgram function in a
way that it transports the attributes to the ShaderComposer?
Or is there something obvious I'm missing?
cheers
Sebastian
Hi
I know that the ShaderComposer is not yet finished. But I have
some simple questions about it.
Right now it is implemented as ShaderAttribute which injects
shader programs when the statesets are traversed.
So the program object stays more or less hidden inside the
state. In my current application I need to set up
vertexAttribute bindings and fragment data bindings.
Obviously this cannot be done with the shader composer in its
current state.
Can someone advise me how to get access to the shader programs
or would it be better to add these things as part of the
injection?
cheers
Sebastian
_______________________________________________
osg-users mailing list
[email protected]
<mailto:[email protected]>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
<mailto:[email protected]>
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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org