Lens Flare 2D Filter

Umm, I don’t know. I’m no GLSL guru, so…

@adriansnetlis: I had the same error in ezio 2D filter but when I removed #version 120 at the top of the shader it worked for me. The result is not exactly the same as in your filter but it’s fun and it seems to work on most of machines. So maybe you could add this file in your first post if it works for you (and for most of hardwares)

fixing the code might be a better idea, if you want to increase compatibility.

Just remove 1 and 2 from noise1 and noise2 functions.
EDIT: It’s so beautiful :smiley:

Attachments


I renamed the noise functions to noiz, otherwise there was a problem, because built-in functions are using the same names. The noise2 function in the code, wont give much effect, so unless anyone finds something better, i think it’s unecessary. But try adding timer to the noiz1. This animates the rays in a cool way.


float noiz1( float n )
{
    return fract(sin(n+timer/2.0));
}

Does anyone else see another sun in the opposite direction?

I don’t.
By the way - when you see some problems or something, always post console output. In 95% of cases it tells the answer.

Ok. There’s no errors, It’s just weird how much the results may differ.

I saw this, too. Very strange.

OK! Now I see it aswell. Must disable the lensflare filter when the sun is in the range behind camera. Must not be hard to detect.

Why disable it! Dont you want to live a in a binary star system. :smiley:

:smiley: Sounds cool - no night at all:D

It works for me. It is a very good lens flare. I started with ThaTimst3r’s lens flare but that one doesn’t work that well. This one is beautiful. Thanks adriansnetlis!:slight_smile:

How do you remove that second sun? I’m quite new to the BGE and Python so I didn’t manage to do it.:smiley: I tried with the radar sensor but that didn’t work.

I think this check has to be made in GLSL shader. Python code just passes on the necessary values.

Here’s what I do to hide the “second sun”


if camera.sphereInsideFrustum(sun.worldPosition, 15) != camera.OUTSIDE:
    owner["sundirect"] = 1.0
else:
    owner["sundirect"] = 0.0

15 is the sphere radius. Change it to fit your needs.

@TwiisterGE - Put that on the end of the sunposition script? I can’t seem to get it working. Sorry, could you be more specific on your code? I’m really new to python also. Thanks!

Yes, at the end of sunScreenPos.py You might want to change that code to:

if cam.sphereInsideFrustum(sun.worldPosition, 15) != cam.OUTSIDE:
        own["sundirect"] = 1.0
    
    else:
        own["sundirect"] = 0.0

I’ve change owner and camera to own and cam. If you find any errors in your script go to the system console: Window --> Toggle system console

How did you make that sky world color? Like when the color gradually lighten’s up towards the horizon. In other blend files the world color is the same color everywhere.

Thanks Nemescraft, got it working with part of that code.