GLSL: ATI vs NVIDIA – Part…

While I was releasing the Julia’s Fractal demo, I tested it on NVIDIA and ATI (as usual before releasing a demo). And as usual, a new difference appeared in the way the GLSL is supported on ATI and on NVIDIA. On NVIDIA the following is line is ok but produces an error on ATI (Catalyst 8.1):

gl_FragColor = texture1D(tex, (float)(i == max_i ? 0 : i) / 100);			

To be ATI Radeon-compliant, this instruction must be split in two:

if( i == max_i )
{
	gl_FragColor = texture1D(tex, 0.0);			
}
else
{
	gl_FragColor = texture1D(tex, i/100.0);			
}

I can’t immagine a world with more than two major graphics cards manufacturers. But if such a world exists, I stop 3d programming… Fortunately, NVIDIA accepts ATI GLSL syntax so there is only one code at the end. Conlusion: always check your GLSL shaders on ATI and NVIDIA before releasing a demo…

One thought on “GLSL: ATI vs NVIDIA – Part…”

  1. BlindSide

    I know you’re only showing this as an example but I think that:

    float Coord = 0.0;

    if(i != max_i)
    Coord = i / 100.0;

    gl_FragColor = texture1D(tex, Coord);

    Is a much better idea. One less if instruction and one less texture read instruction should make for a faster shader on older cards without dynamic flow control. (Although there will probably be no difference on NVidia 6 series +).

    Cheers

Leave a Comment

Your email address will not be published. Required fields are marked *