Good day.
Since I want to create a custom glow on every character sprite, I thought a shader would do the trick.
After a few tries, I thought nothing was working, only to realize that the shader applies to the whole texture (ex. 64x64 with every tile or character pose or whatever) and not a single quad, or a batch.
No, my question is: is there a way to make it work only on one quad or batch, without applying every time the shader?
[Solved] Shader, but on quad/batch and not whole texture
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[Solved] Shader, but on quad/batch and not whole texture
Last edited by ~Tidal on Tue Aug 25, 2015 7:09 pm, edited 1 time in total.
Re: Shader, but on quad/batch and not whole texture
What do you mean? a Shader always applies to everything that is draw as long as it is set. If you only want to apply it t one quad... then do that?~Tidal wrote:Good day.
Since I want to create a custom glow on every character sprite, I thought a shader would do the trick.
After a few tries, I thought nothing was working, only to realize that the shader applies to the whole texture (ex. 64x64 with every tile or character pose or whatever) and not a single quad, or a batch.
No, my question is: is there a way to make it work only on one quad or batch, without applying every time the shader?
Code: Select all
love.graphics.setShader(myshader)
love.graphics.draw(quad, texture) -- drawn with shader
love.graphics.setShader()
love.graphics.rectangle("fill", 20, 20, 100, 100) -- drawn without shader
Re: Shader, but on quad/batch and not whole texture
It is exactly what I want to do.
But I was trying to do a gradient. Simple stuff. But instead of being applied on the current quad/batch drawn, it is applied to the whole picture.
Visual representation.
Edit: I only want to have the lower part of the said quad of a different color than the top part, so I'm working with texture_coords, which don't apply to the quad, but to the original picture.
But I was trying to do a gradient. Simple stuff. But instead of being applied on the current quad/batch drawn, it is applied to the whole picture.
Visual representation.
Edit: I only want to have the lower part of the said quad of a different color than the top part, so I'm working with texture_coords, which don't apply to the quad, but to the original picture.
Re: Shader, but on quad/batch and not whole texture
Real stupid but have you tried drawing each sprite to a separate canvas and then apply the shader to all the canvases?
Re: Shader, but on quad/batch and not whole texture
isn't that the opposite of what he wants to do? :0Ref wrote:Real stupid but have you tried drawing each sprite to a separate canvas and then apply the shader to all the canvases?
OP, please attach your code so we can see what you are actually doing.
Re: Shader, but on quad/batch and not whole texture
aren't canvas supposed to represent static things? IMHO this wouldn't be ok.Ref wrote:Real stupid but have you tried drawing each sprite to a separate canvas and then apply the shader to all the canvases?
anyway, I guess I've solved it.
Since I can't apply the effect on a single quad but it is applied on the whole texture, I tried to think outside the box: instead of using document boundaries, I used each sprite boundaries: via Texel and 1/Width - 1/Height, I got: each pixel value in terms of texture_coord, and each pixel vauel in terms of color and alpha.
Starting from it, it was simple: the shader will be applied to every pixel above the black outline.
For what I was trying to do it is even better. I think in similar situation, a white grid or something could help you a lot.
Re: Shader, but on quad/batch and not whole texture
Canvases can be used to optimize drawing of static things / things that don't change very often, but might also be required for regular drawing and compositing. Most forms of post-processing require canvas'; for example in my ludum dare entry I apply a black-and-white filter to most of the graphics; this is done by drawing all of those to a canvas, and then drawing the canvas with the postprocessing shader.~Tidal wrote:aren't canvas supposed to represent static things? IMHO this wouldn't be ok.Ref wrote:Real stupid but have you tried drawing each sprite to a separate canvas and then apply the shader to all the canvases?
Re: [Solved] Shader, but on quad/batch and not whole texture
Umh. Thanks.
I don't know, tho. I stopped used canvases for dynamic stuff when I experienced flickering, I was using mouse position to change some text and pictures and I think it wasn't ok. As far as I experienced, canvases don't work very well when you put some of their logic in love.update.
I don't know, tho. I stopped used canvases for dynamic stuff when I experienced flickering, I was using mouse position to change some text and pictures and I think it wasn't ok. As far as I experienced, canvases don't work very well when you put some of their logic in love.update.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: [Solved] Shader, but on quad/batch and not whole texture
They work fine anywhere (on the main love thread), as long as you don't draw a canvas to itself. Sometimes it's easy to accidentally do that if you forget to call love.graphics.setCanvas after you're done drawing to it.~Tidal wrote:As far as I experienced, canvases don't work very well when you put some of their logic in love.update.
Re: [Solved] Shader, but on quad/batch and not whole texture
slime wrote:They work fine anywhere (on the main love thread), as long as you don't draw a canvas to itself. Sometimes it's easy to accidentally do that if you forget to call love.graphics.setCanvas after you're done drawing to it.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests