Search Unity

Any documentation on UNITY_SAMPLE_1CHANNEL?

Discussion in 'Shaders' started by Stephan-B, May 31, 2013.

  1. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Where can I find documentation on UNITY_SAMPLE_1CHANNEL and other Unity internal shader stuff?

    Also what is the difference between

    Code (csharp):
    1.  
    2. fixed4 col = tex2D(_MainTex, i.texcoord);
    3.  
    4. fixed4 col = UNITY_SAMPLE_1CHANNEL(_MainTex, i.texcoord);
    5.  
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    I do not know where to get the documentation, but you may look how it works here:
    DRIVE: \ UnityFOLDER \ Editor \ Data \ CGIncludes.
     
  3. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The only references to it are found in HLSLSupport.cginc

    Code (csharp):
    1.  
    2. #if defined(SHADER_API_D3D11_9X)
    3. #define UNITY_SAMPLE_1CHANNEL(x,y) tex2D(x,y).r
    4. #define UNITY_ALPHA_CHANNEL r
    5. #else
    6. #define UNITY_SAMPLE_1CHANNEL(x,y) tex2D(x,y).a
    7. #define UNITY_ALPHA_CHANNEL a
    8. #endif
    9.  
    So with D3D11 it gets the alpha from the red channel otherwise it gets it from the Alpha?

    Why does Unity get Alpha from Red with D3D11 using this function?