Jump to content
  • Advertisement
Sign in to follow this  

OpenGL [newbie] - An another OpenGL vs. ATI/Apple question ! - Long

This topic is 3999 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

Hi everyone, At first, I want to say that I understand almost nothing about OpenGL code (!) and that my post here is only to get some possible help about an issue I have using a software currently under development. My computer is a MacBook Pro C2D 2.33 GHz, Video Card ATI X1600 (256 MB RAM). Mac OS X 10.4.10 I am involved in DftD debugging and eventually porting it to Mac OS X, but we do have a big issue with shader rendering. Well, it seems that it is not only an issue with my MBP but more certainly with any ATI video card (PC users are reporting troubles when using ATI video cards). When using the application, it will crash at running time with the following error message :
Caught exception: compiling of shader failed : ./data/shaders/modelrender.vshader
The whole trace is available here The source code of modelrender.vshader has been checked OK using : a) 3DLabs GLSLValidate on a Linux box, via wine, with an nVidia card b) OpenGL Shader Builder on my MBP All validation tools are saying the same. The other guys of the dev team are using nVidea cards and everything is fine on their side. They have checked the following : === setting some flags : __GL_ShaderPortabilityWarnings=1 __GL_WriteInfoLog=1 __GL_WriteProgramObjectAssembly=1 __GL_WriteProgramObjectSource=1 The GLSLValidate tool, as well as NVidia's strictness warnings turned on, showed that the shaders were all ok. Furthermore, the whole application runs fine when compiled with some Linux flavor, mostly Debian-based. The binary package also runs fine on some Dell D600 laptop with xubuntu. Here is the code for modelrender.vshader :

// -*- mode: C; -*-
#version 110

/* input:
   gl_Normal		(tangentz)
   gl_MultiTexCoord0	(texcoord)
   tangentx_righthanded	(tangentx,righthanded-factor)

/* can we give names to default attributes? or do we need to use named
attributes for that?
   how to give named attributes with vertex buffer objects?
   we could assign them to a variable, but would that be efficient? an
unnecessary copy.
   but the shader compiler should be able to optimize that...
   the way should be to use vertex attributes (together with vertex arrays
or VBOs),
   that have a name and use that name here.
   until then, access sources directly or via a special variable.

varying vec2 texcoord;
varying vec3 lightdir, halfangle;
attribute vec4 tangentx_righthanded;

void main()
	// compute tangent space
	// gl_Normal = tangentz
	vec3 tangentx = vec3(tangentx_righthanded);
	vec3 tangenty = cross(gl_Normal, tangentx) * tangentx_righthanded.w;

	// compute direction to light in object space (L)
	// light.position.w is 0 or 1, 0 for directional light, 1 for point light
	vec3 lightpos_obj = vec3(gl_ModelViewMatrixInverse *
	vec3 lightdir_obj = normalize(lightpos_obj - vec3(gl_Vertex) *

	// direction to viewer (E)
	// compute direction to viewer (E) in object space (mvinv*(0,0,0,1) -
	vec3 viewerdir_obj = normalize(vec3(gl_ModelViewMatrixInverse[3]) -

	// compute halfangle vector (H = ||L+E||)
	vec3 halfangle_obj = normalize(viewerdir_obj + lightdir_obj);

	// transform light direction to tangent space
	lightdir.x = dot(tangentx, lightdir_obj);
	lightdir.y = dot(tangenty, lightdir_obj);
	lightdir.z = dot(gl_Normal /*tangentz*/, lightdir_obj);

	halfangle.x = dot(tangentx, halfangle_obj);
	halfangle.y = dot(tangenty, halfangle_obj);
	halfangle.z = dot(gl_Normal /*tangentz*/, halfangle_obj);

	// compute texture coordinates
	texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;

	// finally compute position
	gl_Position = ftransform();

	// set fog coordinate
	gl_FogFragCoord = gl_Position.z;

We have tried to specify the components of vec4 types, before storing them in vec3. (vec4 = vector, of 4 floats and vec3 = vector, of 3 floats) With nVidia, it is possible to code, for example :
vec3 text = vec3(gl_Vertex);

With ATI, it seems that we have to say :
vec3 variable = gl_Vertex.xyz;

That's what we did in tangentx_righthanded; it was uniform vec4 type. And we coded :
vec3 tangentx = tangentx_righthanded.xyz; 

to avoid the aliasing problem. But I still have the crash at run time. So we think we can remove type aliasing from the list of problems. The dev leader said that we need vertex attributes to work like GLSL defines them or it takes us intolerable time to change it. So we definitely think that the problem is on ATI side but we have absolutely no clue and fwiw I would really like to fix that problem, not only for myself but eventually for all ATI users (PC and/or Mac), if possible... Any idea of what the problem may be and how it may be fixed ? As I have said, I am not at all OpenGL fluent, so please be kind with me ;) Thanks. Claude

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!