Subhransu
Subhransu

Reputation: 449

Inner and Outer Glow Implementation using Opengl ES 3.0

I want to implement inner and outer glow for a rendered 3D object. Here the glow is to be applied only on the 3D models who have glow enabled and not for the entire scene.

There is one post in stackoverflow that talks about implementing it using modifying the mesh, which in my opinion is difficult and intensive.

Was wondering if it can be achieved through multi-pass rendering? Something like a bloom effect thats applied to specific objects in the scene and only to the inner and outer boundaries.

Upvotes: 1

Views: 1171

Answers (1)

heinrichj
heinrichj

Reputation: 552

I assume you want the glow only near the object's contours?

I did an outer glow using a multi-pass approach (after all "regular" drawing):

  1. Draw object to texture (cleared to fully transparent) using constant output shader (using glow color as output), marking the stencil buffer in the process. Use EQUAL depth test if you only want a glow around the part where the object is actually visible on screen. Obviously using the depth buffer used to do normal scene drawing.

  2. Separated gaussian blur on this texture.

  3. Blend result to the output buffer for all pixels that do not have the stencil buffer marked in step 1.

For an inner + outer glow, you could do an edge detection on the result of (1), keeping only marked pixels near the boundary, followed by the blur and and an unmasked blend.

You could also try to combine the edge detection and blurring by using a filter that scales its output based on the variance of all samples in its radius. It would be non-separable though...

Upvotes: 1

Related Questions