Readig the Output of a Shader

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Readig the Output of a Shader

Post by parallax7d »

is there any technique for Love to access/read/get the output of a shader?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Readig the Output of a Shader

Post by kikito »

Draw it in a canvas. Then you can use canvas:getPixel.
When I write def I mean function.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: Readig the Output of a Shader

Post by parallax7d »

It looks like that method has been removed. I guess the new way is to dump the canvas to an imagedata any query that. I wonder if the upcoming changes to imagedata will make the Canvas:newImageData method even quicker?

What would be super nice, although unrealistic? would be a way to allocate a sequential imagedata region in ram, and give shaders/canvases a condition to automatically dump to that region after they've rendered their texture (if the condition is met). That way you don't have to wait for the part of the game loop where the newImageData method is invoked, maybe giving the gpu slightly more time/flexibility for when it wants to dump the data each time it's needed. No idea if sync objects would be required to make this reliable/usable, or if you could just have some sort of flag bit in the 'imagedata region' that flips with each full write or something to signal it's been done.
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: Readig the Output of a Shader

Post by D0NM »

parallax7d wrote: What would be super nice, although unrealistic? would be a way to allocate a sequential imagedata region in ram, and give shaders/canvases a condition to automatically dump to that region after they've rendered their texture
I create a canvass that are 4x bigger than the current display resolution.
Then I use different shaders on the canvases.
And finally I use those canvases as big sprites and draw them on the screen.

Isn't it enough for your case?
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 48 guests