Hello Gerrit,

On 06.05.2013 12:26, Gerrit Voß wrote:
>
> unfortunately there is currently the UInt16 limit, with other
> parts reducing the number of bits further (to 12 IIRC).
>
hmm...

> Currently the id's are also not reused, so if one creates
> and deletes a lot of shaders this will be a problem.
>
this forces a design question:

what I'm doing is the following. I have a really big model with a lot of 
ChunkMaterials. A material might carry a shader program which I share 
between all of the materials. E.g.:

mat->addChunk(spSceneManager->getMaterialShader(COOK_TORRANCE_MATERIAL_SHADER));

Now to handle the variable state I have added a variable chunk to each 
of my materials and added uniforms to them as appropriate. Neither the 
variable chunks nor the materials are shared in my model.

ShaderProgramVariableChunkUnrecPtr variableChunk = 
ShaderProgramVariableChunk::create();
mat->addChunk(variableChunk);

variableChunk->addUniformVariable("uMaterial.ambient", 
OSG::Color3f(colAmbient[0],  colAmbient[1],  colAmbient[2]));
variableChunk->addUniformVariable("uMaterial.diffuse", 
OSG::Color3f(colDiffuse[0],  colDiffuse[1],  colDiffuse[2]));
...

If I remove this code the model renders fine (without shader).

I have chosen this layout because I thought that I can't share the 
variable chunks because the uniforms carry a different state of the 
material.

Currently, I have no infra structure to manage all of the materials from 
a global position, i.e. share them between different geometries being in 
the same visual state.

Is there a simpler way to handle the material state in a shader based 
layout?

How do other handle such multiple material scenarios?

> For planning how to fix this, would it help in your case to
> reuse the id's. E.g. how many shader programs / shader
> executables do you have active at one point in time.

I do not know how I could reuse the ids. Actually, in my case no id is 
freed at all.

Also I do not use so many shader programs. I have 17 shader programs 
that are shared between the materials. Maybe some not so obvious shader 
programs are in action but I doubt that.
So, do the ShaderProgramVariable introduce extra id usage?

What is your advise to handle my problem?

Best,
Johannes





------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to