Hi,

> What exactly is "the state switch" you are referring to, i.e. what state
is > being switched from what to what?

The scene consists only of about 20 items, all of them are using the same
ChunkMaterial:

Class Residue :public ResidueBase {

[...]

        static void initialize(int w, int h);
        static void terminate();
        static void updateViewportSize(int w, int h);

        static ShaderProgramUnrecPtr         m_pSpacefillVP;
        static ShaderProgramUnrecPtr         m_pSpacefillFP;
        static ChunkMaterialUnrecPtr         m_pSpacefillMaterial;
        static Vec4f                         m_Viewport;

        Action::ResultE draw(DrawEnv*);

}

The viewport variable and update routine are in there as the viewport
dimension is a uniform variable in the shader, and this way I can update it
only when the window size changes.

What happens is that the shader gets activated and deactivated for every one
of the 20 items, although I would have thought OpenSG would be smart enough
to see that both materials are identical - but that can only work when the
generated states are identical, and from a first look it seems they are not.


> no, the finalize only retrieves what is already there, if it creates
> something it should be cached (but nothing in there yet does this yet).

Ok this means i should also keep a static state variable and call finalize
only the first time?

> a) which chunks are set for the generated state ?

There are no other chunks, only the shader. The code is identical to
carstens, that's why I didn't post it.
As a reference, this is the setup code:

void Residue::initialize(int w, int h)
{
        m_Viewport.setValues(0,0,w,h);

        ShaderProgramChunkUnrecPtr shader = ShaderProgramChunk::create();
        m_pSpacefillVP = OSG::ShaderProgram::createVertexShader();
        m_pSpacefillVP->readProgram(filename1);
        shader->addShader(m_pSpacefillVP);

        m_pSpacefillFP = OSG::ShaderProgram::createFragmentShader();
        m_pSpacefillFP->readProgram(filename2);
        shader->addShader(m_pSpacefillFP);

        m_pSpacefillVP->addUniformVariable("viewport",m_Viewport);

        m_pSpacefillMaterial = ChunkMaterial::create();
        m_pSpacefillMaterial->addChunk(shader);
}

> b) are there overrides except for lights ?

There is no StateOverride if you mean that, I do change OpenGL state but
encapsulated by glPushAttrib/glPopAttrib.
I just started converting a pure OpenGL drawing routine to use the OpenSG
shader stuff, doing one step at a time, and have not looked at the
StateOverride stuff yet.

> c) are these duplicated state switches for elements with the
>    same material (same object) or different material which just share
>    some chunks ?

As mentioned above, all the objects in the scene use the same material, but
it is switched every time. That's why I get the error message like 20 times
per frame not only once.

Aloha, Andi


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to