View Full Version : A String of specular lights
Hawkwind
02-01-2008, 04:54 AM
I've modelled a strip light as a series of light points to get a long specular on
a surface. However, since these lights are equally spaced, I'm wondering if
there's a faster way to get the total effect at a pixel than calculating each
(N.H)^p term and summing them, rather than using the log and exp approach for every light individually...
log r3, r2.x // r2.x = dot(N,H)
mul r3, cSPECULAR_POWER.x, r3.x //
exp r6, r3.x
Interesting question.
As far as I know it's not possible to simplify the sum of powers unfortunately. However, the series of 2^x is sum(ln(x)^n * x^n, n = 0..inf) and the integral of x^n is x^(n+1) / (n+1). So maybe it's possible to compute specular for an area light. This might have been done before, and intuition tells me it should be possible to do this by altering the vector between the light source center and the surface point you're lighting, depending on your position, so the angle doesn't change so quickly...
Anyway, I see you're using a log/mul/exp sequence to compute the power. Note that some GPU's might have a single cycle pow operation. Of course the driver's shader compiler could detect this, but I still think it's better to use pow if you need a power operation.
Might be worth a read:
Shading with Curve Light Sources (http://www.blackwell-synergy.com/doi/pdf/10.1111/1467-8659.1430217)
A Shading Model of Parallel Cylindrical Light Sources (http://citeseer.ist.psu.edu/429285.html)
Hawkwind
02-04-2008, 06:08 AM
Interesting.. I'll check these out if I can't get anywhere with it myself ( which is always a more satisfying solution). At the moment I'm looking at
using a polynomial differencing approach to the terms in a power series...
particularly since I can consider the string-of-lights as equally spaced. The
idea being to difference a power expansion of the (N.H0)^p term and an expansion of ( N.H1)^p, where H1 = f(H0) for each halfvector. If I can
express f in terms of the direction of the string of lights then I suspect that
expanding the power series to a few terms may give a result which is usable.
kenpex
02-08-2008, 11:35 PM
Integrate the lighting equation along the line. It's more than possible, it's what you should do to simulate a linear light... If you don't want to do the maths, mhm, try with Mathematica...
http://c0de517e.blogspot.com
Hawkwind
02-09-2008, 04:56 PM
Ok, thanks for all the info. Not had time to do any more on this yet - hopefully I'll get to follow this up in the next few days.
Cheers
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.