Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Feature Request Custom Render Texture Shader Graph

Discussion in 'Shader Graph' started by L4Z3RC47, Dec 27, 2019.

  1. L4Z3RC47

    L4Z3RC47

    Joined:
    Jun 21, 2015
    Posts:
    46
    I've been looking around for possible solutions but so far have come up mostly empty handed for native shader graph. Amplify's shader editor does currently have a solution for this but I'd prefer to stick with native tools.
     
  2. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
  3. L4Z3RC47

    L4Z3RC47

    Joined:
    Jun 21, 2015
    Posts:
    46
    Right, however this requires the shader template to have a particular format which to my knowledge shader graph does not allow.

    Shaders for custom render textures must do the following

    * #include “UnityCustomRenderTexture.cginc”

    • Use the provided Vertex Shader
      CustomRenderTextureVertexShader

    • Use the provided input structure v2f_customrendertexture for the pixel shader
     
  4. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    Sorry for the late response.
    I thought so too, but LWRP/URP works with custom render textures for me.
     
  5. L4Z3RC47

    L4Z3RC47

    Joined:
    Jun 21, 2015
    Posts:
    46
    The shader graph does? I know that both SRPs support custom render textures but I’ve been unable to see so far how to create a shader in shader graph for CRTs so far since they require a few specific lines in the generated shader code
     
  6. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    Yes. Just use a LWRP unlit master node (note World position node & other similar nodes will not work as expected -since the texture does not have a position in the game) and use that material in a CRT.

    Terrain displacement is a LWRP unlit shadergraph material (which is why it is gray in the project window).
    Note the Unnamed Pass 0.
    upload_2020-1-30_15-18-4.png
     
  7. jitterhorse

    jitterhorse

    Joined:
    Sep 11, 2016
    Posts:
    9
    Hey, I ran into the same problem. I tried the unlit master node in my shader graph material but have only the options "pass", "shadow caster" and "depth only" in the pass selection of the CRT. "unnamed pass 0" is only apppearing in non-shadergraph unlit shader. Did you find any other solution? Or do I miss here something? Thanks!
     
  8. L4Z3RC47

    L4Z3RC47

    Joined:
    Jun 21, 2015
    Posts:
    46
    @jitterhorse sorry, no luck on my end. I've just been using Amplify Shader Editor. @A132LW Not sure how to reproduce this? As a basic example what I would be trying to do is render the main camera to the custom render texture and then have the shader pickup the texture input from the camera to perform an op. A dead simple example would be like a simple color invert of the incoming texture
     
  9. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    Sorry, meant to respond earlier and forgot. I haven't found another solution.

    "Unnamed pass 0" should appear in the unlit shadergraph - BUT only with LWRP/URP unlit master.
    So at present, I am using a CRT using a URP/LWRP unlit master node based shadergraph, which then can be used as input to a HDRP shadergraph/default shaders.

    (I am assuming you are using HDRP unlit - since you don't have the unnamed pass).


    *Note that if you are using the 2020b, then try the ForwardOnly pass on the unlit master (LWRP/URP, not HDRP).
    Also note below images are for the 2020beta. You don't need to upgrade to the beta, it works with any 2019 version -not sure about the early 2018 versions, because I don't remember if I used this workaround back then.

    upload_2020-7-15_21-5-53.png
    upload_2020-7-15_21-6-37.png
    (again, if this is an older version, you would be using the unnamed pass above, and the material would be pink - if you are on HDRP)

    What version are you using (Unity, HDRP/LWRP)?
     
unityunity