• Advertisement
Sign in to follow this  
  • entry
    1
  • comment
    1
  • views
    1061

About this blog

It's something!

Entries in this blog

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!!
gallery_200007_694_4093.pngfloat 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.

gallery_200007_694_12930.pngprojectionLen = clamp(projectionLen, -maxlen, maxLen);
gallery_200007_694_7496.png
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.

gallery_200007_694_397506.png

With Attenuation:

gallery_200007_694_106300.png

Detailed textures:
gallery_200007_694_60411.png

And Specular:

gallery_200007_694_268732.png
Sign in to follow this  
  • Advertisement