Preventing lighting from being drawn on the background
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Preventing lighting from being drawn on the background
How about this solution: Draw the foreground to a canvas, draw this canvas on screen. Then draw the shades, using the foreground canvas as a mask. See the wiki about stencils, at the bottom, there is a section about "Using an Image as a mask".
Check out my blog on gamedev
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Preventing lighting from being drawn on the background
I can't draw the background manually, remember? The background is the default background that comes with love2d, color of which you can modify via love.graphics.setBackgroundColor.Zer0 wrote:[wiki]love.graphics.setStencil[/wiki]Code: Select all
draw_background() love.graphics.setStencil(draw_foreground()) draw_foreground() love.graphics.setStencil()
setStencil says you ONLY draw to where the stencil draws. (the stencil is just a function with stuff that is drawn)
Though I could make my own background.
Re: Preventing lighting from being drawn on the background
Let me fix the code then.Whatthefuck wrote: I can't draw the background manually, remember? The background is the default background that comes with love2d, color of which you can modify via love.graphics.setBackgroundColor.
Though I could make my own background.
Code: Select all
do_not_draw_background()
love.graphics.setStencil(draw_foreground())
draw_foreground()
love.graphics.setStencil()
If you can't fix it, Kill it with fire. ( Preferably before it lays eggs. )
Re: Preventing lighting from being drawn on the background
Using a plain vanilla stencil will only work in restricted cases. If the foreground is made of image with "holes" in it (=transparency) then a stencil will not work. A stencil function always considers the full rectangle of an image.
A solution is given on the wiki-page on stencils (see post above).
A solution is given on the wiki-page on stencils (see post above).
Check out my blog on gamedev
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Preventing lighting from being drawn on the background
Interesting, I actually tried doing what you linked me to prior to making this thread, but it did not work. I guess I did something wrong.micha wrote:Using a plain vanilla stencil will only work in restricted cases. If the foreground is made of image with "holes" in it (=transparency) then a stencil will not work. A stencil function always considers the full rectangle of an image.
A solution is given on the wiki-page on stencils (see post above).
Will try again.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Preventing lighting from being drawn on the background
Guys, I love you, no homo. You helped me achieve exactly what I needed.
You fucking rock.
You fucking rock.
Re: Preventing lighting from being drawn on the background
Could you post a screenshot of the result? I am interested.
Check out my blog on gamedev
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Preventing lighting from being drawn on the background
https://love2d.org/imgmirrur/Ct7Ijsz.pngmicha wrote:Could you post a screenshot of the result? I am interested.
Using [img] tags doesn't even make it fit in here, so have a link instead. :V
Last edited by Whatthefuck on Sat Jul 26, 2014 5:03 pm, edited 1 time in total.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Preventing lighting from being drawn on the background
Sure.Whatthefuck wrote:micha wrote:Could you post a screenshot of the result? I am interested.
https://love2d.org/imgmirrur/Ct7Ijsz.png
Using [img] tags doesn't even make it fit in here, so have a link instead. :V
Edit: oops, double post. D:
Here, have another one that I took while it was raining in-game: https://love2d.org/imgmirrur/J6CY1rx.png
Who is online
Users browsing this forum: Google [Bot] and 7 guests