Jump to content
  • Advertisement
Sign in to follow this  
Toji

GLSL on ATI hardware

This topic is 4813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
}


Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thank you so much everyone! I'll try those out! (float3x3... that's probably it. bleah >_<)

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!