## Nested Stencils?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Contact:

### Nested Stencils?

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?
Light_world.lua for all your lighting needs
Github

s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

### Re: Nested Stencils?

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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
baby:hurt(me)
end

drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Contact:

### Re: Nested Stencils?

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.
Light_world.lua for all your lighting needs
Github

Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

### Re: Nested Stencils?

By shadow bodies do you mean the bodies that cast the shadows or the actual shadow darkness?

drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Contact:

Azhukar wrote: