[osg-users] Per vertex colors with different front and back intensity

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Thu May 7 09:18:59 PDT 2020

Hi Phil,
if you are working with your own shaders you can query front and back in the fragment shader.


On 7. Mai 2020 17:42:35 MESZ, OpenSceneGraph Users <osg-users at lists.openscenegraph.org> wrote:
>I have a triangle geometry and I'm displaying it in various material
>The standard is just a texture. What I want is the backside of the
>to be slightly darker than the front.
>So I configure my lighting like this
>osg::ref_ptr<osg::LightModel> lm = new osg::LightModel;
>and then I set up my material like this, in addition to setting a
>m_material->setAmbient(osg::Material::FRONT_AND_BACK, xmx::osg::black);
>m_material->setDiffuse(osg::Material::FRONT_AND_BACK, xmx::osg::black);
>m_material->setEmission(osg::Material::FRONT, osg::Vec4(ff, ff, ff,
>m_material->setEmission(osg::Material::BACK, osg::Vec4(fb, fb, fb,
>ff and fb here are two different values, ff usually being just 1 and fb
>something less than 1 to make the backside darker.
>This works great for me.
>Now I also have a mode where I can set per-vertex colors in addition to
>texture, and I want to combine it.
>This works if I just drop the material and set a color array with the 
>provided colors,
>but then I loose the feature of different front and back lighting, or 
>generally the possibility to dampen front and back
>intensity separately.
>Is there any way to achieve this without writing my own shader?
>I tried to set the color mode of the material to AMBIENT_AND_DIFFUSE or
>to EMISSION and added the material,
>which resulted in no spectacular changes.
>How could I combine the material with the texture and color array?
>Thank you in advance,
>You received this message because you are subscribed to the Google
>Groups "OpenSceneGraph Users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to osg-users+unsubscribe at googlegroups.com.
>To view this discussion on the web visit
>osg-users mailing list
>osg-users at lists.openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200507/998d88fd/attachment.html>

More information about the osg-users mailing list