1
\$\begingroup\$

I could like to create a really simple light engine that does not eat to much CPU and will produce this effect:

enter image description here

I am using libgdx for my game with box 2D light (which is too heavy for my needs). I have no idea of what is the best solution to create this effect (shapeRenderer? pure shader?). For the moment I don't need any shadow casting, but I would like to be able to maintain multiple light sources and to add color to the light.

\$\endgroup\$
  • \$\begingroup\$ Usually in theese situations you create a light map (a render target) that you fill with a default color (such as your ambient light) and then you render on it your lights. then when you render the sprites you multiply in the shader the color given by the texture by the color of the lights' render target, bound to the shader as a texture. This is just a comment and not an answer because actually I don't know how libgdx works, only DirectX \$\endgroup\$ – Liuka Dec 17 '16 at 11:19
  • \$\begingroup\$ See also this similar question - in general, techniques used for fog of war will also be useful for this type of lighting effect. Just note that getting two overlapping bright areas to combine correctly may require rendering to an off-screen buffer first, before compositing the result over your scene. \$\endgroup\$ – DMGregory Dec 18 '16 at 17:13
0
\$\begingroup\$

I have finally opted for the following solution:

1 - creating a frame buffer and drawing some full opacity circle on top of it

enter image description here

2 - rendering this frame buffer using this opengl blend function on the scene

GL20.GL_SRC_COLOR, GL20.GL_ZERO

this function will substract occlusion mask opacity from the destination opacity

enter image description here

I know it is not a cartoon render here, but the exact same technique can be applied without the gradient to achieve a more cartoonish look

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.