I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.

As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.

I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.

As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.

I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

In standard OSG (3.2.x, 3.4.0 or the 3.5.x dev series) there isn't any
way to automatically remap osg::Material to uniforms so you'll have to
run a traverser through the scene graph and replace the osg::Material
to osg::Uniform's.

If you are willing to experiment with bleeding edge experimental code
then have a look at the shader_pipeline branch of the OSG, in this
branch I'm working on a new scheme for automatically mapping old fixed
function state like osg::Material to uniforms and #define settings
that can then be used by #pragma(tic) shader composition to provide a
fully integrated shader+fixed function state solution.

Robert.

On 15 May 2017 at 14:18, Goran Pantar <> wrote:

Quote:

Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.

As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.

I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

For OpenGL 3.2, I've taken the approach of using an uniform block to replace the materials, (if you think about this materials are currently treated as something that is shared between all shaders, which is how they are implemented in the fixed function pipeline) each material has a buffer on the GPU, and I just switch the uniform block pointer as part of the material apply. I found using callbacks really slowed down the scene graph update as the scene got larger. And there were also a number of bugs I hit by using material uniforms where scene graph optimizations seemed to lose them.

-Gedalia

On Thu, Jun 1, 2017 at 10:12 AM, Robert Osfield < (

Only registered users can see emails on this board!Get registred or enter the forums!

)> wrote:

Quote:

Hi Goran,

In standard OSG (3.2.x, 3.4.0 or the 3.5.x dev series) there isn't any
way to automatically remap osg::Material to uniforms so you'll have to
run a traverser through the scene graph and replace the osg::Material
to osg::Uniform's.

If you are willing to experiment with bleeding edge experimental code
then have a look at the shader_pipeline branch of the OSG, in this
branch I'm working on a new scheme for automatically mapping old fixed
function state like osg::Material to uniforms and #define settings
that can then be used by #pragma(tic) shader composition to provide a
fully integrated shader+fixed function state solution.

Robert.

On 15 May 2017 at 14:18, Goran Pantar < (

Only registered users can see emails on this board!Get registred or enter the forums!

)> wrote:

Quote:

Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.

As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.

I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

I am currently trying to port a fixed function pipeline application to the Hololens and thus to GLES
I followed your advice and tried the shader_pipeline branch but I don't see where and how osgMaterial state or Light source information is passed to the shader. Is that still in development or was I too stupid to find it?
Is there any documentation on how the compositing should work?

I an away on a trip so not in a position to dive into the code and see what would be appropriate. I will back at the end of the week.

Robert

On 1 Aug 2017 3:24 p.m., "Uwe Woessner" < (

Only registered users can see emails on this board!Get registred or enter the forums!

)> wrote:

Quote:

Hi Robert,

I am currently trying to port a fixed function pipeline application to the Hololens and thus to GLES
I followed your advice and tried the shader_pipeline branch but I don't see where and how osgMaterial state or Light source information is passed to the shader. Is that still in development or was I too stupid to find it?
Is there any documentation on how the compositing should work?

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou cannot download files in this forum