Render to buffer, and use that buffer in shader

I would like to render some sprites into a buffer, and then use that buffer in the shader of a different sprite. (What I'm trying to essentially do is create a custom blending mode, where some sprites are blended with a background image, using a custom shader.) Is this even possible with SpriteKit?


SKEffectNode can be used to render sprites efficiently into a buffer. However, there doesn't seem to be any way of using said buffer in a shader.


(You can add a shader to the SKEffectNode object, but that's not the same thing. That will affect only the contents of SKEffectNode itself. I need to access the buffer in the shader of another node, so that the buffer is blended with that other node using my own custom shader.)

Replies

I don't really know why do a I even bother asking questions here. Nobody ever answers them. Ever. I knew that nobody would answer this either, but I gave it a chance regardless.


Apple, why do you even bother keeping this forum? You are not answering people's questions. So what exactly is the point? You don't seem to care.

There is a way to do this (if I understand you correctly). You can create a new SKTexture that includes the shaded results of a prior rendered SKSpriteNode using SKView's func texture(from: SKNode). Assign the new texture to your sprite node and its shader will have access to this shaded rendering via the normal SKShader sampler2D u_texture. Would that work in your given situation?