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

what is the command of CGINCLUDE?

Discussion in 'Shaders' started by JohnSonLi, Nov 10, 2014.

  1. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    CGINCLUDE

    struct v2f_full
    {
    half4 pos : SV_POSITION;
    half2 uv : TEXCOORD0;
    half4 normalScrollUv : TEXCOORD1;
    half4 screen : TEXCOORD2;
    half2 fakeRefl : TEXCOORD3;
    #ifdef LIGHTMAP_ON
    half2 uvLM : TEXCOORD4;
    #endif
    };

    #include "AngryInclude.cginc" (include this file already ,why need CGINCLUDE command?)

    half4 _DirectionUv;
    half4 _TexAtlasTiling;

    sampler2D _MainTex;
    sampler2D _Normal;
    sampler2D _ReflectionTex;
    sampler2D _FakeReflect;

    ENDCG
     
  2. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    If I recall, CGINCLUDE will insert the contents of the include into each pass of your shader.
     
  3. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    thx
     
  4. chakmeshma

    chakmeshma

    Joined:
    Jan 28, 2013
    Posts:
    1
    I found this comment line in one of Unity's native ImageEffect shaders:
    Code (ShaderLab):
    1. ...
    2. // Shader code pasted into all further CGPROGRAM blocks
    3. CGINCLUDE
    4. ...
    5. ENDCG
    6. ...
    So it seems, it pastes the code between CGINCLUDE and the next ENDCG, into (probably at start) of all the following CGPROGRAM blocks found in Passes. The CGINCLUDE however can (or must) be put directly inside the Shader block.

    *Found in Unity 5.3.5f1 RadialBlur
     

    Attached Files:

    Last edited: Jul 14, 2016
    VitruvianStickFigure likes this.