Search Unity

Using a RenderTexture to apply a Shader to a texture

Discussion in 'Image Effects' started by rohmer, Oct 19, 2016.

  1. rohmer

    rohmer

    Joined:
    Mar 24, 2014
    Posts:
    23
    This seems like it would be easy, but I am having a lot of difficulty figuring out how to do this.

    Here is what I want to do:
    Take a Texture2D and apply a Blur effect to it and get the result. So it would be something like:
    Texture2D blurred=BlurEffect(Texture2D InputTexture)

    BlurEffect would setup a rendertexture and apply the blur shader to it.

    Any suggestions on either:
    A) How I would do this?
    B) Where I would go to learn how to do this (RTFM didn't help too much :))

    Thanks!
     
    eofirdavid likes this.
  2. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Graphics.Blit is used to copy a render texture to another (or to the screen). Note that you cannot blit from a render texture to itself, so you need to create a second one.

    The functions takes a material, which in turn can be created with a shader as parameter - the shader that will apply the blur effect.

    The Unity standard assets already have a blur shader.

    Hope this gets you going ;)
     
    memoid likes this.