Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

What does UNITY_INITIALIZE_OUTPUT() do?

Discussion in 'Shaders' started by Zergling103, Jun 13, 2013.

  1. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    316
    Hey there,

    What does UNITY_INITIALIZE_OUTPUT() do? I need the exact source for it. Thanks. :D

    -Steve
     
  2. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    From HLSLSupport.cginc (found in [Unity Install Folder]/Data/CGIncludes) :
    Code (csharp):
    1. #if defined(UNITY_COMPILER_HLSL)
    2. #define UNITY_INITIALIZE_OUTPUT(type,name) name = (type)0;
    3. #else
    4. #define UNITY_INITIALIZE_OUTPUT(type,name)
    5. #endif
    So, it does nothing unless the HLSL compiler is compiling.
    In that case it sets its value to a typecasted zero. That way the compiler won't complain about uninitialized output values.
     
    BlasMena and kaiyum like this.
  3. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    316
    Ah, thanks. :D Now I know, hopefully this will be useful to someone else too.
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,356
    The general resource is the built-in shaders, which are available at the top of the forum. Since 4.1 or so, the CGIncludes are in there as well, so you don't have to fish them out of your Unity install.
     
unityunity