Guest User

Untitled

a guest
Sep 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. osg::Texture*
  2. GroundCover::createTexture() const
  3. {
  4. osg::Texture2DArray* tex = new osg::Texture2DArray();
  5.  
  6. int arrayIndex = 0;
  7. float s = -1.0f, t = -1.0f;
  8.  
  9. for(int b=0; b<getBiomes().size(); ++b)
  10. {
  11. const GroundCoverBiome* biome = getBiomes()[b].get();
  12.  
  13. for(int i=0; i<biome->getBillboards().size(); ++i, ++arrayIndex)
  14. {
  15. const GroundCoverBillboard& bb = biome->getBillboards()[i];
  16.  
  17. osg::ref_ptr<osg::Image> im;
  18.  
  19. // make sure the texture array is POT - required now for mipmapping to work
  20. if ( s < 0 )
  21. {
  22. s = nextPowerOf2(bb._image->s());
  23. t = nextPowerOf2(bb._image->t());
  24. tex->setTextureSize(s, t, getTotalNumBillboards());
  25. }
  26.  
  27. if ( bb._image->s() != s || bb._image->t() != t )
  28. {
  29. ImageUtils::resizeImage( bb._image.get(), s, t, im );
  30. }
  31. else
  32. {
  33. im = bb._image.get();
  34. }
  35.  
  36. tex->setImage( arrayIndex, im.get() );
  37. }
  38. }
  39.  
  40. tex->setFilter(tex->MIN_FILTER, tex->NEAREST_MIPMAP_LINEAR);
  41. tex->setFilter(tex->MAG_FILTER, tex->LINEAR);
  42. tex->setWrap (tex->WRAP_S, tex->CLAMP_TO_EDGE);
  43. tex->setWrap (tex->WRAP_T, tex->CLAMP_TO_EDGE);
  44. tex->setUnRefImageDataAfterApply( true );
  45. tex->setMaxAnisotropy( 4.0 );
  46. //tex->setResizeNonPowerOfTwoHint( false ); // no longer legal for tex2darray!
  47.  
  48. return tex;
  49. }
Add Comment
Please, Sign In to add comment