I'm trying to do this for my platformer game: http://assets.sbnation.com/assets/17402 ... n07_WP.jpg
I've already implemented a function (from one of the setStencilTest examples in the wiki) that uses a stencil map to draw a circle around the player when he's touching any tile in a certain layer in a tiled map (tmx).
My question would be: is it possible to have the circle perimeter blurred as in the picture above?
Is it possible to apply a mask to a tiledmap with LÖVE?
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
You can try combining the stencil function and a mesh that blurs its edges: https://love2d.org/wiki/love.graphics.newMesh
Or have a stencil of a premade circle image with a blur.
Or have a stencil of a premade circle image with a blur.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
a stencil won't do as it either discards or uses a pixel, but doesn't blend, so it can't blur. OP needs a shader. For example there is one in the o-ten-one splashscreen but it is rather entangled with the other (LIGHTEN) shader code.Davidobot wrote:You can try combining the stencil function and a mesh that blurs its edges: https://love2d.org/wiki/love.graphics.newMesh
Or have a stencil of a premade circle image with a blur.
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
Cool! Yes, I thought a stencil wouldn't blend, but I wanted to confirm. Thank you very much
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
I'm coming back to this, as I'm not very happy with the current result. Besides the stencil, I'm drawing a dark circle around the character, but the effect, as you can see in the attached 2.png, is not very good.
I was wondering if I could use blending modes to achieve what I want, that is, the dark circle only darkening any tile behind it, and not ay pixel behind it (I don't want the scrolls to darken too).
Any hint is appreciated
I was wondering if I could use blending modes to achieve what I want, that is, the dark circle only darkening any tile behind it, and not ay pixel behind it (I don't want the scrolls to darken too).
Any hint is appreciated
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
Use a shader or blendmode that makes the circle not show up on pixels where the destination alpha value is 0, then either make the background have 0 alpha via a shader, by actually lowering the PNG alpha to zero or by drawing everything but the background to a canvas (which is transparent to begin with) and afterwards drawing that canvas on top of the background.molul wrote:I'm coming back to this, as I'm not very happy with the current result. Besides the stencil, I'm drawing a dark circle around the character, but the effect, as you can see in the attached 2.png, is not very good.
I was wondering if I could use blending modes to achieve what I want, that is, the dark circle only darkening any tile behind it, and not ay pixel behind it (I don't want the scrolls to darken too).
Any hint is appreciated
EDIT: I can't find a blendmode that does that, so you'll need a super simple pixel/fragment shader.
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
Thanks for the info! I guessed it wouldn't be easy, but fortunately I found a way that more or less does what I wanted:
-If I'm going to draw the tiledmap layer that covers the secret areas (called "secrets"), I enable a stencil circle. This will eras any pixel from that layer that is inside the circle. When I finish drawing that layer, I disable this stencil.
-After drawing the layer, I enable another stencil circle. This time it's made so only pixels inside the circle are drawn.
-Then, I draw dark squares (with alpha = 100) whenever I find a tile in "secrets" layer. Finally, I disable the second stencil circle.
This way I'm able to achieve the same effect Mario had (except for the blurred edge, which would need a shader). For it to work, I have to make sure that when I enter a secret area in the map, I have put enought tiles on top, right, bottom and left edges of the area so the circle doesn't get cut when the character is close to a wall, ceiling or ground tile. It's not perfect, but I can live with that for now.
It would be very cool that a stencil was able to darken or lighten (or even change the alpha) of the pixels it's working on, instead of just allowing to draw them or not. Would this feature request make sense? If so, I'd gladly raise a ticket in the issue tracker.
-If I'm going to draw the tiledmap layer that covers the secret areas (called "secrets"), I enable a stencil circle. This will eras any pixel from that layer that is inside the circle. When I finish drawing that layer, I disable this stencil.
-After drawing the layer, I enable another stencil circle. This time it's made so only pixels inside the circle are drawn.
-Then, I draw dark squares (with alpha = 100) whenever I find a tile in "secrets" layer. Finally, I disable the second stencil circle.
This way I'm able to achieve the same effect Mario had (except for the blurred edge, which would need a shader). For it to work, I have to make sure that when I enter a secret area in the map, I have put enought tiles on top, right, bottom and left edges of the area so the circle doesn't get cut when the character is close to a wall, ceiling or ground tile. It's not perfect, but I can live with that for now.
It would be very cool that a stencil was able to darken or lighten (or even change the alpha) of the pixels it's working on, instead of just allowing to draw them or not. Would this feature request make sense? If so, I'd gladly raise a ticket in the issue tracker.
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
Stencils are an old OpenGl hardware supported feature. In 0.10 with setStencilTest() we now have access to the complete capabilities of the Stencil Buffer; all it can do is discard or keep a pixel based on one comparison with the previous value in the stencil buffer, that's it. Here's the OpenGL documentation for the Stencil buffer: https://www.opengl.org/wiki/Stencil_TestIt would be very cool that a stencil was able to darken or lighten (or even change the alpha) of the pixels it's working on, instead of just allowing to draw them or not. Would this feature request make sense? If so, I'd gladly raise a ticket in the issue tracker.
As you can see there's no way such a feature could be added without emulating it via shaders etc. which wouldn't make sense to be in the LÖVE api.
Re: Is it possible to apply a mask to a tiledmap with LÖVE?
I see. Thanks for the explanation
Who is online
Users browsing this forum: Ahrefs [Bot] and 6 guests