Bad compile error from TestPssmShadows

I am trying to add shadows to my game but the pssm shadow renderer doesn’t seem to work on my system.

Can anyone make any sense of this error message and see if it’s my graphics card that’s causing the trouble?

My card is an ATI mobility RadeonHD 5650 and I’m running windows 7.

VARNING: Bad compile of:

#define FILTER_MODE 1


#define PCFEDGE 5.0

#extension GL_ARB_texture_gather : enable


#define SHADOWMAP sampler2DShadow

#define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)

#define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)

#define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)


#define SHADOWMAP sampler2D

#define SHADOWCOMPAREOFFSET(tex,coord,offset) step(coord.z, textureProjOffset(tex, coord, offset).r)

#define SHADOWCOMPARE(tex,coord) step(coord.z, textureProj(tex, coord).r)

#define SHADOWGATHER(tex,coord) step(coord.z, textureGather(tex, coord.xy))


#if FILTER_MODE == 0


#define KERNEL 1

#elif FILTER_MODE == 1




#define GETSHADOW Shadow_DoBilinear_2x2


#define KERNEL 1

#elif FILTER_MODE == 2

#define GETSHADOW Shadow_DoDither_2x2

#define KERNEL 1

#elif FILTER_MODE == 3

#define GETSHADOW Shadow_DoPCF

#define KERNEL 4

#elif FILTER_MODE == 4

#define GETSHADOW Shadow_DoPCF

#define KERNEL 8


out vec4 outFragColor;

uniform SHADOWMAP m_ShadowMap0;

uniform SHADOWMAP m_ShadowMap1;

uniform SHADOWMAP m_ShadowMap2;

uniform SHADOWMAP m_ShadowMap3;

uniform vec4 m_Splits;

uniform float m_ShadowIntensity;

in vec4 projCoord0;

in vec4 projCoord1;

in vec4 projCoord2;

in vec4 projCoord3;

in float shadowPosition;

float Shadow_BorderCheck(in vec2 coord){

// Fastest, “hack” method (uses 4-5 instructions)

vec4 t = vec4(coord.xy, 0.0, 1.0);

t = step(t.wwxy, t.xyzz);

return dot(t,t);


float Shadow_DoDither_2x2(in SHADOWMAP tex, in vec4 projCoord){

float border = Shadow_BorderCheck(projCoord.xy);

if (border > 0.0)

return 1.0;

ivec2 texSize = textureSize(tex, 0);

vec2 pixSize = 1.0 / vec2(texSize);

float shadow = 0.0;

ivec2 o = ivec2(mod(floor(gl_FragCoord.xy), 2.0));

shadow += SHADOWCOMPARE(tex, vec4(projCoord.xy+pixSize*(vec2(-1.5, 1.5)+o),;

shadow += SHADOWCOMPARE(tex, vec4(projCoord.xy+pixSize*(vec2( 0.5, 1.5)+o),;

shadow += SHADOWCOMPARE(tex, vec4(projCoord.xy+pixSize*(vec2(-1.5, -0.5)+o),;

shadow += SHADOWCOMPARE(tex, vec4(projCoord.xy+pixSize*(vec2( 0.5, -0.5)+o),;

shadow *= 0.25;

return shadow;


float Shadow_DoBilinear_2x2(in SHADOWMAP tex, in vec4 projCoord){

float border = Shadow_BorderCheck(projCoord.xy);

if (border > 0.0)

return 1.0;

ivec2 texSize = textureSize(tex, 0);

#ifdef GL_ARB_texture_gather

vec4 coord = vec4( / projCoord.w,0.0);

vec4 gather = SHADOWGATHER(tex, coord);


vec4 gather = vec4(0.0);

gather.x = SHADOWCOMPAREOFFSET(tex, projCoord, ivec2(0, 0));

gather.y = SHADOWCOMPAREOFFSET(tex, projCoord, ivec2(1, 0));

gather.z = SHADOWCOMPAREOFFSET(tex, projCoord, ivec2(0, 1));

gather.w = SHADOWCOMPAREOFFSET(tex, projCoord, ivec2(1, 1));


vec2 f = fract( projCoord.xy * texSize );

vec2 mx = mix( gather.xz, gather.yw, f.x );

return mix( mx.x, mx.y, f.y );


float Shadow_DoPCF(in SHADOWMAP tex, in vec4 projCoord){

float pixSize = 1.0 / textureSize(tex,0).x;

float shadow = 0.0;

float border = Shadow_BorderCheck(projCoord.xy);

if (border > 0.0)

return 1.0;

float bound = KERNEL * 0.5 - 0.5;

bound *= PCFEDGE;

for (float y = -bound; y <= bound; y += PCFEDGE){

for (float x = -bound; x <= bound; x += PCFEDGE){

vec4 coord = vec4(projCoord.xy + vec2(x,y) * pixSize,;

shadow += SHADOWCOMPARE(tex, coord);



shadow = shadow / (KERNEL * KERNEL);

return shadow;


void main(){

float shadow = 0.0;

if(shadowPosition < m_Splits.x){

shadow = GETSHADOW(m_ShadowMap0, projCoord0);

}else if( shadowPosition < m_Splits.y){

shadow = GETSHADOW(m_ShadowMap1, projCoord1);

}else if( shadowPosition < m_Splits.z){

shadow = GETSHADOW(m_ShadowMap2, projCoord2);

}else if( shadowPosition < m_Splits.w){

shadow = GETSHADOW(m_ShadowMap3, projCoord3);


shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);

outFragColor = vec4(shadow, shadow, shadow, 1.0);


2011-maj-08 23:44:54 handleError

ALLVARLIG: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadowPSSM15.frag, defines, type=Fragment] error:Fragment shader failed to compile with the following errors:

ERROR: 0:90: error(#201) Requires extension support: textureGather (GL_ARB_gpu_shader5)

ERROR: 0:90: error(#160) Cannot convert from ‘const float’ to ‘highp 4-component vector of float’

ERROR: error(#273) 2 compilation errors. No code generated

same thing here, getting it on win 7 64x - nvidia geforce GT430

@Momoko_Fan, isn’t there a way to check if the texture gather extension is supported? I mean in the shader? (i guess at worst we could check it via Caps and use a define)…

Please take a look at

I used to have similar problem, but it has disappeared after one of the updates to PSSM.

com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadowPSSM15.frag, defines, type=Fragment] error:0(90) : error C1115: unable to find compatible overloaded function "textureGather(sampler2DShadow, vec2, float)"

my error is different thought.

@abies: the line shadowRenderer.setCompareMode(CompareMode.Software); removed the error, thanks. but i guess this is a work around and not a solution to the problem. Oh well, for now this works for me.