[Solved] Looking for a ready-to-paint canvas using a shader

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
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

Post by alberto_lara »

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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Looking for a ready-to-paint canvas using a shader

Post by raidho36 »

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.
User avatar
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

Post by alberto_lara »

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.
User avatar
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

Post by Positive07 »

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...
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
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

Post by alberto_lara »

I almost forget the pencil API, gonna try that. Thanks!
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Looking for a ready-to-paint canvas using a shader

Post by raidho36 »

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.
User avatar
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

Post by alberto_lara »

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!
susse.love
(1.69 KiB) Downloaded 167 times
Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests