From fe66501c47a0aadcd1ff1f9d6e4809c686b01e5e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 15 Aug 2007 15:07:56 +0000 Subject: [PATCH] From Stephan Huber, "the softshadowmap-implementation does not compile on os x, to be more precise, the shader does not compile on os x because of some type-conflicts ala "can not convert from const int to const float" So I changed the offending lines to force the type of the vars. It works now on OS X (albeit very slowly, 3fps on a 7300), perhaps you find the changes useful. Note: perhaps there is a better way in shaders to cast/convert from int to float and viceversa." --- src/osgShadow/SoftShadowMap.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/osgShadow/SoftShadowMap.cpp b/src/osgShadow/SoftShadowMap.cpp index 7165c8df8..2592e85d8 100755 --- a/src/osgShadow/SoftShadowMap.cpp +++ b/src/osgShadow/SoftShadowMap.cpp @@ -34,9 +34,11 @@ using namespace osgShadow; // GPU Gems 2, Matt Pharr ed. Addison-Wesley. // static const char fShaderSource_noBaseTexture[] = - "#define SAMPLECOUNT 64 \n" + "#define SAMPLECOUNT 64 \n" + "#define SAMPLECOUNT_FLOAT 64.0 \n" "#define SAMPLECOUNT_D2 32 \n" - "#define INV_SAMPLECOUNT (1.0f / SAMPLECOUNT) \n" + "#define SAMPLECOUNT_D2_FLOAT 32.0 \n" + "#define INV_SAMPLECOUNT (1.0 / SAMPLECOUNT_FLOAT) \n" "uniform sampler2DShadow shadowTexture; \n" "uniform sampler3D jitterMapSampler; \n" @@ -53,12 +55,12 @@ static const char fShaderSource_noBaseTexture[] = " vec3 jitterCoord = vec3( gl_FragCoord.xy / jscale, 0.0 ); \n" " vec4 shadow = vec4(0.0, 0.0, 0.0, 0.0); \n" // First "cheap" sample test - " const float pass_div = 1.0f / (2.0 * 4); \n" + " const float pass_div = 1.0 / (2.0 * 4.0); \n" " for ( int i = 0; i < 4; ++i ) \n" " { \n" // Get jitter values in [0,1]; adjust to have values in [-1,1] " vec4 offset = 2.0 * texture3D( jitterMapSampler, jitterCoord ) -1.0; \n" - " jitterCoord.z += 1.0 / SAMPLECOUNT_D2; \n" + " jitterCoord.z += 1.0 / SAMPLECOUNT_D2_FLOAT; \n" " smCoord.xy = sceneShadowProj.xy + (offset.xy) * softFactor; \n" " shadow += shadow2DProj( shadowTexture, smCoord ) * pass_div; \n" @@ -67,12 +69,12 @@ static const char fShaderSource_noBaseTexture[] = " shadow += shadow2DProj( shadowTexture, smCoord ) *pass_div; \n" " } \n" // skip all the expensive shadow sampling if not needed - " if ( shadow * (shadow -1.0) != 0 ) \n" + " if ( shadow * (shadow -1.0) != 0.0 ) \n" " { \n" " shadow *= pass_div; \n" - " for (int i=0; i