Search Unity

[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:
    295
    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