|
之前发了个贴,说是render to texture的时候,读不出来float数,现在的想把整数纹理送进glsl的fragment shading代码段,却送不进去
读送入的纹理数据代码如下:
ivec3 color=texture2D(texture1,0);
读到的结果竟然是 0.
纹理送入部分的代码如下,只用了一个纹理进行测试
unsigned int imgdata[1];
imgdata[0]=2;
img->setImage(1,1,1,GL_INTENSITY32UI_EXT,GL_INTENSITY,GL_UNSIGNED_INT,(unsigned char*)imgdata,osg::Image::USE_NEW_DELETE);
osg::Texture2D *tex2d=new osg::Texture2D;
tex2d->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST);
tex2d->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST);
tex2d->setWrap(osg::Texture2D::WRAP_R,osg::Texture2D::REPEAT);
tex2d->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
tex2d->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
tex2d->setImage(img);
试了下面的表达式,进行替换也不行,结果仍为0
img->setImage(1,1,1,GL_LUMINANCE,GL_LUMINANCE,GL_UNSIGNED_INT,(unsigned char*)imgdata,osg::Image::USE_NEW_DELETE);
img->setImage(1,1,1,GL_RED,GL_RED,GL_UNSIGNED_INT,(unsigned char*)imgdata,osg::Image::USE_NEW_DELETE);
但是发现,浮点数据却可以送进去呀,浮点纹理的代码如下。
osg::Image* img = new osg::Image();
float imgdata[1];
imgdata[0]=2;
img->setImage(1,1,1,GL_LUMINANCE32F_ARB,GL_LUMINANCE,GL_FLOAT,(unsigned char*)imgdata,osg::Image::USE_NEW_DELETE);
这是为什么呀,我这一周都被这送进送出的问题烦死了,谢谢大神指点。 |
|