[osg-users] [forum] passing material properties to shader uniforms

Robert Osfield robert.osfield at gmail.com
Thu Jun 1 07:12:41 PDT 2017


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 <gpantar at logicbricks.com> wrote:
> 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.
>
> Thank you!
>
> Cheers,
> Goran
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70931#70931
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



More information about the osg-users mailing list