<div dir="ltr"><div>Hi,</div><div><br></div>I think internal format GL_RGBA16 normalizes your float values to 0..1 range. Try GL_RGBA16F_ARB instead. <div><br><div>Cheers,</div><div>Wojtek Lewandowski</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-10-04 17:00 GMT+02:00 liu ming <span dir="ltr"><<a href="mailto:81792534@qq.com" target="_blank">81792534@qq.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
  I want to send a set of data to geometry shader with osg::texture,I've got a problem:in the geometry shader,I can use glsl  function"texelFetch"to get the texel's values,and use the values to draw a triangle,But the values is not correct.  the values always are "0" or "1",not the original input.It make me confused. whether the code" texture0->setInternalFormat(<wbr>GL_RGBA16);"  wrong?How can I get the correctly texel's values?<br>
<br>
The code:<br>
<br>
<br>
Code:<br>
  //.....<br>
    osg::ref_ptr< osg::StateSet > ss = new osg::StateSet;<br>
    osg::Texture1D * texture0 = new osg::Texture1D;<br>
    texture0->setDataVariance(osg:<wbr>:Object::DYNAMIC);<br>
    osg::ref_ptr<osg::Image> image = new osg::Image;<br>
    image->allocateImage( 4, 1, 1,  GL_RGB, GL_FLOAT );<br>
    //write data to the image<br>
   osg::Vec3* ptr1 = (osg::Vec3*)image->data();<br>
   *ptr1=osg::Vec3( 0.0,0.0,0.0);<br>
   *ptr1++;<br>
   *ptr1= osg::Vec3( 40.0,0.0,0.0);<br>
   *ptr1++;<br>
   *ptr1=osg::Vec3( 20.0,0.0,20.0);<br>
<br>
     texture0->setImage(image);<br>
     texture0->setInternalFormat(<wbr>GL_RGBA16);<br>
    //<br>
    osg::ref_ptr< osg::Uniform > sample0 = new osg::Uniform( "data", 0 );<br>
   ss->addUniform(sample0);<br>
    ss-><wbr>setTextureAttributeAndModes(0,<br>
texture0,osg::StateAttribute::<wbr>ON);<br>
   // ....<br>
<br>
  //--------------------------<br>
  //geometyr shader code<br>
  //----------------------------<wbr>--<br>
  //.....<br>
  uniform sampler1D data;<br>
  void main()<br>
{<br>
        //get the texel's value,but the value is wrong<br>
        vec4 C0=vec4(texelFetch(data,0,0).<wbr>xyz,1.0);<br>
        vec4 C1=vec4(texelFetch(data,1,0).<wbr>xyz,1.0);<br>
        vec4 C2=vec4(texelFetch(data,2,0).<wbr>xyz,1.0);<br>
<br>
        //use value to draw a triangle<br>
        gl_Position=osg_<wbr>ModelViewProjectionMatrix*C0;<br>
        EmitVertex();<br>
                gl_Position=osg_<wbr>ModelViewProjectionMatrix*C1;<br>
        EmitVertex();<br>
                gl_Position=osg_<wbr>ModelViewProjectionMatrix*C2;<br>
        EmitVertex();<br>
<br>
        EndPrimitive();<br>
}<br>
<br>
<br>
<br>
Thank you! My english is poor ,sorry.<br>
<br>
Cheers,<br>
liu<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=68848#68848" rel="noreferrer" target="_blank">http://forum.openscenegraph.<wbr>org/viewtopic.php?p=68848#<wbr>68848</a><br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
</blockquote></div><br></div>