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 Reaching "_CameraOpaqueTexture" in HLSL on shader graph

Discussion in 'General Graphics' started by ZerinLabs, Oct 4, 2020.

  1. ZerinLabs

    ZerinLabs

    Joined:
    Mar 8, 2019
    Posts:
    32
    Hi guys,

    I'm really struggling to get this done.

    I'm aware I can get the "_CameraOpaqueTexture" texture via "Scene color" node, but I would like to access it from inside a custom function node in order to work with it via HLSL code.

    I tried this directly on the code...
    SAMPLE_TEXTURE2D( _CameraOpaqueTexture, SS, UV);
    ...and no success :/

    I tried too setting up a texture2d variable inside shader graph and changing the "reference name" as "_CameraOpaqueTexture" and then moving from there but ...no success neither

    any help or suggestion would be really appreciated

    cheers!
     
  2. ZerinLabs

    ZerinLabs

    Joined:
    Mar 8, 2019
    Posts:
    32
    Ok, it looks like finally I had some success...

    Two things are important here:

    1) it looks like you CAN't have a custom texture2D property if you have on your graph already the "sceneColor" node
    (even if you're not using it...)

    2) when you create a new "texture2d" property and you set its reference name as "_CameraOpaqueTexture" in order to get the "URP opaque texture" there... it is extremely important you disable the "exposed" property on the Texture2D properties section

    all this made the deal for me

    cheers!!