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

Werner

On 7. Mai 2020 17:42:35 MESZ, OpenSceneGraph Users 
<osg-users@lists.openscenegraph.org> wrote:
>
>Hello,
>
>I have a triangle geometry and I'm displaying it in various material
>modes.
>The standard is just a texture. What I want is the backside of the
>geometry 
>to be slightly darker than the front.
>
>So I configure my lighting like this
>
>osg::ref_ptr<osg::LightModel> lm = new osg::LightModel;
>lm->setTwoSided(true);
>m_geometry->getOrCreateStateSet()->setAttributeAndModes(lm);
>
>and then I set up my material like this, in addition to setting a
>texture.
>
>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,
>1.0f));
>m_material->setEmission(osg::Material::BACK, osg::Vec4(fb, fb, fb,
>1.0f));
>m_material->setColorMode(osg::Material::ColorMode::OFF);
>
>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
>a 
>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,
>Phil
>
>-- 
>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+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/osg-users/109aa9e5-0fa3-4dda-bbd7-e6aff3e11131%40googlegroups.com.
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>osg-users mailing list
>osg-users@lists.openscenegraph.org
>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to