Readig the Output of a Shader
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- parallax7d
- Citizen
- Posts: 82
- Joined: Wed Jul 02, 2014 11:44 pm
Readig the Output of a Shader
is there any technique for Love to access/read/get the output of a shader?
- 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
Draw it in a canvas. Then you can use canvas:getPixel.
When I write def I mean function.
- parallax7d
- Citizen
- Posts: 82
- Joined: Wed Jul 02, 2014 11:44 pm
Re: Readig the Output of a Shader
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.
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
I create a canvass that are 4x bigger than the current display resolution.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
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.
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
Who is online
Users browsing this forum: Ahrefs [Bot] and 6 guests