Strange GLSL trouble

Can someone tell me if it is normal :

i wrote a GLSL shader (Frag & vertex), it is working fine as far as i use a Nvidia card, but it crashed the appli when used on an ati card saying it can't cast int to float.



7 juin 2007 12:08:52 com.jme.scene.state.lwjgl.LWJGLShaderObjectsState checkProgramError
GRAVE: ERROR: 0:66: '-' :  wrong operand types  no operation '-' exists that takes a left-hand operand of type 'const int' and a right operand of type 'uniform float' (or there is no acceptable conversion)
ERROR: 0:66: '>' :  wrong operand types  no operation '>' exists that takes a left-hand operand of type 'float' and a right operand of type 'const int' (or there is no acceptable conversion)
ERROR: 0:68: '-' :  wrong operand types  no operation '-' exists that takes a left-hand operand of type 'const int' and a right operand of type 'uniform float' (or there is no acceptable conversion)
ERROR: 0:68: '>' :  wrong operand types  no operation '>' exists that takes a left-hand operand of type 'float' and a right operand of type 'const int' (or there is no acceptable conversion)
ERROR: 0:91: 'assign' :  cannot convert from 'const int' to 'float'
ERROR: 0:95: '/' :  wrong operand types  no operation '/' exists that takes a left-hand operand of type 'float' and a right operand of type 'const int' (or there is no acceptable conversion)
ERROR: 0:98: '/' :  wrong operand types  no operation '/' exists that takes a left-hand operand of type 'float' and a right operand of type 'const int' (or there is no acceptable conversion)
ERROR: 0:98: '-' :  wrong operand types  no operation '-' exists that takes a left-hand operand of type 'const int' and a right operand of type 'float' (or there is no acceptable conversion)
ERROR: 0:98: 'assign' :  cannot convert from 'const int' to 'float'
ERROR: 9 compilation errors.  No code generated.

GLSL doesn't do autocasting, nVidia probably handles it because their GLSL implementation is based on their Cg implementation. Try adding explicit casts. eg


int i = 2;
float f = float(i);

thx, trying that right now :slight_smile:

There is a tool that has been mentioned in a few other threads that supposedly can check glsl code to see if it is completely compliant.

ATI is more strict about what they do allow and don't allow in GLSL code.



That might solve your problem

problem solved; once again , llama got the answer :wink:

thx all for answering so quickly



edit:

And i'm an arse coz RenderMonkey told me that i did implicit cast that should'nt work on all gpu.

run your shaders through glslvalidate from 3dlabs. http://developer.3dlabs.com/downloads/index.htm

thx for the tip MrCoder :wink: