<div dir="ltr">Hi Erik,<div><br></div><div>That looks like a texture wrap issue. Try setting your texture wrap mode to CLAMP_TO_EDGE:</div><div><br></div><div><div><span style="font-size:12.8000001907349px">pTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);</span></div><div><span style="font-size:12.8000001907349px">pTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::</span><span style="font-size:12.8000001907349px">CLAMP_TO_EDGE</span><span style="font-size:12.8000001907349px">);</span></div></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Cheers,</span></div><div><span style="font-size:12.8000001907349px">Farshid</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 11, 2015 at 12:39 PM, Erik Hensens <span dir="ltr"><<a href="mailto:ehensens@hunter.com" target="_blank">ehensens@hunter.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all!<br>
<br>
I'm having trouble with image texture mapping a geode. Specifically, where the top and the bottom of the image meet, there is a dark shadow effect that I want to avoid.<br>
<br>
I've created the simplest example of how I'm attempting the texture mapping and I've taken screenshots that show the unwanted shadow (please see the attached screenshots and the overlay image itself).<br>
<br>
Below is the code I'm using. As you can see, it's very simple: just four quadrangle faces that form four sides of an open-ended box. I've attempted to map the overlay image around the entire box so that the top and bottom meet at one of the four edges.<br>
<br>
Does anyone have any idea what I'm doing wrong or how I can modify my code to get rid of the shadow effect? Thanks a bunch in advance!<br>
<br>
<br>
Code:<br>
// Create the new geode node<br>
osg::ref_ptr < osg::Geode > pGeode = new osg::Geode;<br>
<br>
// Create the single new geometry<br>
osg::ref_ptr < osg::Geometry > pGeometry = new osg::Geometry;<br>
<br>
// The vertex array to define the geometry shape<br>
osg::ref_ptr < osg::Vec3Array > pVertices = new osg::Vec3Array;<br>
<br>
// Add face 1/4 quad vertices<br>
pVertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 0.0f, 0.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(0.0f, 5.0f, 5.0f));<br>
<br>
// Add face 2/4 quad vertices<br>
pVertices->push_back(osg::Vec3(0.0f, 5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 0.0f, 10.0f));<br>
pVertices->push_back(osg::Vec3(0.0f, 0.0f, 10.0f));<br>
<br>
// Add face 3/4 quad vertices<br>
pVertices->push_back(osg::Vec3(0.0f, 0.0f, 10.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 0.0f, 10.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, -5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(0.0f, -5.0f, 5.0f));<br>
<br>
// Add face 4/4 quad vertices<br>
pVertices->push_back(osg::Vec3(0.0f, -5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, -5.0f, 5.0f));<br>
pVertices->push_back(osg::Vec3(10.0f, 0.0f, 0.0f));<br>
pVertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));<br>
<br>
// Set the vertex array on the geometry<br>
pGeometry->setVertexArray(pVertices);<br>
<br>
// Create the geometry's color array<br>
osg::ref_ptr < osg::Vec4Array > pColors = new osg::Vec4Array;<br>
pColors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));<br>
<br>
// Set the color array on the geometry<br>
pGeometry->setColorArray(pColors);<br>
pGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);<br>
<br>
// Set the quad draw array on the geometry<br>
osg::ref_ptr < osg::DrawArrays > pDrawArrays = new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, static_cast < GLsizei >(pVertices->size()));<br>
pGeometry->addPrimitiveSet(pDrawArrays);<br>
<br>
// Load the overlay image<br>
osg::ref_ptr < osg::Image > pImage = osgDB::readImageFile("overlay.png");<br>
<br>
// Create the image texture<br>
osg::ref_ptr < osg::Texture2D > pTexture = new osg::Texture2D(pImage);<br>
<br>
// Create the texture coordinates array<br>
osg::ref_ptr < osg::Vec2Array > pTexCoords = new osg::Vec2Array;<br>
<br>
// Set face 1/4 quad texture overlay coordinates<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.0f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.0f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.25f));<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.25f));<br>
<br>
// Set face 2/4 quad texture overlay coordinates<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.25f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.25f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.50f));<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.50f));<br>
<br>
// Set 3/4 quad texture overlay coordinates<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.50f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.50f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.75f));<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.75f));<br>
<br>
// Set 4/4 quad texture overlay coordinates<br>
pTexCoords->push_back(osg::Vec2(0.0f, 0.75f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 0.75f));<br>
pTexCoords->push_back(osg::Vec2(1.0f, 1.0f));<br>
pTexCoords->push_back(osg::Vec2(0.0f, 1.0f));<br>
<br>
// Set the geometry's texture coordinates array<br>
pGeometry->setTexCoordArray(0, pTexCoords);<br>
<br>
// Get the geometry's stateset<br>
osg::ref_ptr < osg::StateSet > pStateSet = pGeometry->getOrCreateStateSet();<br>
<br>
// Set the texture on the stateset<br>
pStateSet->setTextureAttributeAndModes(0, pTexture, osg::StateAttribute::ON);<br>
<br>
// Set the geometry's stateset<br>
pGeometry->setStateSet(pStateSet);<br>
<br>
// Add the single drawable to the geode node<br>
pGeode->addDrawable(pGeometry);<br>
<br>
// Add this new geode to the scene<br>
pTopGroupNode->addChild(pGeode);<br>
<br>
<br>
<br>
Cheers,<br>
Erik<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=63711#63711" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=63711#63711</a><br>
<br>
<br>
<br>
<br>_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br></blockquote></div><br></div>