I have shadows and reflections code working on ATI cards and now need to extend to support nVidia cards also. But nVidia cards seem to not support ARB_shadow_ambient, and the sample code I have seen uses an extra render pass to get around this. I read somewhere that this is not a problem because it can be done via ARB_texture_env_combine. Can someone show me or point me at an example of this somewhere? Not obvious what to do...
The sample code in OpenGL SuperBible uses an extra render pass when the ambient shadow extension is not available (listing 18.2). When it *is* available (as on ATI cards) then just one line of code is added when setting up the texture state, see the if()... below:
Elsewhere in the sample, there is the code
ambientShadowAvailable is set by testing GL_ARB_shadow_ambient and this is true on ATI cards but not on nVidia cards it seems. Surely it's not necessary to do an extra rendering pass on nVidia cards? I saw a fleeting reference to the use of ARB_texture_env_combine in a post somewhere, and another to ARB_fragment_program_shadow but I can't figure out how to write a simple replacement for the one liner above!
So my question is, can one do something with other GL extensions to replace the COMPARE_FAIL_VALUE line above and still avoid the need for that extra rendering pass in this sample code?
The sample code in OpenGL SuperBible uses an extra render pass when the ambient shadow extension is not available (listing 18.2). When it *is* available (as on ATI cards) then just one line of code is added when setting up the texture state, see the if()... below:
Code:
// Set up some texture state that never changes
glGenTextures(1, &shadowTextureID);
glBindTexture(GL_TEXTURE_2D, ShadowTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
if (ambientShadowAvailable)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.5f);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
RegenerateShadowMap();
Elsewhere in the sample, there is the code
Code:
if (!ambientShadowAvailable) {
...
// Because no support for an "ambient" shadow compare fail value,
// we'll have to draw an ambient pass first
...
DrawModels();
}
ambientShadowAvailable is set by testing GL_ARB_shadow_ambient and this is true on ATI cards but not on nVidia cards it seems. Surely it's not necessary to do an extra rendering pass on nVidia cards? I saw a fleeting reference to the use of ARB_texture_env_combine in a post somewhere, and another to ARB_fragment_program_shadow but I can't figure out how to write a simple replacement for the one liner above!
So my question is, can one do something with other GL extensions to replace the COMPARE_FAIL_VALUE line above and still avoid the need for that extra rendering pass in this sample code?