Journal Entry 24 – NVIDIA versus ATI

NVIDIA drivers are very different than ATI drivers, and I ran into a few problems when trying to get the voxel engine up and running on modern NVIDIA equipment (versus my home setup, which has an ATI HD GPU). Several new warnings occurred, the first of which was a result of using uniform blocks. NVIDIA requires that the GLSL version be identified as at least 130, which is the first version that supports uniforms.

Upon setting the version information, NVIDIA pushes for all varying/attribute keywords to be removed, as they are deprecated. It would also like the use of gl_FragColor removed. After messing with GLSL for a bit, here are the resulting shaders I am using. First, the vertex shader:

#version 140
uniform Camera {
   mat4 projection_matrix;
   mat4 view_matrix;
uniform mat4 model_matrix;
in vec3 in_position;
in vec3 in_normal;
out vec3 vertex_light_position;
out vec3 vertex_normal;
out vec3 vertex_color;
void main(void)
  vertex_normal = (model_matrix * vec4(in_normal, 0)).xyz;
  vertex_light_position = normalize(vec3(0.5, 0.3, 0.2));
  vertex_color = fract(in_position);
  gl_Position = projection_matrix * view_matrix * model_matrix * vec4(floor(in_position), 1);

and the fragment shader:

#version 140
in vec3 vertex_light_position;
in vec3 vertex_normal;
in vec3 vertex_color;
out vec4 fragment_color;
void main(void)
  float diffuse_value = 2.0 * max(dot(vertex_normal, vertex_light_position), 0.0);
  fragment_color = vec4(vertex_color, 1) * min(1.0, max(0.5, diffuse_value));

One thing that bothers me is that the output (fragment_color) of the fragment shader is not explicitly defined to be the color buffer data. It looks like both ATI and NVIDIA assume that this must be the case, although I suppose you could reassign it in code. I just wanted to get rid of the warnings, so I didn’t delve too deep. I figured it was worth a quick blog post in case anyone ran into an issue like this. Cheers,


Leave a Reply