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

How to get albedo color?

Discussion in 'High Definition Render Pipeline' started by TOES2, Sep 17, 2021.

  1. TOES2

    TOES2

    Joined:
    May 20, 2013
    Posts:
    135
    I am writing a custom post processing volume shader for HDRP, and wonder how I can read the albedo?

    This from the official example shader:

    Code (CSharp):
    1.     float4 CustomPostProcess(Varyings input) : SV_Target
    2.     {
    3.         UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
    4.  
    5.         float3 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex, s_linear_clamp_sampler, input.texcoord).xyz;
    6.  
    7.         // Apply greyscale effect
    8.         float3 color = lerp(sourceColor, Luminance(sourceColor), _Intensity)*0.5;
    9.  
    10.         float3 albedoColor = //HOW TO????
    11.  
    12. ...
    13.      
    14.         return float4(color, 1);  
    15. }
     
  2. TOES2

    TOES2

    Joined:
    May 20, 2013
    Posts:
    135
    Anyone..?
     
  3. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
  4. TOES2

    TOES2

    Joined:
    May 20, 2013
    Posts:
    135
    Hm, but I get other buffers like normals and depth in the post processing...? So seems there are more buffers available, it is just super poorly documented..

    This is how to grab normals for example:

    Code (CSharp):
    1.  
    2. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
    3.  
    4. float3 GetNormalWorldSpace(float2 uv, float depth)
    5.     {
    6.         float3 normalWS = 0.0f;
    7.  
    8.         if (depth > 0.0f)
    9.         {
    10.             NormalData normalData;
    11.             const float4 normalBuffer = LOAD_TEXTURE2D_X(_NormalBufferTexture, uv);
    12.             DecodeFromNormalBuffer(normalBuffer, uv, normalData);
    13.             normalWS = normalData.normalWS;
    14.         }
    15.  
    16.         return normalWS;
    17.     }