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?

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.

The uniforms OpenSG does predefine are 'OSGWorldMatrix' and 'OSGViewMatrix'.
Once added, they are set by OpenSG and can be accessed in your GLSL code.
Unfortunately, OpenSG does not pre-define the projection matrix as generic
uniform. That means you need to use GLSL compatibility mode (as in e.g.
#version 330 compatibility) to access the projection matrix as
gl_ProjectionMatrix in your GLSL code.

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
}

The problem is when you do anything beyond standard model-view-projection
transformation, things like intersection tests or frustum culling as
provided by OpenSG won't work as expected anymore, since OpenSG is
naturally unaware of these transformations.

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

Uniforms are added with
OSGShaderProgram::addUniformVariable(<name>, <value>);
where <value> can be any primitive type, OSGMatrices and -Vectors, and
multi-fields thereof.

Regards,
Alex

> Hello Carsten,
>
> I have some additional questions with respect to shader programming in
> the scene graph world. After I have glanced through the GLSL
> specifications and some shader books, I'm puzzled with respect to the GL
> state.
>
> The scene graph defines the rendering properties of its constituents.
> This is done with a fine granularity via the material chunk objects.
> This defines the rendering state for sets of objects. Now, if I use
> shader replacements for the fixed function part of the pipeline I have
> to access this state in order to emulate the functionality. But some
> state is not available in the shader (on present GLSL versions all state
> is actually gone). I could set up some state as uniforms on the start of
> the render function but then I would lose the fine grained scene graph
> description of the rendering task. The state I have currently in mind
> consists of
> GL_LIGHT_MODEL_TWO_SIDED, GL_LIGHT_MODEL_LOCAL_VIEWER,
> GL_LIGHT_MODEL_COLOR_CONTROL as well as of the texture application
> functionality, i.e. GL_REPLACE, GL_MODULATE, GL_DECAL, GL_BLEND and
> GL_ADD.
>
> Does OpenSG provide support for these; or do I have misconception of the
> problem? How, do you solve this problem? Is this expectation in the line
> with the scene graph paradigm?
>
> Any help and guidance is very much appreciated.
>
> Best,
> Johannes
>
> P.S. Is it possible to set up structures as uniforms with OpenSG?
>
>
>
> ------------------------------------------------------------------------------
> 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
>



------------------------------------------------------------------------------
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