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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

[SOLVED] Reading directional lightmaps manually in a custom shader differs from unity_Lightmap

Discussion in 'Global Illumination' started by SurvivalMachine, Mar 24, 2015.

  1. SurvivalMachine

    SurvivalMachine

    Joined:
    Jun 21, 2013
    Posts:
    15
    My lightmap works fine if I sample the scene's lightmap like this:
    half3 lm = UNITY_SAMPLE_TEX2D( unity_Lightmap, i.lmuv ).rgb

    But if I take the lightmap texture (Lightmap-0_comp_dir.exr) and sample it like this its colors are wrong (tinted to green):
    half3 lm = UNITY_SAMPLE_TEX2D( _LightmapColor, i.lmuv ).rgb;

    What causes the difference? How can I supply Unity's lightmaps manually into my shader (without using unity_Lightmap* for various reasons)
     
  2. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    294
    Have you tried decoding the sampled color with DecodeLightmap(fixed4) from UnityCG.cginc? Might be worth a shot.
     
  3. SurvivalMachine

    SurvivalMachine

    Joined:
    Jun 21, 2013
    Posts:
    15