I finally got it! I replaced the calcPhongSpotLight() function in "Content/shaders/utilityLib/fragLighting.glsl" with a function that returns a constant term, and the whole system executes nicely! Except of course that the lighting is not correct
I assume therefore that the phong lighting equation there is overrunning my cards capabilities/finding an obscure bug. I am not a shader wizard, so I wonder if someone else could have a bash at working up a simplified version of the shader that I could test...
For reference, here is the function it dies with:
Code:
vec3 calcPhongSpotLight( const vec3 pos, const vec3 normal, const vec3 albedo, const float specMask, const float viewDist )
{
vec3 light = lightPos.xyz - pos;
// Distance attenuation
float lightDist = length( light ) / lightPos.w;
float att = max( 1.0 - lightDist * lightDist, 0.0 );
light = normalize( light );
// Spotlight falloff
float angle = dot( lightDir, -light );
att *= clamp( (angle - lightCosCutoff) / 0.2, 0.0, 1.0 );
// Half lambert lighting
float NdotL = dot( normal, light );
float diffuse = NdotL * 0.5 + 0.5;
diffuse = diffuse * diffuse;
// Final color
vec3 col = albedo * lightColor * (diffuse + 0.3) * att; // Diffuse & ambient color
// Shadow
if( NdotL > 0.0 && att > 0.0 )
{
mat4 lightMat;
if( viewDist < shadowSplitDists.x ) lightMat = shadowMats[0];
else if( viewDist < shadowSplitDists.y ) lightMat = shadowMats[1];
else if( viewDist < shadowSplitDists.z ) lightMat = shadowMats[2];
else lightMat = shadowMats[3];
vec4 projShadow = lightMat * vec4( pos, 1.0 );
projShadow.z = lightDist;
projShadow.xy /= projShadow.w;
float shadowFac = PCF( projShadow );
col *= max( 0.5, shadowFac );
// Specular
vec3 eye = normalize( viewer - pos );
vec3 refl = reflect( -light, normal );
float spec = pow( clamp( dot( refl, eye ), 0.0, 1.0 ), 8.0 ) * specMask;
col += vec3( 0.3, 0.3, 0.4 ) * spec * att * shadowFac;
}
return col;
}
And here is my replacement which ends the crashing...
Code:
vec3 calcPhongSpotLight( const vec3 pos, const vec3 normal, const vec3 albedo, const float specMask, const float viewDist )
{
return vec3(0.5);
}
However, this does confirm it is a problem with my specific card/driver and the shader, rather than the engine code itself, so I am going to go ahead an package up a binary SDK for Mac. Would you like me to place it elsewhere, or could it be hosted here? For the record, I am willing to be the maintainer for the Mac port, especially since I am gearing up a project using Horde for the renderer.
Edit: Here is the binary distribution:
deprecated - see newer version below.
I would be obliged if any other Mac users could give it a spin and see if it works...