Page 1 of 1

Nested Stencils?

Posted: Fri Dec 19, 2014 6:25 pm
by drunken_thor
Hey all I have come upon a hard problem, I am trying to optimize light_world.lua and I have realized that stencils are a good way to go because I have noticed that stencils limit the amount of area that shaders are applied thus speeding up the shader application. However this is a sticking point, I want to mask of the area not touched by the light (a circle mask) and mask off the shadow bodies(inverted stencils). To draw circle mask I need a stencil and the bodies I need an inverted stencil. Is there a way to use one of each or nest them?

Re: Nested Stencils?

Posted: Fri Dec 19, 2014 10:33 pm
by s-ol
drunken_thor wrote:Hey all I have come upon a hard problem, I am trying to optimize light_world.lua and I have realized that stencils are a good way to go because I have noticed that stencils limit the amount of area that shaders are applied thus speeding up the shader application. However this is a sticking point, I want to mask of the area not touched by the light (a circle mask) and mask off the shadow bodies(inverted stencils). To draw circle mask I need a stencil and the bodies I need an inverted stencil. Is there a way to use one of each or nest them?
draw onto a canvas: {255,255,255,255} for "can be drawn to" and {0,0,0,0} for "can't be drawn to"
then set blend mode to multiplicative and draw as usual.

Re: Nested Stencils?

Posted: Sat Dec 20, 2014 12:48 am
by drunken_thor
The problem is that I want to use a stencil as an optimization techique for shaders. That is a very cool technique you described but I need a stencil for a very specific reason in this instance.

Re: Nested Stencils?

Posted: Sat Dec 20, 2014 12:46 pm
by Azhukar
drunken_thor wrote:mask off the shadow bodies
By shadow bodies do you mean the bodies that cast the shadows or the actual shadow darkness?

Re: Nested Stencils?

Posted: Sun Dec 21, 2014 1:22 am
by drunken_thor
Azhukar wrote:
drunken_thor wrote:mask off the shadow bodies
By shadow bodies do you mean the bodies that cast the shadows or the actual shadow darkness?
The actual shadow darkness, for now I have settled to just use a sentcil for the range of the light and integrate the shadow stenciling into the shader being used. Not as optimal as I had hoped but oh well.