https://kotlinlang.org logo
Title
a

Arjan van Wieringen

02/09/2023, 2:16 PM
If I wanted to do some sort of Shader where the Shader code is dependent on the previous shader result (e.g. in a simulation, or some motion blur). How would I do this? Can I render the shader result in a temporary buffer somehow and load that into the next render frame into a
uniform
?
r

romainguy

02/09/2023, 3:58 PM
Yes you can link shaders using uniform shader types.
a

Arjan van Wieringen

02/09/2023, 4:43 PM
Thanks, I am aware that is possible. But unless I am misunderstanding it this is subtly different then what I mean. I want a shader that has as a uniform input the shader result from the last frame(s). This way you can do things like motion blur.
r

romainguy

02/09/2023, 4:48 PM
Ah, no there’s no easy way to do this
You’d have to render into a bitmap yourself and feed that back to your shader
k

Kirill Grouchnikov

02/09/2023, 6:41 PM
Getting shader output off of the GPU path and into software-managed bitmaps is not going to be good for performance
If possible, I would suggest using another shader that is a “step behind” your primary one, and use that as a child shader to feed that previous frame
r

romainguy

02/09/2023, 6:45 PM
Technically they don’t have to be software managed bitmaps
Not sure what Skiko provides but that’s what volatile images are in Java2D, and Android has hardware buffers
a

Arjan van Wieringen

02/09/2023, 7:31 PM
I think I need to understand the pipeline better first before I can do these things. But thanks for your help!