So in order to implement this (referencing
@manu3d 's suggestions and google) :
- Get a set of lensflare artifact textures in a single Texture Atlas file. The number of artifacts is arbitrary.
- Check if any light source is visible in the camera (using OpenGL's occlusion queries) If not occluded by anything, proceed.
- Find the 2D coords of the light source on the screen.
- Using the light source's 2D coords and the center of screen's 2D coords, we have an axis along which to render the lensflare artifacts. We also know the distance between lightSource and center('D').
5. The brightness of each artifact is calculated as being inversely proportional to D.
6. Assuming number of artifacts in atlas = N.
To place any arbitrary number of artifacts along the axis, we first scale the lightToCenter vector down by some amount (say 0.2).
Now starting at the light's position, for each artifact, we keep adding this scaled lightToCenter vector to get the position of the next artifact.
Also, to implement this in Terasology where do I start? I have been trying to understand the DAG based rendering system. These have to be rendered before any GUI stuff. I think the addFinalPostProcessingNodes()
method of the WorldRendererImpl
class might be the place to start.
I would like to know if I'm on the right track. Thanks.