Appling Lens Flare effect

I found a GLSL shader on that makes that effect, but it is a 2D, not a 3D world.
So in my opinion implementing such a thing is super cool (not sure if it is possible).

Here is the shader link:

So can anyone teach me exactly what I should do to make it work on a 3d scene?
I would like to make it possible just by passing the light position to the shader.

There is no need to redo this in 3D. You can convert object coordinates to screen coordinates and then pass them to the shader.


Thank you so much for your time.

Well, please bare with my lack of experience (2-weeks for now), so what I need to do is:

  1. I need to use a separate buffer to render that shader into a 2d plane which represents the screen view.
  2. Translate the light object position from 3d into 2d so the shader does the correct calculation.
  3. get that buffer and display it on the screen somehow.

in that steps I can see both my 3d world and the effect, am not sure if I am right?, if so is there any tutorial that can teach me how to do these steps, or even better if there is already code that does that?

You will find the answer to these questions if you study the example that is located in the samples folder, namely render-to-texture

As for the second question, I remember on the forum that there were answers.

@Pythonic_Person So that you don’t go astray, you can take a look at this.

1 Like

No need to do render-to-texture for this effect.

Just apply it to a fullscreen quad on render2d with transparency (or with “additive” mode blending) so you can still see the underlying scene.

Pass in the position of the light source translated to 2D as a shader input if you need.

This video tutorial explains how to convert shadertoy shaders for Panda3D:

If you wish to have the effect “obscured” by other objects, then you could perhaps apply the effect to a plane in the 3D scene that tracks the distance to the light source. Or you could render a “mask” that indicates where the light will be visible as part of the main scene, which you incorporate into the post-shader. That does require render-to-texture (FilterManager could help).

1 Like