#include <stdlib.h>#include <stdio.h>#include <OSGConfig.h>#include <OSGLog.h>#include <OSGImage.h>#include <OSGBaseFunctions.h>#include "OSGImageFunctions.h"Go to the source code of this file.
Namespaces | |
| namespace | osg |
Defines | |
| #define | MAXB 0x100 |
Functions | |
| bool | createComposedImage (std::vector< ImagePtr > imageVec, ImagePtr image, SliceDataType sliceDataType) |
| bool | osg::createNormalMapFromBump (ImagePtr image, ImagePtr dst, Vec3f normalMapScale) |
| void | osg::createNormalVolume (ImagePtr inImage, ImagePtr outImage, AlphaValue alphaValue) |
| bool | osg::create2DPreIntegrationLUT (ImagePtr dst, ImagePtr src, Real32 thickness) |
| bool | osg::splitRGBA (ImagePtr rgba, ImagePtr rgb, ImagePtr alpha) |
| bool | osg::mergeRGBA (ImagePtr rgb, ImagePtr alpha, ImagePtr rgba) |
| bool | osg::createPhongTexture (ImagePtr image, UInt32 size, Real32 specular_exponent, Real32 ka, Real32 kd, Real32 ks) |
| bool | osg::createNormalizationCubeMap (std::vector< ImagePtr > imageVec, UInt32 size) |
| void | setNoiseFrequency (Int32 frequency) |
| Real32 | lerp (Real32 t, Real32 a, Real32 b) |
| Real32 | sCurve (Real32 t) |
| Real32 | at2 (Real32 *q, Real32 rx, Real32 ry) |
| Real32 | at3 (Real32 *q, Real32 rx, Real32 ry, Real32 rz) |
| void | setup (Real32 *vec, UInt8 i, Real32 &t, Int32 &b0, Int32 &b1, Real32 &r0, Real32 &r1) |
| void | normalize2 (Real32 v[2]) |
| void | normalize3 (Real32 v[3]) |
| void | init (void) |
| Real32 | noise1 (Real32 vec[1]) |
| Real32 | noise2 (Real32 vec[2]) |
| Real32 | noise3 (Real32 vec[3]) |
| Real32 | noise (Real32 vec[], Int32 len) |
| bool | osg::createNoise (ImagePtr image, Image::PixelFormat pixelformat, UInt16 numOctaves, UInt16 size, UInt8 dim, bool splitOctaves) |
Variables | |
| Int32 | p [MAXB+MAXB+2] |
| Real32 | g3 [MAXB+MAXB+2][3] |
| Real32 | g2 [MAXB+MAXB+2][2] |
| Real32 | g1 [MAXB+MAXB+2] |
| Int32 | start = 1 |
| Int32 | B = 0x100 |
| Int32 | BM = 0xff |
|
|
Definition at line 843 of file OSGImageFunctions.cpp. |
|
||||||||||||||||
|
composes multiple images to one Definition at line 68 of file OSGImageFunctions.cpp. References osg::DEPTH_SDT, osg::FieldContainerPtrBase::dump(), FLOG, osg::FRAME_SDT, FWARNING, osg::INVALID_SDT, osg::osgMax(), osg::SIDE_SDT, and osg::subRefCP(). 00071 { 00072 UInt32 dataSize, i, n = imageVec.size(); 00073 Int32 w, h; 00074 UInt8 *destData, *srcData; 00075 Image::PixelFormat pf; 00076 Image::Type dt; 00077 bool needColor, needAlpha, needCopy = false; 00078 ImagePtr copy = Image::create(); 00079 UInt32 depth, frameCount, sideCount; 00080 00081 if (n) { 00082 for (i = 0; i < n; i++) { 00083 if ( i == 0 ) { 00084 pf = Image::PixelFormat(imageVec[0]->getPixelFormat()); 00085 dt = Image::Type(imageVec[0]->getDataType()); 00086 w = imageVec[0]->getWidth(); 00087 h = imageVec[0]->getHeight(); 00088 needAlpha = imageVec[0]->hasAlphaChannel(); 00089 needColor = imageVec[0]->hasColorChannel(); 00090 } 00091 else { 00092 needAlpha |= imageVec[i]->hasAlphaChannel(); 00093 needColor |= imageVec[i]->hasColorChannel(); 00094 if (Image::PixelFormat(imageVec[i]->getPixelFormat()) != pf) { 00095 needCopy = true; 00096 FWARNING (( "Image has different PF while composing\n" )); 00097 pf = Image::OSG_INVALID_PF; 00098 } 00099 if (Image::Type(imageVec[i]->getDataType()) != dt) { 00100 needCopy = true; 00101 FWARNING (( "Image has different DT while composing\n" )); 00102 dt = Image::OSG_INVALID_IMAGEDATATYPE; 00103 } 00104 if (imageVec[i]->getWidth() != w) { 00105 needCopy = true; 00106 FWARNING (( "Image has different width while composing\n" )); 00107 w = osgMax ( w, imageVec[i]->getWidth()); 00108 } 00109 if (imageVec[i]->getHeight() != h) { 00110 needCopy = true; 00111 FWARNING (( "Image has different height while composing\n" )); 00112 h = osgMax ( h, imageVec[i]->getHeight()); 00113 } 00114 } 00115 } 00116 00117 if (pf == Image::OSG_INVALID_PF) { 00118 if (needColor) 00119 if (needAlpha) 00120 pf = OSG::Image::OSG_RGBA_PF; 00121 else 00122 pf = OSG::Image::OSG_RGB_PF; 00123 else 00124 if (needAlpha) 00125 pf = OSG::Image::OSG_LA_PF; 00126 else 00127 pf = OSG::Image::OSG_L_PF; 00128 } 00129 00130 if (dt == Image::OSG_INVALID_IMAGEDATATYPE) 00131 dt = Image::OSG_UINT8_IMAGEDATA; 00132 00133 depth = frameCount = sideCount = 1; 00134 switch (sliceDataType) { 00135 case FRAME_SDT: 00136 frameCount = n; 00137 break; 00138 case SIDE_SDT: 00139 sideCount = n; 00140 case INVALID_SDT: 00141 case DEPTH_SDT: 00142 default: 00143 depth = n; 00144 break; 00145 } 00146 00147 image->set( pf, w, h, depth, 1, frameCount, 0.0, 00148 0, dt, true, sideCount ); 00149 00150 destData = image->getData(); 00151 dataSize = image->getSize() / n; 00152 00153 if (needCopy) { 00154 FLOG (("Image data/type/size missmatch while composing\n")); 00155 } 00156 00157 for (i = 0; i < n; i++) { 00158 if (needCopy) { 00159 copy->set(imageVec[i]); 00160 if ( Image::PixelFormat(copy->getPixelFormat()) != pf ) 00161 copy->reformat(pf); 00162 if ( Image::Type(copy->getDataType()) != dt ) 00163 copy->convertDataTypeTo(dt); 00164 if ( (w != copy->getWidth()) || (h != copy->getHeight())) 00165 copy->scale(w,h,copy->getDepth()); 00166 srcData = copy->getData(); 00167 } 00168 else 00169 srcData = imageVec[i]->getData(); 00170 00171 memcpy ( destData, srcData, dataSize ); 00172 destData += dataSize; 00173 } 00174 } 00175 00176 subRefCP(copy); 00177 00178 imageVec[0]->dump(); 00179 image->dump(); 00180 00181 return true; 00182 }
|
|
|
Definition at line 854 of file OSGImageFunctions.cpp. Referenced by osg::createNoise().
|
|
||||||||||||||||
|
Definition at line 861 of file OSGImageFunctions.cpp. Referenced by noise1(), noise2(), and noise3().
|
|
|
Definition at line 866 of file OSGImageFunctions.cpp. Referenced by noise1(), noise2(), and noise3().
|
|
||||||||||||||||
|
Definition at line 871 of file OSGImageFunctions.cpp. Referenced by noise2().
|
|
||||||||||||||||||||
|
Definition at line 876 of file OSGImageFunctions.cpp. Referenced by noise3().
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 881 of file OSGImageFunctions.cpp. Referenced by noise1(), noise2(), noise3(), and osg::QFCItem::setup(). 00885 { 00886 t = vec[i] + 0x1000; 00887 b0 = ((Int32)t) & BM; 00888 b1 = (b0 + 1) & BM; 00889 r0 = t - (Int32)t; 00890 r1 = r0 - 1.0f; 00891 }
|
|
|
Definition at line 893 of file OSGImageFunctions.cpp. Referenced by init(). 00894 { 00895 Real32 s = sqrt(v[0] * v[0] + v[1] * v[1]); 00896 v[0] = v[0] / s; 00897 v[1] = v[1] / s; 00898 }
|
|
|
Definition at line 900 of file OSGImageFunctions.cpp. Referenced by init(). 00901 { 00902 Real32 s = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); 00903 v[0] = v[0] / s; 00904 v[1] = v[1] / s; 00905 v[2] = v[2] / s; 00906 }
|
|
|
|
Definition at line 945 of file OSGImageFunctions.cpp. References init(), lerp(), sCurve(), and setup(). Referenced by noise(). 00946 { 00947 Int32 bx0, bx1; 00948 Real32 rx0, rx1, sx, t, u, v; 00949 00950 if (start) 00951 { 00952 start = 0; 00953 init(); 00954 } 00955 00956 setup(vec, 0, t, bx0, bx1, rx0, rx1); 00957 00958 sx = sCurve(rx0); 00959 00960 u = rx0 * g1[ p[ bx0 ] ]; 00961 v = rx1 * g1[ p[ bx1 ] ]; 00962 00963 return lerp(sx, u, v); 00964 }
|
|
|
Definition at line 966 of file OSGImageFunctions.cpp. References at2(), init(), lerp(), sCurve(), and setup(). Referenced by noise(). 00967 { 00968 Int32 bx0, bx1, by0, by1, b00, b10, b01, b11; 00969 Real32 rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v; 00970 Int32 i, j; 00971 00972 if (start) 00973 { 00974 start = 0; 00975 init(); 00976 } 00977 00978 setup(vec, 0, t, bx0, bx1, rx0, rx1); 00979 setup(vec, 1, t, by0, by1, ry0, ry1); 00980 00981 i = p[ bx0 ]; 00982 j = p[ bx1 ]; 00983 00984 b00 = p[ i + by0 ]; 00985 b10 = p[ j + by0 ]; 00986 b01 = p[ i + by1 ]; 00987 b11 = p[ j + by1 ]; 00988 00989 sx = sCurve(rx0); 00990 sy = sCurve(ry0); 00991 00992 q = g2[ b00 ] ; u = at2(q, rx0,ry0); 00993 q = g2[ b10 ] ; v = at2(q, rx1,ry0); 00994 a = lerp(sx, u, v); 00995 00996 q = g2[ b01 ] ; u = at2(q, rx0,ry1); 00997 q = g2[ b11 ] ; v = at2(q, rx1,ry1); 00998 b = lerp(sx, u, v); 00999 01000 return lerp(sy, a, b); 01001 }
|
|
|
Definition at line 1003 of file OSGImageFunctions.cpp. References at3(), init(), lerp(), sCurve(), and setup(). Referenced by noise(). 01004 { 01005 Int32 bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11; 01006 Real32 rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v; 01007 Int32 i, j; 01008 01009 if (start) 01010 { 01011 start = 0; 01012 init(); 01013 } 01014 01015 setup(vec, 0, t, bx0, bx1, rx0, rx1); 01016 setup(vec, 1, t, by0, by1, ry0, ry1); 01017 setup(vec, 2, t, bz0, bz1, rz0, rz1); 01018 01019 i = p[ bx0 ]; 01020 j = p[ bx1 ]; 01021 01022 b00 = p[ i + by0 ]; 01023 b10 = p[ j + by0 ]; 01024 b01 = p[ i + by1 ]; 01025 b11 = p[ j + by1 ]; 01026 01027 t = sCurve(rx0); 01028 sy = sCurve(ry0); 01029 sz = sCurve(rz0); 01030 01031 q = g3[ b00 + bz0 ] ; u = at3(q, rx0,ry0,rz0); 01032 q = g3[ b10 + bz0 ] ; v = at3(q, rx1,ry0,rz0); 01033 a = lerp(t, u, v); 01034 01035 q = g3[ b01 + bz0 ] ; u = at3(q, rx0,ry1,rz0); 01036 q = g3[ b11 + bz0 ] ; v = at3(q, rx1,ry1,rz0); 01037 b = lerp(t, u, v); 01038 01039 c = lerp(sy, a, b); 01040 01041 q = g3[ b00 + bz1 ] ; u = at3(q, rx0,ry0,rz1); 01042 q = g3[ b10 + bz1 ] ; v = at3(q, rx1,ry0,rz1); 01043 a = lerp(t, u, v); 01044 01045 q = g3[ b01 + bz1 ] ; u = at3(q, rx0,ry1,rz1); 01046 q = g3[ b11 + bz1 ] ; v = at3(q, rx1,ry1,rz1); 01047 b = lerp(t, u, v); 01048 01049 d = lerp(sy, a, b); 01050 01051 return lerp(sz, c, d); 01052 }
|
|
||||||||||||
|
Definition at line 1054 of file OSGImageFunctions.cpp. References noise1(), noise2(), and noise3(). Referenced by osg::createNoise(). 01055 { 01056 // noise functions over 1, 2, and 3 dimensions 01057 switch (len) 01058 { 01059 case 1: return noise1(vec); 01060 case 2: return noise2(vec); 01061 case 3: return noise3(vec); 01062 case 0: 01063 default: return 0.0f; 01064 } 01065 }
|
|
|
|
Definition at line 846 of file OSGImageFunctions.cpp. |
|
|
Definition at line 847 of file OSGImageFunctions.cpp. |
|
|
Definition at line 848 of file OSGImageFunctions.cpp. Referenced by osg::GradientBackground::clear(). |
|
|
|
Definition at line 850 of file OSGImageFunctions.cpp. Referenced by osg::calcVertexTangents(). |
|
|
Definition at line 851 of file OSGImageFunctions.cpp. |
1.4.3