<div dir="ltr">My best guess is that the hardware is rounding down the tex coords when sampling the texture so that it's not always picking out the right hand set of pixels due to numerical precision issues. Try setting the Border of the osg::Texture2D::setBorderColor(Vec4(r,g,b,a)); and set the wrap mode to CLAMP_TO_BORDER.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 August 2015 at 10:39, Vitaliy Polyakov <span dir="ltr"><<a href="mailto:poljak181@yandex.ru" target="_blank">poljak181@yandex.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
robertosfield wrote:<br>
> Try changing the Texure type to Texture2D and the tex coordinates to 0 to 1.0.<br>
><br>
<br>
<br>
</span>New code, but old behaviour..<br>
<br>
<br>
Code:<br>
<br>
osg::ref_ptr<osg::Node> createFixedSizeTexture()<br>
<span class="">{<br>
osg::ref_ptr<osg::Image> image = osgDB::readImageFile("8x8.png");<br>
float width = image->s();<br>
float height = image->t();<br>
<br>
</span><span class="">osg::Vec3Array* verts = new osg::Vec3Array(4);<br>
(*verts)[0] = osg::Vec3(-width/2.0f, -height/2.0, 0.0f);<br>
(*verts)[1] = osg::Vec3(width/2.0f, -height/2.0, 0.0f);<br>
(*verts)[2] = osg::Vec3(width/2.0f, height/2.0, 0.0f);<br>
(*verts)[3] = osg::Vec3(-width/2.0f,height/2.0, 0.0f);<br>
<br>
osg::Geometry* geometry = new osg::Geometry;<br>
geometry->setVertexArray( verts );<br>
<br>
osg::Vec2Array* texcoords = new osg::Vec2Array(4);<br>
(*texcoords)[0].set(0.0f , 0.0f);<br>
</span>(*texcoords)[1].set(1.0f , 0.0f);<br>
(*texcoords)[2].set(1.0f , 1.0f);<br>
(*texcoords)[3].set(0.0f , 1.0f);<br>
<span class=""><br>
geometry->setTexCoordArray(0, texcoords);<br>
<br>
osg::Vec4Array* colors = new osg::Vec4Array(1);<br>
(*colors)[0].set(1, 1, 1, 1);<br>
geometry->setColorArray( colors );<br>
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );<br>
<br>
geometry->addPrimitiveSet( new osg::DrawArrays(GL_QUADS, 0, 4));<br>
<br>
osg::StateSet* stateSet = geometry->getOrCreateStateSet();<br>
<br>
</span>osg::Texture2D* texture = new osg::Texture2D( image );<br>
<span class="">texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);<br>
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);<br>
</span><span class="">texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);<br>
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);<br>
</span><span class="">stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);<br>
<br>
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);<br>
stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS,false), 1 );<br>
<br>
osg::Geode* geode = new osg::Geode;<br>
geode->addDrawable( geometry );<br>
<br>
osg::AutoTransform *at = new osg::AutoTransform;<br>
at->setAutoScaleToScreen(true);<br>
at->setAutoRotateMode( osg::AutoTransform::ROTATE_TO_SCREEN );<br>
at->addChild( geode );<br>
<br>
return at;<br>
}<br>
<br>
<br>
<br>
<br>
</span><span class="">------------------<br>
Read this topic online here:<br>
</span><a href="http://forum.openscenegraph.org/viewtopic.php?p=64574#64574" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=64574#64574</a><br>
<div class="HOEnZb"><div class="h5"><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" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</div></div></blockquote></div><br></div>