Search Unity

Anyway to include GI information or send out GI information using custom shader?

Discussion in 'Shaders' started by FuzzyShan, Apr 27, 2015.

  1. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    wonder what is the exact code to be used in shader to allow GI information been passed when set this object to lightmap static... for example I want to able to write my own custom water shader, by marking the water static, I want my water able to affect my surrounding areas...
     
  2. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    Anybody?
    1. Include this sub shader to any other shader I write I assume it is passing meta information to unity regarding for GI and light mapping?
    // ------------------------------------------------------------------
    //Extractsinformationforlightmapping, GI (emission, albedo, ...)
    //Thispassitnotusedduringregularrendering.
    Pass
    {
    Name"META"
    Tags { "LightMode"="Meta" }

    CullOff

    CGPROGRAM
    #pragmavertexvert_meta
    #pragmafragmentfrag_meta

    #pragmashader_feature_EMISSION
    #pragmashader_feature_METALLICGLOSSMAP
    #pragmashader_feature____DETAIL_MULX2

    #include "UnityStandardMeta.cginc"
    ENDCG
    }


    2. This assuming below is using realtime GI for different shaders?
    I looked into the standard shader code, I see that Unity has this:
    UnityGIgi = FragmentGI (
    s.posWorld, occlusion, i.ambientOrLightmapUV, atten, s.oneMinusRoughness, s.normalWorld, s.eyeVec, dummyLight);
    half3color = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect).rgb;
    color += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, occlusion, go);

    To calculate the PBS and GI into color, assuming that I don't want Physical based shading, I can then just not use the UNITY_BRDF_PBS function?

    3. Any documentation on this?

    #if (SHADER_TARGET < 30)
    outDiffuse = 1;
    outSpecSmoothness = 1;
    outNormal = 0;
    outEmission = 0;
    return;
    #endif

    4. also about this... so shader target using opengles 2.0 will not have any dynamic emission?
     
    Last edited: May 5, 2015
  3. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    I'm having a hard time finding a proper solution for this, too.
    Some documentation or examples with a practical use case would be great.