Realistic Lighting: Can it be done in realtime?

Mr. Blue said:
Hmm.. I'll go a step further then. How is the Taylor series approximated on the GPU? Do you have to store the values from an Nth Taylor series in a texture? Or does the GPU integrate by summation? How many passes? Whats the error?
I believe the DX9 specs discuss this for the sin and cos functions. Mainly, you load the coefficients of the Taylor series into constant registers, then compute the terms. Obviously, you'd want to use functions that converge quickly so that you don't spend all your time doing these kinds of calculations.

nAo said:
Is well know that Taylor expansion sucks for trigonometric functions.
There are plenty of other better way to make it
Sure, I was just giving an example :)
 
both the Fresnel and Distribution textures would have to be 3d to get a one-to-one mapping and an accurate specular spread.

I'm assuming that you are using the extinction=0 Fresnel approximation, which depends only on L.H. The Cook-Torrance distribution function is based only on N.H (acos(N.H) = alpha).

Therefore, the F*D texture only needs to be 2D.

To map the textures onto an object, you compute V, L, N, and H in the same 3D space (tangent, view, object, world, etc.), and then compute [ (dp+1)/2 ] to generate each texture coordinate.

I guess on GeForce 3 hardware, these values will probably need to be interpolated per-vertex to get everything running in 1 pass. On 8500, you could probably compute each dot product in the first phase, and then lookup the terms in the second phase. This is a non-issue on next-gen hardware.

Do you have to store the values from an Nth Taylor series in a texture? Or does the GPU integrate by summation? How many passes? Whats the error?

You store the values from an Nth taylor series (typically 4 terms, 8 if necessary) as a constant. Which is similar to storing as a texture. The error depends on the function you're approximating -- for atan, around pi/2, the series converges very slowly. There are better approximations for atan, though, then using an N-term taylor series.
 
Back
Top