how to apply output of shader to the same shader?

I made a shader that does holes on the screen.

What I want to do is to pass the output of the shader again to the same shader.

Currently my shader is applied on a quad that takes 2 textures as the input.
1 tex is background, the other is something to add to the background.

What is the best way of doing this?
Is the material shaded texture available again?
So I want to use the modified texture and modify it again and again and again.

Thanks

You can’t really retrieve “shader results” unless you’re doing an image effect where you render to a texture.

I think you only have 2 options:

  • Make your shader in such a way that the result is directly caused by passed parameters (from your script to the shader) so you can continue with said parameters in the next shader(s).
  • Make the shader in multiple passes.

What suits better depends on what you’re trying to achieve though.

You can store the result of the first pass in a RenderTexture, and use that as input the next time you run the shader.

Be careful though, writing to the texture you’re reading from can give some unexpected results, so draw into a different RenderTexture the second time.

Uhm yeah, what RC-1290 said. For some reason I thought RenderTextures only worked properly for Image Effects. Guess I was wrong :slight_smile:

Yup

I am looking into that.
The shader is already designed to take 2 textures as an input + some info parameters.
So I will render a texture to a render texture and use the output as input of the next operation to make sure all effects are done on the same texture.