Thanks Art, I am looking forward for the patch and will definitely keep an eye on the osg-submissions list. cheers RJ
Art Tevs wrote: > Hi Raul, > > OK, I see the problem. In my case your code just work almost fine (I can see > the loaded image). However I found a bug in the osg support for texture > arrays. The problem is that the images are not correctly uploaded to the > texture (as soon as you are using more than one). As for my self, I have only > used texture arrays by creating them on the fly (without image data). As for > uploading images, I haven't tested it excesively. > > I will try to prepare a patch, which will solve the problem. Hence, just be > patient and take a look into osg-submissions list ;) > > Best regards, > Art > > > > > --- Rahul Jain <[EMAIL PROTECTED]> schrieb am Sa, 17.5.2008: > > >> Von: Rahul Jain <[EMAIL PROTECTED]> >> Betreff: Re: [osg-users] Texture2DArray shows up black >> An: [EMAIL PROTECTED], "OpenSceneGraph Users" >> <osg-users@lists.openscenegraph.org> >> Datum: Samstag, 17. Mai 2008, 8:44 >> Hi Art, >> Here is the code. >> cheers >> RJ >> Art Tevs wrote: >> >>> Hi Raul, >>> >>> is it possible, that you extract that peace of code >>> >> and post it here. >> >>> Maybe I would be able to find then the issue. On my >>> >> side, texture arrays seems to work properly ;) >> >>> Best regards, >>> Art >>> >>> >>> --- Rahul Jain <[EMAIL PROTECTED]> schrieb am >>> >> Fr, 16.5.2008: >> >>> >>> >>>> Von: Rahul Jain <[EMAIL PROTECTED]> >>>> Betreff: Re: [osg-users] Texture2DArray shows up >>>> >> black >> >>>> An: [EMAIL PROTECTED], "OpenSceneGraph >>>> >> Users" <osg-users@lists.openscenegraph.org> >> >>>> Datum: Freitag, 16. Mai 2008, 21:26 >>>> Yes I did but no luck I tried the program sean >>>> >> sent also. >> >>>> RJ >>>> >>>> Art Tevs wrote: >>>> >>>> >>>>> Hi Raul, >>>>> >>>>> have you tried the proposed changes by Sean >>>>> >> (min/mag >> >>>>> >>>>> >>>> filters, at least 2 layers, ...)? >>>> >>>> >>>>> >>>>> Cheers, >>>>> Art >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>> --- Rahul Jain >>>>>> >> <[EMAIL PROTECTED]> >> >>>>>> >>>>>> >>>> schrieb am Fr, >>>> >>>> >>>>>> 16.5.2008: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>> Von: Rahul Jain >>>>>>> >> <[EMAIL PROTECTED]> >> >>>>>>> Betreff: Re: [osg-users] >>>>>>> >> Texture2DArray shows >> >>>>>>> >>>>>>> >>>> up black >>>> >>>> >>>>>>> An: "OpenSceneGraph Users" >>>>>>> >>>>>>> >>>>>>> >>>>>> <osg-users@lists.openscenegraph.org> >>>>>> >>>>>> >>>>>> >>>>>>> Datum: Freitag, 16. Mai 2008, 16:29 >>>>>>> Hi Sean and all, >>>>>>> I am facing the same problem as yours >>>>>>> >> on my >> >>>>>>> >>>>>>> >>>> G80 card >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> on >>>>>> >>>>>> >>>>>> >>>>>>> windows as well >>>>>>> as linux. I also tried your code >>>>>>> but the results are all same. I am >>>>>>> >> linking >> >>>>>>> >>>>>>> >>>> with OSG2.4 >>>> >>>> >>>>>>> libs. What can be >>>>>>> wrong >>>>>>> Cheers >>>>>>> RJ >>>>>>> >>>>>>> Sean Carmody wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>>> Art, >>>>>>>> >>>>>>>> Thanks a lot, I've made the >>>>>>>> >> change you >> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>> suggested. >>>>>> >>>>>> >>>>>> >>>>>>> Also, as it turns >>>>>>> >>>>>>> >>>>>>> >>>>>>>> out, I had a number of >>>>>>>> other things preventing my sample >>>>>>>> >> program >> >>>>>>>> >>>>>>>> >>>> from >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> working. I needed to add >>>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >> textureArray->setFilter(osg::Texture2DArray::MIN_FILTER, >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>> osg::Texture2DArray::NEAREST); >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >> textureArray->setFilter(osg::Texture2DArray::MAG_FILTER, >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>> osg::Texture2DArray::NEAREST); >>>>>>>> >>>>>>>> otherwise I was getting a warning: >>>>>>>> >>>>>>>> 'Warning: >>>>>>>> >>>>>>>> >>>>>>>> >>>> Texture2DArray::applyTexImage2DArray_subload(..) >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> automagic >>>>>> >>>>>> >>>>>> >>>>>>>> mipmap generation >>>>>>>> is currently not implemented.' >>>>>>>> >>>>>>>> which resulted in nothing but >>>>>>>> >> black. >> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>> Furthermore, I >>>>>> >>>>>> >>>>>> >>>>>>> guess it is a >>>>>>> >>>>>>> >>>>>>> >>>>>>>> requirement that you have at >>>>>>>> least two layers (of course you >>>>>>>> >>>>>>>> >>>> wouldn't be >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>> using >>>>>> >>>>>> >>>>>> >>>>>>> a texture array >>>>>>> >>>>>>> >>>>>>> >>>>>>>> unless you had more than one >>>>>>>> layer). By adding a second image >>>>>>>> >> to the >> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> Texture2DArray, it showed up >>>>>>> >>>>>>> >>>>>>> >>>>>>>> (even though I'm still >>>>>>>> only reading from the first layer >>>>>>>> >> in my >> >>>>>>>> >>>>>>>> >>>> shader). >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> I'm not sure if this >>>>>>> >>>>>>> >>>>>>> >>>>>>>> is the intended behavior, but >>>>>>>> it seems to be the case. >>>>>>>> >>>>>>>> Thank you again. I've >>>>>>>> >> attached my >> >>>>>>>> >>>>>>>> >>>> sample >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>> program >>>>>> >>>>>> >>>>>> >>>>>>> just in case someone >>>>>>> >>>>>>> >>>>>>> >>>>>>>> else is having trouble >>>>>>>> getting Texture2DArray to work. >>>>>>>> >>>>>>>> -Sean >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Date: Mon, 25 Feb 2008 >>>>>>>>> >> 20:08:17 +0100 >> >>>>>>>>> From: [EMAIL PROTECTED] >>>>>>>>> To: >>>>>>>>> >> osg-users@lists.openscenegraph.org >> >>>>>>>>> Subject: Re: [osg-users] >>>>>>>>> >>>>>>>>> >>>> Texture2DArray >>>> >>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>> shows up >>>>>> >>>>>> >>>>>> >>>>>>> black >>>>>>> >>>>>>> >>>>>>> >>>>>>>>> Hi Sean, >>>>>>>>> >>>>>>>>> as far as I see you have an >>>>>>>>> >> error in >> >>>>>>>>> >>>>>>>>> >>>> your >>>> >>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>> setup. >>>>>> >>>>>> >>>>>> >>>>>>> This >>>>>>> >>>>>>> >>>>>>> >>>>>>>>> line: >>>>>>>>> >>>>>>>>> ref_ptr<Uniform> >>>>>>>>> >> texturesUniform >> >>>>>>>>> >>>>>>>>> >>>> = new >>>> >>>> >>>>>>>>> Uniform(Uniform::FLOAT, >>>>>>>>> 'textures', 1); >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> must be replaced with >>>>>>>>> >> something like >> >>>>>>>>> >>>>>>>>> >>>> this: >>>> >>>> >>>>>>>>> ref_ptr<Uniform> >>>>>>>>> >> texturesUniform >> >>>>>>>>> >>>>>>>>> >>>> = new >>>> >>>> >> Uniform(Uniform::SAMPLER_2D_ARRAY, >> >>>>>>>>> 'textures', 0); >>>>>>>>> >>>>>>>>> >>>>>>>>> Try this out. >>>>>>>>> >>>>>>>>> Cheers, >>>>>>>>> Art >>>>>>>>> >>>>>>>>> >>>>>>>>> --- Sean Carmody >>>>>>>>> >>>>>>>>> >>>> <[EMAIL PROTECTED]> >>>> >>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>> schrieb: >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> Hi Art, >>>>>>>>>> >>>>>>>>>> Thanks for the idea. I do >>>>>>>>>> >> have a >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> Geforce >>>>>> >>>>>> >>>>>> >>>>>>> 8800, and >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> the extensions are >>>>>>>>>> >> reported as >> >>>>>>>>>> >>>>>>>>>> >>>> being >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> supported. >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> I've attached a very >>>>>>>>>> >> simple >> >>>>>>>>>> >>>>>>>>>> >>>> program >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> (shaders inlined >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> in the code) which shows >>>>>>>>>> >> my setup, >> >>>>>>>>>> >>>>>>>>>> >>>> if >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> anyone >>>>>> >>>>>> >>>>>> >>>>>>>>>> is interested. Thanks. >>>>>>>>>> >>>>>>>>>> -Sean >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Date: Mon, 25 Feb 2008 >>>>>>>>>>> >>>>>>>>>>> >>>> 13:27:55 >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>> +0100 >>>>>> >>>>>> >>>>>> >>>>>>>>>>> From: >>>>>>>>>>> >> [EMAIL PROTECTED] >> >>>>>>>>>>> To: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>> osg-users@lists.openscenegraph.org >>>>>> >>>>>> >>>>>> >>>>>>>>>>> Subject: Re: >>>>>>>>>>> >> [osg-users] >> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>> Texture2DArray >>>>>> >>>>>> >>>>>> >>>>>>> shows up >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> black >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Hi Sean, >>>>>>>>>>> >>>>>>>>>>> which graphic card do >>>>>>>>>>> >> you >> >>>>>>>>>>> >>>>>>>>>>> >>>> have? >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>> Texture2DArray do >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> only >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> work fine with G80 >>>>>>>>>>> >> chips. I >> >>>>>>>>>>> >>>>>>>>>>> >>>> have >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>> never >>>>>> >>>>>> >>>>>> >>>>>>> tested it >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> on >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> current ATI chips. >>>>>>>>>>> >>>>>>>>>>> Best, >>>>>>>>>>> Art >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> --- Sean Carmody >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>> <[EMAIL PROTECTED]> schrieb: >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> Hi All, >>>>>>>>>>>> >>>>>>>>>>>> I'm trying to >>>>>>>>>>>> >> get >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> Texture2DArrays working, but >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> am >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> having some >>>>>>>>>>>> >> trouble. My >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> textures >>>>>> >>>>>> >>>>>> >>>>>>> always show up >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> black. I'm >>>>>>>>>>>> >> setting up >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> the >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> texture array as >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> follows >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> ref_ptr<Texture2DArray> >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> textureArray = new >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> Texture2DArray; >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> textureArray->setTextureDepth(1); >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> Image* image = >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> osgDB::readImageFile('media/skymap.tga'); >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>> textureArray->setImage(0, >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> image); >>>>>>> >>>>>>> stateSet->setTextureAttribute(0, >>>>>>> >>>>>>> >>>>>>> >> textureArray.get(), >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> osg::StateAttribute::ON); >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> and trying to read >>>>>>>>>>>> >> it in >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> the >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> shader. >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> #version 120 >>>>>>>>>>>> #extension >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> GL_EXT_gpu_shader4 >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> : >>>>>> >>>>>> >>>>>> >>>>>>> enable >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> uniform >>>>>>>>>>>> >> sampler2DArray >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> rainTextures; >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> void main() >>>>>>>>>>>> { >>>>>>>>>>>> gl_FragColor = >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >> texture2DArray(rainTextures, >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> vec3(gl_TexCoord[0].st, >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> 0)); >>>> >>>> >>>>>>>>>>>> } >>>>>>>>>>>> >>>>>>>>>>>> Now, if I switch >>>>>>>>>>>> >> out the >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> Texture2DArray with a >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> normal Texture2D >>>>>>>>>>>> >> (and >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> update >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> the >>>>>> >>>>>> >>>>>> >>>>>>> shader >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> accordingly) >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> it shows up fine, >>>>>>>>>>>> >> which >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> leads >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> me >>>>>> >>>>>> >>>>>> >>>>>>> to believe the >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> rest >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> of the app is >>>>>>>>>>>> >> working. >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> I'm >>>>>> >>>>>> >>>>>> >>>>>>> pretty new to OSG >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> and so >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> am wondering if I >>>>>>>>>>>> >> missed >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> something >>>>>> >>>>>> >>>>>> >>>>>>> obvious with >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> the >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> setup of the >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> Texture2DArray. >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>>> Thanks! >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> -Sean >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >> _________________________________________________________________ >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>>>>>> Shed those extra >>>>>>>>>>>> >> pounds >> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>> with >>>> >>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> MSN >>>>>> >>>>>> >>>>>> >>>>>>> and The Biggest >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> Loser! >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> http://biggestloser.msn.com/> >>>>>> >>>>>> >>>>>> >>>> _______________________________________________ >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>> osg-users mailing >>>>>>>>>>>> >> list >> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> >> >>>>>> osg-users@lists.openscenegraph.org >>>>>> >>>>>> >>>>>> >>>>>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>>>>> Lesen Sie Ihre E-Mails >>>>>>>>>>> >> jetzt >> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>> einfach >>>>>> >>>>>> >>>>>> >>>>>>> von >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> unterwegs. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> www.yahoo.de/go >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> _______________________________________________ >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>> osg-users mailing list >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> osg-users@lists.openscenegraph.org >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> _________________________________________________________________ >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>>>> Need to know the score, >>>>>>>>>> >> the latest >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> news, or >>>>>> >>>>>> >>>>>> >>>>>>> you need >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> your HotmailĀ®-get your >>>>>>>>>> >>>>>>>>>> >>>> 'fix'. >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> http://www.msnmobilefix.com/Default.aspx> >> >>>>>> >>>>>> >>>>>> >>>>>>> #include >>>>>>> >>>>>>> >>>>>>> >>>>>>>>> <osg/Group> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> #include <osg/Geode> >>>>>>>>>> #include >>>>>>>>>> >> <osg/ShapeDrawable> >> >>>>>>>>>> #include <osg/Node> >>>>>>>>>> #include >>>>>>>>>> >> <osgViewer/Viewer> >> >>>>>>>>>> #include >>>>>>>>>> >>>>>>>>>> >>>> <osg/Texture2DArray> >>>> >>>> >>>>>>>>>> #include >>>>>>>>>> >> <osgDB/ReadFile> >> >>>>>>>>>> #include <string> >>>>>>>>>> >>>>>>>>>> using namespace osg; >>>>>>>>>> >>>>>>>>>> void applyShader(Geode* >>>>>>>>>> >> geode) >> >>>>>>>>>> { >>>>>>>>>> ref_ptr<Program> >>>>>>>>>> >> program = >> >>>>>>>>>> >>>>>>>>>> >>>> new >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> Program; >>>>>>> >>>>>>> >>>>>>> >> program->setName('TexturesTest'); >> >>>>>> >>>>>> >>>>>> >>>>>>>>>> ref_ptr<Shader> >>>>>>>>>> >> vertObj = >> >>>>>>>>>> >>>>>>>>>> >>>> new >>>> >>>> >>>>>>>>>> Shader(Shader::VERTEX); >>>>>>>>>> ref_ptr<Shader> >>>>>>>>>> >> fragObj = >> >>>>>>>>>> >>>>>>>>>> >>>> new >>>> >>>> >>>>>>>>>> Shader(Shader::FRAGMENT); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> program->addShader(vertObj.get()); >>>> >>>> program->addShader(fragObj.get()); >>>> >>>> >>>>>>>>>> ref_ptr<StateSet> >>>>>>>>>> >> stateSet = >> >>>>>>>>>> >>>>>>>>>> >>>> new >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> osg::StateSet; >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> ref_ptr<Uniform> >>>>>>>>>> >>>>>>>>>> >>>> texturesUniform >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> = new >>>>>> >>>>>> >>>>>> >>>>>>>>>> Uniform(Uniform::FLOAT, >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> 'textures', >>>>>> >>>>>> >>>>>> >>>>>>> 1); >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>> stateSet->addUniform(texturesUniform.get()); >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>> stateSet->setAttributeAndModes(program.get(), >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> StateAttribute::ON); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> ref_ptr<Texture2DArray> >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> textureArray = >>>>>> >>>>>> >>>>>> >>>>>>> new >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> Texture2DArray; >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> textureArray->setTextureDepth(1); >>>> >>>> >>>>>>>>>> Image* image = >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> osgDB::readImageFile('Images/Brick-Std-Orange.TGA'); >> >>>> >>>> >>>>>> >>>>>> >>>>>> >> textureArray->setImage(0, >> >>>>>>>>>> >>>>>>>>>> >>>> image); >>>> >>>> stateSet->setTextureAttribute(0, >>>> >>>> >>>>>>>>>> textureArray.get(), >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> osg::StateAttribute::ON); >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> std::string vertSource = >>>>>>>>>> 'void main()' >>>>>>>>>> '{' >>>>>>>>>> 'gl_TexCoord[0].st = >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> gl_MultiTexCoord0.st;' >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> 'gl_Position = >>>>>>>>>> >>>>>>>>>> >>>> ftransform();' >>>> >>>> >>>>>>>>>> '}'; >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> vertObj->setShaderSource(vertSource); >>>>>> >>>>>> >>>>>> >>>>>>>>>> std::string fragSource = >>>>>>>>>> '#version >>>>>>>>>> >> 120\n' >> >>>>>>>>>> '#extension >>>>>>>>>> >> GL_EXT_gpu_shader4 >> >>>>>>>>>> >>>>>>>>>> >>>> : >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> enable\n' >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> '' >>>>>>>>>> 'uniform >>>>>>>>>> >> sampler2DArray >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> textures;' >>>>>> >>>>>> >>>>>> >>>>>>>>>> '' >>>>>>>>>> 'void main()' >>>>>>>>>> '{' >>>>>>>>>> 'gl_FragColor = >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> texture2DArray(textures, >>>>>> >>>>>> >>>>>> >>>>>>>>>> vec3(gl_TexCoord[0].xy, >>>>>>>>>> >> 0));' >> >>>>>>>>>> '}'; >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> fragObj->setShaderSource(fragSource); >>>>>> >>>>>> >>>>>> >>>> geode->setStateSet(stateSet.get()); >>>> >>>> >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> int main(int argc, char** >>>>>>>>>> >> argv) >> >>>>>>>>>> { >>>>>>>>>> >>>>>>>>>> >> setNotifyLevel(osg::DEBUG_INFO); >> >>>>>>>>>> // Create a cube >>>>>>>>>> ref_ptr<Group> >>>>>>>>>> >> rootNode = >> >>>>>>>>>> >>>>>>>>>> >>>> new >>>> >>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>> Group; >>>>>> >>>>>> >>>>>> >>>>>>>>>> Box* cube = new >>>>>>>>>> >> Box(Vec3(0,0,0), >> >>>>>>>>>> >>>>>>>>>> >>>> 1.0f); >>>> >>>> >>>>>>>>>> ShapeDrawable* drawable = >>>>>>>>>> >> new >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> ShapeDrawable(cube); >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> Geode* geode = new >>>>>>>>>> >> Geode(); >> >> geode->addDrawable(drawable); >> >> rootNode->addChild(geode); >> >>>>>>>>>> // Apply our shader to >>>>>>>>>> >> this cube >> >>>>>>>>>> applyShader(geode); >>>>>>>>>> >>>>>>>>>> osgViewer::Viewer viewer; >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> viewer.setSceneData(rootNode.get()); >>>> >>>> >>>>>>>>>> return viewer.run(); >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> _______________________________________________ >>>> >>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> osg-users mailing list >>>>>>>>>> >>>>>>>>>> >> osg-users@lists.openscenegraph.org >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>>> Lesen Sie Ihre E-Mails auf dem >>>>>>>>> >> Handy. >> >>>>>>>>> www.yahoo.de/go >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >> _______________________________________________ >> >>>>>> >>>>>> >>>>>> >>>>>>>>> osg-users mailing list >>>>>>>>> >>>>>>>>> >> osg-users@lists.openscenegraph.org >> >>>>>>>>> >>>>>>>>> >>>>>>>>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >> ------------------------------------------------------------------------ >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>> Connect and share in new ways with >>>>>>>> >> Windows >> >>>>>>>> >>>>>>>> >>>> Live. >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>> Get >>>>>> >>>>>> >>>>>> >>>>>>> it now! >>>>>>> >>>>>>> >>>>>>> >> <http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008> >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >> ------------------------------------------------------------------------ >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>> _______________________________________________ >>>> >>>> >>>>>>>> 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 >> >>>> >>>> >>>>>> >>>>>> >>>>>> >>>>>> >> __________________________________________________________ >> >>>> >>>> >>>>>> Gesendet von Yahoo! Mail. >>>>>> Dem pfiffigeren Posteingang. >>>>>> http://de.overview.mail.yahoo.com >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >> __________________________________________________________ >> >>>> >>>> >>>>> Gesendet von Yahoo! Mail. >>>>> Dem pfiffigeren Posteingang. >>>>> http://de.overview.mail.yahoo.com >>>>> >>>>> >> _______________________________________________ >> >>>>> osg-users mailing list >>>>> osg-users@lists.openscenegraph.org >>>>> >>>>> >>>>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>>> >>>> >>>>> >>>>> >>> >>> >> __________________________________________________________ >> >>> Gesendet von Yahoo! Mail. >>> Dem pfiffigeren Posteingang. >>> http://de.overview.mail.yahoo.com >>> _______________________________________________ >>> osg-users mailing list >>> osg-users@lists.openscenegraph.org >>> >>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >>> #include <osg/Group> >>> >> #include <osg/Geode> >> #include <osg/ShapeDrawable> >> #include <osg/Node> >> #include <osgViewer/Viewer> >> #include <osg/Texture2DArray> >> #include <osgDB/ReadFile> >> #include <string> >> >> using namespace osg; >> >> void applyShader(Geode* geode) >> { >> ref_ptr<Program> program = new Program; >> program->setName("TexturesTest"); >> ref_ptr<Shader> vertObj = new >> Shader(Shader::VERTEX); >> ref_ptr<Shader> fragObj = new >> Shader(Shader::FRAGMENT); >> >> program->addShader(vertObj.get()); >> program->addShader(fragObj.get()); >> >> ref_ptr<StateSet> stateSet = new osg::StateSet; >> ref_ptr<Uniform> texturesUniform = new >> Uniform(Uniform::SAMPLER_2D_ARRAY, "textures", >> 0); >> stateSet->addUniform(texturesUniform.get()); >> stateSet->setAttributeAndModes(program.get(), >> StateAttribute::ON); >> >> ref_ptr<Texture2DArray> textureArray = new >> Texture2DArray; >> textureArray->setFilter(osg::Texture2DArray::MIN_FILTER, >> osg::Texture2DArray::NEAREST); >> >> textureArray->setFilter(osg::Texture2DArray::MAG_FILTER, >> osg::Texture2DArray::NEAREST); >> textureArray->setTextureDepth(2); >> Image* image = >> osgDB::readImageFile("~/Images/phadke.jpg"); >> textureArray->setImage(0, image); >> textureArray->setImage(1, image); >> stateSet->setTextureAttribute(0, textureArray.get(), >> osg::StateAttribute::ON); >> >> std::string vertSource = >> "void main()" >> "{" >> "gl_TexCoord[0].st = gl_MultiTexCoord0.st;" >> "gl_Position = ftransform();" >> "}"; >> vertObj->setShaderSource(vertSource); >> >> std::string fragSource = >> "#version 120\n" >> "#extension GL_EXT_gpu_shader4 : enable\n" >> "" >> "uniform sampler2DArray textures;" >> "" >> "void main()" >> "{" >> "gl_FragColor = texture2DArray(textures, >> vec3(gl_TexCoord[0].xy, 0));" >> "}"; >> fragObj->setShaderSource(fragSource); >> >> geode->setStateSet(stateSet.get()); >> } >> >> int main(int argc, char** argv) >> { >> setNotifyLevel(osg::DEBUG_INFO); >> >> // Create a cube >> ref_ptr<Group> rootNode = new Group; >> Box* cube = new Box(Vec3(0,0,0), 1.0f); >> ShapeDrawable* drawable = new ShapeDrawable(cube); >> Geode* geode = new Geode(); >> geode->addDrawable(drawable); >> rootNode->addChild(geode); >> >> // Apply our shader to this cube >> applyShader(geode); >> >> osgViewer::Viewer viewer; >> viewer.setSceneData(rootNode.get()); >> return viewer.run(); >> } >> > > > __________________________________________________________ > Gesendet von Yahoo! Mail. > Dem pfiffigeren Posteingang. > http://de.overview.mail.yahoo.com > > > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org