]> git.mxchange.org Git - simgear.git/commitdiff
Add noise texture and noise normal map to StateAttributeFactory
authorFrederic Bouvier <fredfgfs01@free.fr>
Mon, 23 Jan 2012 20:22:44 +0000 (21:22 +0100)
committerFrederic Bouvier <fredfgfs01@free.fr>
Sun, 4 Mar 2012 19:21:34 +0000 (20:21 +0100)
simgear/scene/util/StateAttributeFactory.cxx
simgear/scene/util/StateAttributeFactory.hxx

index 3e289ad57e9d4e51895e3e67388ba1ae169cb51b..0ad63c51e7dc9c15400c4c388a4ea2052c4f3e18 100644 (file)
 #include <osg/Depth>
 #include <osg/ShadeModel>
 #include <osg/Texture2D>
+#include <osg/Texture3D>
 #include <osg/TexEnv>
 
 #include <osg/Image>
 
+#include <simgear/scene/material/Noise.hxx>
+
 using namespace osg;
 
 namespace simgear
@@ -86,10 +89,375 @@ StateAttributeFactory::StateAttributeFactory()
     _depthWritesDisabled->setDataVariance(Object::STATIC);
 }
 
+osg::Image* make3DNoiseImage(int texSize)
+{
+    osg::Image* image = new osg::Image;
+    image->setImage(texSize, texSize, texSize,
+                    4, GL_RGBA, GL_UNSIGNED_BYTE,
+                    new unsigned char[4 * texSize * texSize * texSize],
+                    osg::Image::USE_NEW_DELETE);
+
+    const int startFrequency = 4;
+    const int numOctaves = 4;
+
+    int f, i, j, k, inc;
+    double ni[3];
+    double inci, incj, inck;
+    int frequency = startFrequency;
+    GLubyte *ptr;
+    double amp = 0.5;
+
+    osg::notify(osg::WARN) << "creating 3D noise texture... ";
+
+    for (f = 0, inc = 0; f < numOctaves; ++f, frequency *= 2, ++inc, amp *= 0.5)
+    {
+        SetNoiseFrequency(frequency);
+        ptr = image->data();
+        ni[0] = ni[1] = ni[2] = 0;
+
+        inci = 1.0 / (texSize / frequency);
+        for (i = 0; i < texSize; ++i, ni[0] += inci)
+        {
+            incj = 1.0 / (texSize / frequency);
+            for (j = 0; j < texSize; ++j, ni[1] += incj)
+            {
+                inck = 1.0 / (texSize / frequency);
+                for (k = 0; k < texSize; ++k, ni[2] += inck, ptr += 4)
+                {
+                    *(ptr+inc) = (GLubyte) (((noise3(ni) + 1.0) * amp) * 128.0);
+                }
+            }
+        }
+    }
+
+    osg::notify(osg::WARN) << "DONE" << std::endl;
+    return image;
+}
+
+osg::Texture3D* StateAttributeFactory::getNoiseTexture(int size)
+{
+    NoiseMap::iterator itr = _noises.find(size);
+    if (itr != _noises.end())
+        return itr->second.get();
+    Texture3D* noiseTexture = new osg::Texture3D;
+    noiseTexture->setFilter(osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR);
+    noiseTexture->setFilter(osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_S, osg::Texture3D::REPEAT);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture3D::REPEAT);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT);
+    noiseTexture->setImage( make3DNoiseImage(size) );
+    _noises.insert(std::make_pair(size, noiseTexture));
+    return noiseTexture;
+}
+
+static osg::Image* make2DNoiseNormal();
+osg::Texture2D* StateAttributeFactory::getNoiseNormalMap()
+{
+    if (_noiseNormalTexture.valid())
+        return _noiseNormalTexture.get();
+
+    _noiseNormalTexture = new osg::Texture2D;
+    _noiseNormalTexture->setFilter(osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR);
+    _noiseNormalTexture->setFilter(osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR);
+    _noiseNormalTexture->setWrap(osg::Texture3D::WRAP_S, osg::Texture3D::REPEAT);
+    _noiseNormalTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture3D::REPEAT);
+    _noiseNormalTexture->setImage( make2DNoiseNormal() );
+    return _noiseNormalTexture;
+}
+
 // anchor the destructor into this file, to avoid ref_ptr warnings
 StateAttributeFactory::~StateAttributeFactory()
 {
   
 }
   
