[Solved] Looking for a ready-to-paint canvas using a shader
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
[Solved] Looking for a ready-to-paint canvas using a shader
Hi guys, I want to change some things in Süsse and one of them is to change the "fake" table-based canvas for a real canvas, I think I may be able to figure it out but I wanted to ask here first to see if somebody did something like this before, I mean, a transparent canvas that can be painted with different colors using a shader and sending the mouse coordinates.
Last edited by alberto_lara on Mon Mar 06, 2017 8:55 pm, edited 1 time in total.
Re: Looking for a ready-to-paint canvas using a shader
That's not quite how it works. The shader part is a substitute for sprite brush, not for painting itself. To paint onto canvas you simply set it as render target and, well, render. Everything will go into that canvas. Just don't clear it and it will retain all contents.
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Looking for a ready-to-paint canvas using a shader
I actually did this once but I lost that code, the main reason I did it was because of performance reasons, and I liked what I saw. The only thing which I wasn't able to implement was to erase (make transparent) a part of the canvas. I guess I'll try again, I'll post the result here later so you can see what I meant.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Looking for a ready-to-paint canvas using a shader
Well you can use a shader... And discard the pixels that you don't want to render, basically your shader should take the canvas, and the mouse coordinates and discard say everything in a radius of 3px and draw everything else, you render the result from the shader to the same canvas and overwrite what was there.
Alternatively you could create a second canvas, create an inverted stencil, so that it renders everywhere where the mouse isn't. Then render your canvas on this second canvas, and swap them (the second canvas becomes active, the first canvas becomes the second canvas, and gets cleared). I haven't tried this and I hope that there is no problem between stencil buffers and canvas...
Alternatively you could create a second canvas, create an inverted stencil, so that it renders everywhere where the mouse isn't. Then render your canvas on this second canvas, and swap them (the second canvas becomes active, the first canvas becomes the second canvas, and gets cleared). I haven't tried this and I hope that there is no problem between stencil buffers and canvas...
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Looking for a ready-to-paint canvas using a shader
I almost forget the pencil API, gonna try that. Thanks!
Re: Looking for a ready-to-paint canvas using a shader
You can't render to the same canvas you're sampling from.
To erase pixels you can use multiply blend mode with solid brush background and a hole where erasing area is.
To erase pixels you can use multiply blend mode with solid brush background and a hole where erasing area is.
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Looking for a ready-to-paint canvas using a shader
It looks I was just confused about the shader, I don't actually need it, the performance I was looking for, you can see it by dragging the mouse here, just canvas logic. thanks anyway!
Who is online
Users browsing this forum: Ahrefs [Bot] and 228 guests