Combine inverted stencil and normal stencil

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
SCARD
Prole
Posts: 45
Joined: Tue Sep 04, 2012 12:44 pm

Combine inverted stencil and normal stencil

Post by SCARD »

Hi guys!

I'm trying to implement a lighting engine that can draw shadows and reflections of polygons. This is how it basically works:

1. render the scene unlit into canvas
2. render the unlit canvas into the backbuffer with an ambient color
3. for each lightsource the unlit scene is rendered additive on top of the backbuffer with an inverted stencil that draws shadow polygons of some shadowcasters (convex polygons)

until now everything works quite well but here comes my problem:

4. each lightsource casts reflections on some sides of the convex polygons. these are rendered by drawing the unlit canvas with a stencil that draws the reflection polygon.

this also works quite well but if i want to draw the shadows of those reflections i would need an inverted stencil that again draws the shadow polygons for the reflections. If you first active the normal stencil and than activate the inverted stencil only the inverted stencil is active.

Is there a way to combine the two stencils or do i have to rethink my relfection rendering?
Attachments
Test scene with one light source. Reflections dont cast shadows :(
Test scene with one light source. Reflections dont cast shadows :(
2014-05-18-191300_1366x768_scrot.png (661.84 KiB) Viewed 1496 times
Post Reply

Who is online

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