Hello, is there a way for me to send a 1D depth-buffer to a shader.
I'm trying to store a value(distance) for every x-coordinate on the screen. And I would like to send it to my shader.
I've tried to send an array to the shader, but that won't let me send over 1019 values to a shader. Plus I heard that It was very slow.
So how can I do this?
Sending 1D depthbuffer to a shader
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Sending 1D depthbuffer to a shader
You could use a texture, store your distances in it's pixels and then sample the value using your x-coordinate in your shader.
Re: Sending 1D depthbuffer to a shader
Make an ImageData of format r32f (or whatever fits best) with the approriate width and a height of 1 pixel. Make an Image from the ImageData, that's your texture, and send it to the shader. Use Image:replacePixels to update the texture. Use ImageData:mapPixel to update the pixels, avoid ImageData:setPixel.
https://love2d.org/wiki/PixelFormat
https://love2d.org/wiki/ImageData:mapPixel
https://love2d.org/wiki/(Image):replacePixels
https://love2d.org/wiki/PixelFormat
https://love2d.org/wiki/ImageData:mapPixel
https://love2d.org/wiki/(Image):replacePixels
Re: Sending 1D depthbuffer to a shader
thank you!grump wrote: ↑Sun Jan 16, 2022 10:51 am Make an ImageData of format r32f (or whatever fits best) with the approriate width and a height of 1 pixel. Make an Image from the ImageData, that's your texture, and send it to the shader. Use Image:replacePixels to update the texture. Use ImageData:mapPixel to update the pixels, avoid ImageData:setPixel.
https://love2d.org/wiki/PixelFormat
https://love2d.org/wiki/ImageData:mapPixel
https://love2d.org/wiki/(Image):replacePixels
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests