GLSL on ATI hardware

Started by
6 comments, last by MARS_999 18 years, 7 months ago
I have a simple shader-based program I'm working on lately, and I've run into a major frustration. While the shader stuff all works fine on the nVidia hardware I've tried it on, my friend can't get it to work on any of his ATI hardware. Yes, he has the latest drivers and all, and yes, I know it's the shader due to a bunch of logging stuff I've been doing. I just can't figure out what's in the shader that ATI doesn't like. Any suggestions? Thanks!


//VERTEX SHADER

varying vec3 lightDir;

attribute vec3 aQTan, aQBitan;
	
void main()
{
	lightDir = normalize(gl_LightSource[0].position);
	
	mat3 TBNMatrix = float3x3(aQTan, aQBitan, gl_Normal);
	lightDir = TBNMatrix * lightDir;
	
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	gl_TexCoord[0] = gl_MultiTexCoord0;
}

// FRAGMENT SHADER

varying vec3 lightDir;
uniform sampler2D diffuse, norm;
	
void main()
{
	lightDir = normalize(lightDir);
	
	vec3 normal = normalize(2.0 * (texture2D(norm, gl_TexCoord[0].st).rgb - 0.5));
	
	vec4 vColor = texture2D(diffuse, gl_TexCoord[0].st);
	
	gl_FragColor = vec4(gl_LightSource[0].diffuse.rgb * vColor.rgb * max(dot(lightDir,normal),0.0), vColor.a);
}


// The user formerly known as Tojiro67445, formerly known as Toji [smile]
Advertisement
Quote:mat3 TBNMatrix = float3x3(aQTan, aQBitan, gl_Normal);
I don't think float3x3 is a valid type in GLSL. Check out the GLSL Spec for more info.

Another case of the NVidia GLSL compiler not being standards compliant by default (if that is the problem).
no idea but ild guess this here
float3x3(aQTan, aQBitan, gl_Normal)

float3x3 is a function of some sort
ATI cards tend to comply strictly with the GLSL specs (which are, IMHO, somewhat badly designed) while NVIDIA just uses their CG compiler (cgc) to parse GLSL. Thus if you're developing on an NVIDIA card, you have to be very careful that you're using strict GLSL syntax and not CG/HLSL stuff that might pass through unnoticed with cgc.
You'll want to get hold of the various parsing and testing tools that 3DLabs has made avaible for you;

Downloads here.
Personally, I use the validator to check my syntax is sane on my shaders [smile]
Thank you so much everyone! I'll try those out! (float3x3... that's probably it. bleah >_<)
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
mat3 TBNMatrix = mat3(aQTan, aQBitan, gl_Normal);

or to be safe...which I don't think you need to be:

mat3 TBNMatrix = mat3(aQTan.xyz, aQBitan.xyz, gl_Normal.xyz);
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
float 3x3 float 4x4 these are all HLSL types. I have found that their are some differences between the two that might get you. e.g. Where your calculations are done at, such as eye space, world space, ect...

This topic is closed to new replies.

Advertisement