Search Unity

Doc about "Surface Shader lighting examples"

Discussion in 'Documentation' started by lichunHZ, Jul 12, 2017.

  1. lichunHZ

    lichunHZ

    Joined:
    Jun 13, 2017
    Posts:
    3
    https://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html

    On this page in the "Custom GI" section:
    Code (CSharp):
    1. inline void LightingStandardToneMappedGI_GI(
    2.                 SurfaceOutputStandard s,
    3.                 UnityGIInput data,
    4.                 inout UnityGI gi)
    5.             {
    6.                 LightingStandard_GI(s, data, gi);
    7.    
    8.                 gi.light.color = TonemapLight(gi.light.color);
    9.                 #ifdef DIRLIGHTMAP_SEPARATE
    10.                     #ifdef LIGHTMAP_ON
    11.                         gi.light2.color = TonemapLight(gi.light2.color);
    12.                     #endif
    13.                     #ifdef DYNAMICLIGHTMAP_ON
    14.                         gi.light3.color = TonemapLight(gi.light3.color);
    15.                     #endif
    16.                 #endif
    17.                 gi.indirect.diffuse = TonemapLight(gi.indirect.diffuse);
    18.                 gi.indirect.specular = TonemapLight(gi.indirect.specular);
    19.             }
    UnityGI is defined in UnityLightingCommon.cginc, and has no light2 and light3 members. Is there anything i missunderstand.
     
  2. Bloogson

    Bloogson

    Joined:
    Jan 27, 2015
    Posts:
    12
    Bump. I'm confused about the exact same thing.
     
  3. PurpleGooper

    PurpleGooper

    Joined:
    Jul 9, 2019
    Posts:
    7
    i've yet to test this but,
    i've noticed that the custom lighting EXAMPLES (not the 4 function presets) never use Unity GI and even use more arguments than those in the presets. So i thought maybe they just wrote "Unity GI" just to abbreviate : "put any arguments you want as long as they come from the Unity GI struct".
    This is what unity says about the custom lighting function structure to follow:



    and here is one of the examples instead


    you can see how the arguments dont match the types in the first picture where the presets are, or the number of arguments for that matter.
    This was very confusing for me and i've been struggling myself with passing the data i need through the lighting function, i hope this helps you find the solution.

    EDIT: wow i cant get the pictures to work... i'll just post you the links i snapped the pictures from:
    https://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html 1st pic

    https://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html2nd pic (scroll down to simple specular)