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

Sharing Render Textures between shaders

Discussion in 'Shaders' started by jefferytitan, Jan 20, 2015.

  1. jefferytitan

    jefferytitan

    Joined:
    Jul 19, 2012
    Posts:
    88
    Hi all,

    I'm working on a project in Pro that has a bunch of post-processing shaders (e.g. SSAO, bloom, etc) and I may add more. Many of the shaders come from the Asset Store and other third-party sources.

    So on to my question: I feel that we should make sure we're not duplicating work, e.g. each effect rendering it's own depth texture, that sort of thing. I'm still pretty new to Pro (and hence Render Textures). How would I find which shaders are creating/using Render Textures? Can I share them between different shaders, and would it depend upon the order the shaders are run?

    Thanks,
    JT
     
  2. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,862
    You have to check the source files manually and make sure, i dont think there is any other way.
    Forexample, if your custom shaders use unity provided _DepthTexture or _DepthNormalsTexture, then it is surely created once for camera (which it was turned on)
    But if your shader builds a custom RT somewhere, it probably creates a few more.

    I am not sure but maybe the profiler gives you statistics about this, i never checked.
     
    jefferytitan likes this.
  3. jefferytitan

    jefferytitan

    Joined:
    Jul 19, 2012
    Posts:
    88
    Thanks for explaining about the unity textures. If you did want to share custom textures, are they named somehow like the Unity provided ones?
     
  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,862
    Who knows what the author of your custom package did, most people doesnt follow naming schemes as unity does.