Jump to content
Sign in to follow this  
  • entry
    1
  • comment
    1
  • views
    1161

Sleep time ideas. Per-Pixel Fluorescent?

Sign in to follow this  
FreOzgur

782 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!!
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  


1 Comment


Recommended Comments

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!