Jump to content

Recent Entries

Recent Comments

- - - - -

Sleep time ideas. Per-Pixel Fluorescent?

4: Adsense

Per-Pixel Fluorescent Light

This was just a sleep time idea. I have never seen or never noticed a real-time, per-pixel fluorescent lamps.
Most of games just uses point lights under this kind of lamps.

Actually the idea is pretty simple. Our fluorescent lamp is represented as a direction and a length.
And the math is much more simple. Just find the nearest distance between a point and a line. (line is our fluorescent lamps direction).

Actually it is just a simple projection using a Dot Product.
Project the point on the fluorescent line.

Black Dot: Fluorescent middle point (LightPos)
Green: Fluorescent direction with length (lightDirection and maxLen)
Red: Projected length (projectionLen)
Blue: Projected point (actualLightPos)
Yellow: Pixel Position (PixelPos)

lightDirection must be normalized!!
Posted Image
float projectionLen = dot(PixelPos.xyz - LightPos, lightDirection);
But our Fluorescent direction is not a line but a line segment. So if our projection is out of the maximum length, we should limit it.

Posted Image
projectionLen = clamp(projectionLen, -maxlen, maxLen);
Posted Image
maxLen is our length from middle to ends. If our total length is 4 units, then maxLen is 2.
Now we know the length of the light position from the center of fluorescent.
Calculating the actual position is not that hard.
vec3 actualLightPos = LightPos + (lightDirection * projectionLen);
Just multiply our projectionLen with the light direction, than add it to the fluorescent light Position.
Now we calculated the desired light position. From now on, everything is same as a point light.


Here are few screenshots with simple artwork and a much more detailed one.

Posted Image

With Attenuation:

Posted Image

Detailed textures:
Posted Image

And Specular:

Posted Image

Sep 30 2013 12:15 AM

But how are you going to make it work for semi-shadowing? I had a similar idea but had to drop it since I couldn't figure out that.

Note: GameDev.net moderates comments.