Per-Pixel Lighting with no Register Combiners.

I don’t know if I’m stupid, blind or what, but I have been searching about 10 OpenGL forums + Google and Yahoo for information about implementing per-pixel lighting with attenuation using cubemaps and 1D+2D textures without using Nvidia’s Register Combiners. I have Dot3 bumpmapping implemented and per pixel lighting with attenuation from a 3D texture but that’s now good since it doesn’t work on most of the cards. The question is, is it posible to do everything that’s done in http://www.ronfrazier.net/apparition/research/per_pixel_lighting.html just using ARB extensions? If so, is there any paper(and some code if possible) to implement that?

Thanks.

Try this. The answer is in the end of the thread.

http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008206.html

Thanks for the link to that post, I will be giving it a try once I finish some contract work I have to do. Thanks again.

I’m not able to get my application to work, everything seems to be right but when I add one line from the code of the other post, the program crashes. Here I leave the code that I use to setup everything.

glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture (GL_TEXTURE_2D, id_bump);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

// Enable and bind base texture
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture (GL_TEXTURE_2D, id_base);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);

glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

// Enable and bind 1D attenuation map into texture unit 1
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, id_light1D);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE0_ARB);

//**************************************************************
// If I comment this line, the application works but the there is no proper lighting
//**************************************************************
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE1_ARB);

// Enable and bind 2D attenuation map into texture unit 0
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id_light2D);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_ONE_MINUS_SRC_COLOR);

After all this I start drawing. But as you see in the code if I have one line that makes the program crash, and if I comment that line I get no proper lighting.

It looks like you are trying to source tex unit 1 on tex unit 0.

Don`t do that.

Originally posted by V-man:
[b]It looks like you are trying to source tex unit 1 on tex unit 0.

Don`t do that.[/b]

Why ? The ARB_texture_env_crossbar extension does allow that.
From the issues section of the specification at http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_crossbar.txt :

Issues

  1. Should only “upstream” textures be allowed as inputs to a
    given texture unit? (Texture inputs to unit <m> are restricted to
    the range TEXTURE0_ARB to TEXTURE<m>_ARB).
- RESOLVED: No. Most vendors support this functionality.

Anyway, it should never crash. What’s your graphics card / OS / driver combo ?

Originally posted by V-man:
[b]It looks like you are trying to source tex unit 1 on tex unit 0.

Don`t do that.[/b]

That made the demo not crash but on the other side what vincoof said its true, I shouldn’t have to do that. Thanks.

Originally posted by vincoof:

Anyway, it should never crash. What’s your graphics card / OS / driver combo ?

Now that you say that I bet my life that it is a driver’s issue. Anyway I’m using a Radeon 9700 Pro, Windows XP, and the Catalysts 3.6. I hope to get new drivers from ATI’s dev relations department soon.

The program is meaningless at first two stages. AFAIK texture_env_combine is an extension for “cascade” OpenGL scheme of multitexturing, which implies that each subsequent stage uses result of the previous one. If it doesn’t, all preceding computations are lost.