PDA

View Full Version : PerPixel Lighting



WM
03-02-2002, 09:51 AM
How to make perpixel lighting using COMBINE texture env, not NVIDIA register combiners?
Is there any good tutor?
Thanks.

zeckensack
03-02-2002, 10:44 AM
You can't. At least not with extensions supported on contemporary consumer hardware.

You'll need fragment shaders for that. <- called pixel shaders in Direct3D lingo

Gorg
03-02-2002, 11:10 AM
Originally posted by WM:
How to make perpixel lighting using COMBINE texture env, not NVIDIA register combiners?
Is there any good tutor?
Thanks.



Using the DOT3 extenstion, you can do per-pixel lighting.


[This message has been edited by Gorg (edited 03-02-2002).]

zed
03-02-2002, 11:17 AM
as gorg saiz plain old dot3 (part of opengl1.3) is good enuf
theres no need for register combiners (though perhaps register combiners will give u a nicer finished product they are not necessary at all)

davepermen
03-03-2002, 01:39 AM
for simple diffuse and ambient perpixel lighting you can use the dot3-ext, yes.. if you want more, you need register-combiners, possibly even texture-shaders, or simply the fragment-shaders from ati (wich are the best anyways http://www.opengl.org/discussion_boards/ubb/wink.gif)

here, for some register-combiners-features: http://tyrannen.starcraft3d.net/PerPixelLighting

davepermen
03-03-2002, 01:45 AM
btw, if you want perpixellighting WITHOUT bumpmapping, you can even get it to work without the dot3-ext.. just use tangent-space lighting and you get the dot3 of the point_to_light vector and the surface normal (0,0,1) very simple: use simply the z-component of the light..

jwatte
03-03-2002, 07:13 AM
daveperman,

You can't do tangent space lighting without extensions, though, can you? I mean, apart from calculating it yourself...

PH
03-03-2002, 07:22 AM
I've done some per-pixel Blinn-style specular lighting without using extensions ( bump mapping is of cause not possible ). I have some screenshots on my site ( also, I explained how it worked somewhere on the board ).

PH
03-03-2002, 07:30 AM
Here it is,
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/004436.html

Gorg
03-03-2002, 07:34 AM
Originally posted by PH:
I've done some per-pixel Blinn-style specular lighting without using extensions ( bump mapping is of cause not possible ). I have some screenshots on my site ( also, I explained how it worked somewhere on the board ).

Cass has shown that you can do per-pixel lighting with an unextended opengl 2 years ago.
http://www.opengl.org/developers/code/features/oimfinal/perpixel.html


[This message has been edited by Gorg (edited 03-03-2002).]

PH
03-03-2002, 07:36 AM
I guess you're refering to OIM ? Yes, I've read that but that requires 12 passes ( last time I looked ). I simply use a 2D lookup table with spherical coordinates.

davepermen
03-03-2002, 07:38 AM
jwatte:
first: its permen, not perman http://www.opengl.org/discussion_boards/ubb/wink.gif (how often did i now had to write that? i dunno..)

ok.. yes you're right, you can't do it in hardware without using extensions for vertex programs/vertex shaders..

but doing it in software is no big thing.. for every vertex {
calculate point_to_light
transform trough tangentspace-matrix of the vertex
set as texcoord for normalization-cubemap OR normalize and set to glColor (wrong but for small triangles working.. used this in my demo http://tyrannen.starcraft3d.net/PerPixelLighting )
}

i did not used any hardware-extensions except register-combiners (and for opengl1.1, cubemaps..,oh and VAR of course to speed up, but thats secondary.. http://www.opengl.org/discussion_boards/ubb/smile.gif)

you can do it without tangentspace (without bumpmapping) if you have the dot3-ext.. then you can simply give per vertex the point_to_light and the normal into yetanother normalization-cubemap and dot3 in the texenv.
all you have to do for this is one: binding the normal-array as texcoods for the normalmap, and setting up a nice texmatrix and bind the vertex-pos in the other for the point_to_light map..

it was my first perpixellighting-demo at all.. no vertexprograms even planned then http://www.opengl.org/discussion_boards/ubb/smile.gif