Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Shader drawing over rendertexture

Discussion in 'Shaders' started by Alvare32, May 20, 2023.

  1. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    58
    Hello forum,

    I've attached two gifs of what I want the shader to achieve. Basically, the shader is just black voronoi blobs going around on a white background. This is the one I'm currently using: https://www.shadertoy.com/view/fs2XRW
    What I want to do is have the substracted result of that so it draws the black blobs and smears them over the rendertexture like in the 2nd gif.

    What I'm currently doing is:
    Have an orthographic camera with a 'don't clear' flag look at a quad with the shader applied. And underneath that quad, have a transparent quad that makes sure it gets somewhat cleared over time.

    And for some reason it never works as the 2nd gif. Anyone know how to achieve this effect?
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    You'd need the blob shader to be transparent too. If it's not transparent and has a white background it'll be overwriting the previous data with white.
     
    Alvare32 likes this.
  3. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    58
    I've been thinking about this 'depth clear' technique I'm trying without avail.
    But I think this is not what I need. Well, sort of.

    I think I need this fade to happen earlier. Within the shader itself.
    https://www.shadertoy.com/view/fl3fzr
    Sort of like how the lines in this one. I'm wondering, is it possible in Unity to do this 'delayed clear' within the shader instead? I'd really love to port the colored lines one now to learn how these types of effects
    Buffer.jpg
    are ported over. Always wondered about it and never managed to figure it out.
     
    Last edited: May 26, 2023
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,991
    Alvare32 likes this.
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    That particular shadertoy is doing something a bit more complicated than you're attempting to do. But the short version is Buffer tabs render to a render texture (iChannel#), the Image tab renders to the screen. Common just has code snippets you can call from any other tab.

    For what you're doing, all you really need to do is have your blob texture render using an alpha blend where the white areas are mostly transparent. That's it.
     
    Alvare32 likes this.