+/*  GIMP header image file format (RGB):  */
+
+static unsigned int noiseNormalWidth = 64;
+static unsigned int noiseNormalHeight = 64;
+
+/*  Call this macro repeatedly.  After each use, the pixel data can be extracted  */
+
+#define NOISE_NORMAL_PIXEL(data,pixel) {\
+pixel[0] = (((data[0] - 33) << 2) | ((data[1] - 33) >> 4)); \
+pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2)); \
+pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33))); \
+data += 4; \
+}
+static char *noiseNormalData =
+       "@Y4`CI$`BXX`>XP`>HH_AH<`B8H`?X\\`AHT`B8\\`B8\\`@H`^>I$\\>Y(^@(T_AHD`"
+       "?)$]B),`DI0`BI0`?90`>),^@HX^C8@^AHP`A8<`B(<`BHD`AHD\\@HD]A(L_A(D`"
+       "DXD`@8L`=HX\\?9(_CI(`D8X`AY,`?9H`?9,\\@9(_A(X_A(H^@H@\\@8L\\?X`]?)$]"
+       "@I<`AY,`@I,`>9<]?Y8_CY$`D(T`@HX^@HH[B(``BY,`A90]@9<^A9P`AYT`AI<`"
+       ">XPZAHD^A8H`?(P_?(X`AXT`B(X`@)(`A9$`B),`BY,`AY4`@)<`@9@`A)4`AY$`"
+       ">H\\\\A(X_B8P_@HP]>8`\\>I(^A(``D(T`@(T`@(H]A8L]AXT_@XT^@H`_AY,`B9,`"
+       "BXH`@(H]>XT[@9(`BI(`BX\\`@X\\^?I,`@9(_A)(`A8\\`A(L_@XH^@XT^@Y$`@9(_"
+       "BI8`B)(`A9,`@I@`AY@`BY,`A8T^>8HX@(X]A9$`B),`A),^@),]@),_@8\\]?XDZ"
+       ">XDX@H@Z@XL\\?X`^@9,`B),`AY(_?Y4^AI@^B98`B90`A9$`@)(`?Y0`@90`@9(]"
+       "?9(_A(X_AXH]@(H[>8`\\?)0`AY,`D(``?Y0`@9(_AY,`B)<`@I,`@),_A)4`AI0`"
+       "@(P^?XL]@(P\\AI$`B),`A(``@HX^@X\\`AY$`AY,`AI(`A(``@HX`@X\\`A(``A8\\`"
+       "CY(`@X\\_?XT[AX\\_C)(`A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+       "A98`B(``@8T]>8X[?8X[B(X_BI(`@9@`AI0`AY,`AY$`A9$`@I,`@I0`AI<`BY<`"
+       "AY,`A9,`@I,`A9,`AY(_AY(`@Y$_?I$]AHP`@XH^@8T_@X\\`A(``A(X`B(X`C8``"
+       "?HL]@(T_@HX`@HX`@8T]@XT^A8\\`AH``@9$`A)$`AI(`B90`B98`B)<`@Y8`@)4`"
+       "@Y0`?),^>I,[@90\\C98`D)D`B)D`?9D`?)0`@I(`BH``BH``A9$`@I,`AI(`BY$`"
+       "A(``BH``A9$`>I,]>X`\\AXT^BX\\`@I,`@I(`A9$`AHT`@XH^?H@[?H@[A(L_BHT`"
+       "@HX`@H\\`@Y$`@X\\^A8T]A(P\\@HX^@)$_B9(`A8X`@XX`AY$`AHT`@X8[A80[C8H`"
+       "?H\\]A)(`AI(`A8\\`A8\\`AY,`A9,`?X`]@XT`A(X`B(``B9$`AY(`A)(`@9,`?Y0`"
+       "@XT`>X`]>),]@90`C),`CY$`@X\\^=X`Z>I(^@9,`B9,`BI0`AY,`A)(`A(X_AHP^"
+       "@HH[BXX`AI0`>I4_?90_BH``BXT_@8P[?X\\`@X\\`AHT`A(L_@(H]?8D[?H@Y@8DZ"
+       "?HD^?XP^@8\\^@X\\_AHX_AHP^@HX`?X\\`@8H`@(H_@8P`@X\\`A(X_A(P]B8T^CI(`"
+       "?9(^@I,`AI(`B(``B9$`B)0`A)4`@),_@(P^@8T_@XT^A8T^@XL\\@8L^@8P`@8X`"
+       "AHL`@X``@)4`A9,`B8\\`B(H]@(<[>(@Y=XXY?8`\\A)(`AI0`A9,`A(``A(X_A8T^"
+       "B8\\`C(``@H`^=8`Z>I$\\BY$`CH``A(X_@HX^A(X_B8\\`BI(`AY4`A9@`A)<`A)4`"
+       "@9$`@9$`A)(`AH``BH``B8\\`@X\\`?8\\`?X8Z@8L\\@HX^@(X\\@8`[@Y0_AI@`A9<_"
+       "?I$]?8X[@8T\\A8`_AI$`A9$`A)(`@I4`?Y$`@)(`@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AHX^@90^@)<`@),]@(TW"
+       "@H<^@80YA8DZAI$^A98`A)L`@9<`>X\\`@I<VBI@^CI4`AY(`@90`@)D`A)P`AIH^"
+       "A)<_?9@`>)0`>X``AH\\`B(\\`@90^?9X_A9@`A)4`@9(`@8\\^@HX`@XT`@XT`@HP_"
+       "C(`_B(H\\B(@\\B8P`AXX`@HX`@XT`B(``BI(`?X`^>8\\^?8T`AXH`D(T`C8``@8T]"
+       "?(``?I0`?Y8`@90`A90]BI4`B98^@Y4[@9H`@I4`@XX]AHD\\B(H]AXT`@8X`>HX`"
+       "?8X\\@XL\\BXL^C(X`A(\\^?(X\\?)$`A)8`D)0`B98`@90`?H\\]@HH[AXH]AX\\`A)(`"
+       "A9(^?9(_>(X]?8H^B8H`C(D^B(P[AI,]AI,_AY0`AY8`A9,`@9(_?Y(^@)(`@9,`"
+       "B9$`B(P]AX@^B(L`A8P`@(P^@8L^AXT_BXT`?XD\\>(T\\>H``?8T^@8@\\A(<Z@X4X"
+       "@X8YA(P]@X\\^@Y$_@Y0_AYH`@YP`?IP`A)L`A9@`AI0`AY$`B(``A(``?HX_>8T_"
+       "@9(`B(``CH``D9,`AY(`?8\\]>H\\^@)(`BY(`A9$`?X`^@(X]A8P`B8P_AHX_A(`_"
+       "A9$`?I,`>9(\\>X`\\B(``C(P_B(H\\AHP]A8PXB)$\\B90_AY8`@90^?),\\?98^?IH`"
+       "AY,`A8\\`AHP`AXT`@HP`@(H]@HD]B8P`D8X`AXH_@X``@IH`>Y<`>H\\\\A(H[D(<]"
+       "A(`_@Y0`@I4`@I,`A9$`BI(`AY(`@8\\]?9(^@),_@I4`@Y4`A)4`@I(`@(``?8\\_"
+       "A)4`B)(`CI(`CY,`AY(`?H\\]>XT]?H``AHP^@(H[?HL]@H\\`B8``BH``BH``BI(`"
+       "@)(`?94`>)@^?)T`AI``AYH`@I,`@9,`A8L\\AX\\_AY(`AI(`@Y$_?Y(^@)4`A)D`"
+       "@Y4`A9(`AH``A8\\`@HX`@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       "C90`AI(`@)(`@)(`@Y$`A8T^A(P]A8P`@Y$_?X`^?H\\]@8T_A8@_A80_B(@`BX``"
+       "@(X\\@Y$_A9$`A(X_A(P]A(P]AHT`AHT`?Y$_?X`^?XP^?8T^?H``@)(`A9,`B),`"
+       "?XD^?(<\\?(8[@88]AX@`C(@`B(D_A(<\\>X`_@(``@Y$`@H`^@Y$`AH``@HX`?8H\\"
+       "@8XZ@XX[AI$^B90`B94`B)8`AY4`AI0`?H<`@8@`AHD`B(L`AHX_@8\\^?I4`?YH`"
+       "B94]@Y$_?8\\`?XX`A(\\`AXX`B(``B8``BY,`@I0`?94`@)(`B(L`BH<^BHL`B)(`"
+       "@),[A)<`@Y8`@)$^@8T]AX\\`CH\\`CXX`@I(`@HT`@XT`A(``@Y0`@9,`A9,`B90`"
+       "@9,`?I,`@)(`AI0`C)0`C8``AXT_@(H[@XH^@(P^@X\\_AY(`AI(`?Y$_>Y(^?I,`"
+       "AI,_AI,_AI(`B),`B90`AI(`@)$_?8\\]?(``@9$`AY$`BH``B(``@X\\^@90`@9@`"
+       "AI,[@8\\]?(T`?HT`@XX`AXX`AH``A9$`BXX`@9(`>Y,_?I4`AI,_BI$]AY,[@Y<\\"
+       "@I@_@YD`@)8_?8`\\?XT\\A8T^B8H`AX8]@8P`@8@^@H<^AXT`AH``@H`^A(`_BI(`"
+       "?Y8`?94`?I4`@Y8`B98`B90`A9$`@)$^BHL`@HP]@HX]BY$`AY0`>Y0^>I<`@YL`"
+       "BI8`AI0`@Y$_@HX^A8T^A8P`?XP^>(T\\>Y(^@)(`A9,`AY(`AX\\_A(\\\\@I$\\@I,^"
+       "AY0`@)$_?8\\`?X\\`A(``@X\\^@(X\\?(X\\A(H^@(P\\?)$]?I4^A9D^B9D^B)L]AILZ"
+       "@98`@)4`?Y0`@)(`A)(`AY$`AHT`@XD]?8<\\?X0[@X8[B(L^B(``A8`_A8`_BH``"
+       "?HX_>XT[?(\\[@)$^AI$^AI$`A(`_@I,`C(X`@H`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H`^?Y(^?I,`"
+       "?8T`?(P]>X@Z?84V@80WA8@]A(X`@H\\`?90`?Y0`@I<`AI@`AY<`AY0`A9$`@XT`"
+       "C(``AXT_AX\\`@X\\`?HX_?Y$`@)<`?I<`A90_BY,`B90`?Y0`?I,_AX\\_BH``AI(`"
+       "A(T`@HD`@HD_A(X`A(\\`@8L`A8<`BH8`DHH`BHL`@XT^@H`_@Y$`@Y$`@I,`@Y4`"
+       "A9@`A)<`@9,`@)(`@(``@8\\^@XT^A(P\\?Y@`@Y8`B90`C),`AI$^@(X\\?H\\]?X`^"
+       "?H``@)(`@9,`A(``AXT_B8P_AHP^@8L^?X`^?X`^@8\\^@HX^@HX^@XT^A8T^AHX_"
+       "B9$`@XT^@8T_@8T_@(P^@X\\`A9,`@90`@Y8`C)(`BY$`?Y$_?H\\]B8P_BXX`@I(`"
+       ">X\\`@8X`AXX`AH``@Y$`?X\\`@X\\`B8X`CXH`B(H]@8L\\?XT\\@8T_@XH^@XH^A8P`"
+       "@YH`@9@`?Y0`?H`^?XP^@(H]@XD[AHD\\?Y(^@HX]AHX^B(``A8\\`?XP^?8H^?HL`"
+       "@HP_A9(`AI@`B)D`BI8`B90`A8`_@(P\\AXT`A8L]@XD[@8<Y@X<XA8DZB(P[BHX]"
+       "AY4`@9(`@9$`@X``A8P`B(X`B(``@XX]>Y(^B8\\`BHT`@(X]?HL]B(<^B(D_?(X`"
+       "=I$\\@Y8`C)<`AI,_?I$[?),^?Y0`A9,`CX\\`B(``A)(`A9(`AH``AXH_AX8_BH8`"
+       "A(\\ZA(\\\\@HX]@(X]?X\\`@9$`AI,`B)4`BI(`B8\\`BHT`BH``AI$`?X\\`>XH`>X<`"
+       "BXH`AX\\`@9(`?I$]?I$[@9(]@Y0`@Y0`?HX_@9(`A98`B)D`B9H`B)D`AID`A9@`"
+       "";
+
+static osg::Image* make2DNoiseNormal() {
+    osg::Image* image = new osg::Image;
+    image->setImage(noiseNormalWidth, noiseNormalHeight, 1,
+                    GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE,
+                    new unsigned char[3 * noiseNormalWidth * noiseNormalHeight],
+                    osg::Image::USE_NEW_DELETE);
+
+    char* data = noiseNormalData;
+    for (unsigned int i=0; i<noiseNormalHeight; ++i) {
+        for (unsigned int j=0; j<noiseNormalWidth; ++j) {
+            GLubyte *ptr = image->data(i,j);
+            NOISE_NORMAL_PIXEL(data,ptr);
+        }
+    }
+
+    return image;
+}
 }
index 12b6840b144dab1982ffa9e5563f8a8380286c2b..95750849b8277fe8e89307be0105442229f9bef5 100644 (file)
@@ -25,6 +25,7 @@
 #include <OpenThreads/Mutex>
 #include <osg/ref_ptr>
 #include <osg/Array>
+#include <map>
 
 namespace osg
 {
@@ -34,6 +35,7 @@ class CullFace;
 class Depth;
 class ShadeModel;
 class Texture2D;
+class Texture3D;
 class TexEnv;
 }
 
@@ -69,6 +71,8 @@ public:
     osg::CullFace* getCullFaceBack() { return _cullFaceBack.get(); }
     // Standard depth with writes disabled.
     osg::Depth* getDepthWritesDisabled() { return _depthWritesDisabled.get(); }
+    osg::Texture3D* getNoiseTexture(int size);
+    osg::Texture2D* getNoiseNormalMap();
     StateAttributeFactory();    
 protected:
     osg::ref_ptr<osg::AlphaFunc> _standardAlphaFunc;
@@ -78,10 +82,13 @@ protected:
     osg::ref_ptr<osg::TexEnv> _standardTexEnv;
     osg::ref_ptr<osg::Texture2D> _whiteTexture;
     osg::ref_ptr<osg::Texture2D> _transparentTexture;
+    osg::ref_ptr<osg::Texture2D> _noiseNormalTexture;
     osg::ref_ptr<osg::Vec4Array> _white;
     osg::ref_ptr<osg::CullFace> _cullFaceFront;
     osg::ref_ptr<osg::CullFace> _cullFaceBack;
     osg::ref_ptr<osg::Depth> _depthWritesDisabled;
+    typedef std::map<int, osg::ref_ptr<osg::Texture3D> > NoiseMap;
+    NoiseMap _noises;
 };
 }
 #endif