PDA

View Full Version : Per-pixel lighting with Raedon



N64Marin
07-11-2004, 10:08 PM
I've searched the Internet about the algorithm of Per-pixel lighting with ambient, diffuse, specular and self-shadow effects. The recent ones use fragment programs. But on Geforce 256 and Geforce 2, although fragment program is not supported, register combiners can do it. The ATI cards like Raedon 7500 support neither fragment program nor register combiners. I tried to use GL_ARB_texture_env_combine, GL_ARB_texture_env_dot3. But it seems that you can only implement diffuse lighting only. Can we add specular and self shadow on these cards?

Jens Scheddin
07-12-2004, 04:41 AM
It's possible, but not practible. You would need too many passes generally. I think the tenebrae 1 engine implemented this. You might look at their code for example. For getting a high exponent you have to render a lot multipass, IIRC. On the R300 class of hardware (8500, 8600, ...) you can use the more flexible fragment_shader_ATI extension, which will give you even higher quality than specular on GeForce3/4 cards.

Stephen_H
07-12-2004, 08:55 AM
You could try encoding your specular (n dot h)^k function into a texture, with n dot h one axis and the specular exponent 'k' along the other axis... then its just a simple texture lookup.

zeckensack
07-12-2004, 05:58 PM
Have a look at ATI_texture_env_combine3 (http://oss.sgi.com/projects/ogl-sample/registry/ATI/texture_env_combine3.txt) for some increased flexibility. The Radeon supports crossbar, too, if that's any help.

castano
07-12-2004, 05:58 PM
Originally posted by Stephen_H:
You could try encoding your specular (n dot h)^k function into a texture, with n dot h one axis and the specular exponent 'k' along the other axis... then its just a simple texture lookup.That won't work. He wants perpixel lighting, and you cannot do a dependant read on R100 hardware.

You can implement a function like this one:

(((nĚh)*color - bias*color)*scale)^2

using GL_COMBINE_EXT and the following combine modes:
GL_MODULATE_DOT3
GL_MODULATE_SUBTRACT_ATIX
GL_MODULATE

with scale=4 and bias=0.75, you will get a decent aproximation of (nĚh)^16.