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

Unity 5.4 How to get the second lightmap(direction map)

Discussion in 'Shaders' started by Lin-Dong, Jan 11, 2017.

  1. Lin-Dong

    Lin-Dong

    Joined:
    Apr 10, 2015
    Posts:
    14
    Hey guys, I want to get the direction map(directional specular bake) in a vert frag shader.Get the light map is easy just sample "unity_Lightmap".How to get another one?:)
    Another question is, used standard shader baked have normal map's information,how to let unity get the normal map in vert frag shader?
     
  2. Lin-Dong

    Lin-Dong

    Joined:
    Apr 10, 2015
    Posts:
    14
    umm...somebody said
    UNITY_SAMPLE_TEX2D_SAMPLER(unity_LightmapInd,unity_Lightmap,1)
    can get this map, but my shader will post an error:
    Fragment program 'frag': sampler 'samplerunity_Lightmap' has no matching texture and will be undefined.
     
  3. bugsbun

    bugsbun

    Joined:
    Jun 26, 2017
    Posts:
    27
    I also want the "realtime directional map" as specified here : https://forum.unity3d.com/threads/directional-lightmaps.280716/

    For the normal and depth information you can use the _CameraDepthNormalsTexture in the shader. You can decode it using :
    Code (CSharp):
    1. DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture,i.uv),decodedDepth,decodedNormal);
     
  4. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    692
    did anyone ever figure this out?