Jump to content

  • Log In with Google      Sign In   
  • Create Account






Sleep time ideas. Per-Pixel Fluorescent?

Posted by OzgurEra, 28 September 2013 · 392 views

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.

Results??

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




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.

Recent Entries

Recent Comments

PARTNERS