Hello Alexander,

On 29.11.2012 19:02, Alexander Lang wrote:> Hi,
> it would help if you could specify your problem. Do you have a concrete
> issue with your application using OpenSG? Do you want to port an
> application from OpenGL 1.x to modern OpenGL using OpenSG?
> 

My application is successfully ported to OpenSG 2 already. I'm now in the 
process of switching from the classic fixed function pipeline to a shader based 
implementation.

My problem is that I have scene graphs with multiple materials and geometries 
(as usual). Some materials do have texture chunks and light model chunks etc. 
The settings of the chunks are typically different among the materials.

If I write a shader emulating the fixed function pipeline, I have to evaluate 
the state of my chunks in my shader code. But how can I set uniforms for the 
differing material chunks. I see no correct place for doing this. If I update 
my uniforms at the beginning of the render loop I would define a global state. 
But the state changes between different branches of the scene graph in one 
render loop evaluation.

How do you handle such setups?

I think that the existing material chunks define a state set that should be 
provided to shader code in form of uniforms, which would be updated in the 
render action as necessary. Otherwise, IMHO, it would not be possible to map 
the classical GL state expressed be the material chunks to a shader based 
implementation.

But as I tried to express, I might missing some important piece here.

> The light states you mentioned are part of the fixed-function pipeline.
> With shaders you are entirely free to do whatever you want, the downside
> is that your host code and therefore OpenSG cannot know anything about it.
> So if you want to work with these light states in your shader you have to
> define them as uniforms by yourself, AFAIK OpenSG does not pre-define
> these anywhere.
But how do you handle the situation that say the first branch of your scene 
graph should be lit by 3 spot lights and the second branch should be lit by 4 
directional light?

> 
> The uniforms OpenSG does predefine are 'OSGWorldMatrix' and 'OSGViewMatrix'.
> Once added, they are set by OpenSG and can be accessed in your GLSL code.

I'm aware of these and actually does use them already in my silhouette shader 
which work perfectly.

> 
> Also, custom attributes are available if you enable vertexattribfuncs in
> your build. For example:
> 
> vertexShader->setProgramAttribute(OSG::ShaderConstants::PositionsIndex,
> "vertexPos");
> 
> Then you can access "vertexPos" in your shader code like this:
> 
> in vec3 vertexPos;
> int main()
> {
>    //transform vertexPos;
>    //write to gl_Position
> }
> 
That is new to me and I won't forget about it. However, it is in my opinion on 
a different granularity level. (?)

> 
> The texture parameters GL_REPLACE, GL_MODULATE, etc. can be set within
> OpenSG with OSG::TextureEnvChunk.

Yes, but at which place do you update a uniform for such a parameter?

Best,
Johannes


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to