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.
Hey there. Not that I'm really qualified to give you a certain answer here but I expect a lens flare node is not GSOC scope on its own, although a rendering-related GSOC item is quite possible, and could probably contain one or more nodes in it. Both on a technical level a single node is probably a bit underwhelming for three months of work, as well as a project prioritization level - would it really help move the project forward substantially to be able to show lens flares thanks to three months of effort, even if they're really cool?
Hop on chat to find one of us sometime for a Slack invite, as the #rendering channel there is probably the best place to ask for further details
In response to your question, you are on the right track in regard to WorldRenderer/WorldRendererImpl being the right place where to start, and in particular the nodes added in addFinalPostProcessingNodes(). Notice that LensFlares should likely go before tone mapping and potentially other nodes, I don't have the chance to check right now.