Jump to content

  • Log In with Google      Sign In   
  • Create Account

EraEngine



Sleep time ideas. Per-Pixel Fluorescent?

Posted by , 28 September 2013 - - - - - - · 549 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:
http://uploads.gamedev5.net/gallery/album_694/gallery_200007_694_60411.png

And Specular:

http://uploads.gamedev5.net/gallery/album_694/gallery_200007_694_268732.png





Recent Entries

Recent Comments



PARTNERS