Page 1 of 1

Readig the Output of a Shader

Posted: Tue Dec 06, 2016 5:24 pm
by parallax7d
is there any technique for Love to access/read/get the output of a shader?

Re: Readig the Output of a Shader

Posted: Tue Dec 06, 2016 5:52 pm
by kikito
Draw it in a canvas. Then you can use canvas:getPixel.

Re: Readig the Output of a Shader

Posted: Tue Dec 06, 2016 7:13 pm
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.

Re: Readig the Output of a Shader

Posted: Thu Dec 08, 2016 9:21 am
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?