Search Unity

Inconsistency between Edit and Play mode on custom shader

Discussion in 'Shaders' started by leitecunha, Sep 5, 2017.

  1. leitecunha

    leitecunha

    Joined:
    Jun 26, 2013
    Posts:
    7
    Hi there!

    I have a custom shader that enables the user to plug in external lightmaps to Unity. It is actually built on top of the Standard shader, so it can have all of its functionalities and add that feature (and some others, like refraction). To create it, I replaced the includes where unity_Lightmap is called and insert my variables for the external textures.

    This way I can even use realtime GI on top of that, since it's another variable and workflow (unity_DynamicLightmap).

    The problem is when I turn on Mixed Lighting on the lighting tab (so I can use other shaders and also be able to process light probe groups for any dynamic object).

    Here is what happens... I am using the second UV channel of my models for the external lightmaps. Everything works super fine in the editor, until I press the Play button, or make a build. It appears that Unity gets the object second UV channel and transforms it, using the lightmap UVs it creates (because it always creates its own lightmap anyways), causing my UVs to be totally incorrect.

    Some help would be much appreciated!
    Thanks
    Paulo Cunha