Nested Stencils?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Nested Stencils?

Post 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?
Light_world.lua for all your lighting needs
Talkies for all dialog needs
Github
twitter
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Nested Stencils?

Post 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.

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
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Nested Stencils?

Post 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.
Light_world.lua for all your lighting needs
Talkies for all dialog needs
Github
twitter
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Nested Stencils?

Post 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?
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Nested Stencils?

Post 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.
Light_world.lua for all your lighting needs
Talkies for all dialog needs
Github
twitter
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 47 guests