Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Replacing the lighting calculations in forward mode

Discussion in 'Shaders' started by andyz, Aug 22, 2016.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,251
    In deferred I can change the lighting part of shaders easily by choosing a different shader - https://docs.unity3d.com/Manual/class-GraphicsSettings.html

    But for legacy forward shaders I think I have to replace the Lighting.cginc file ? to modify the Lambert/BlinnPhong shaders by replacing the installed file in: Unity5.x.x\Editor\Data\CGIncludes.
    Edit: tried this and reloaded Unity - no difference

    Can you replace the lambert and blinnPhong surface shading for all shaders in forward?
     
    Last edited: Aug 22, 2016
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Because Unity doesn't expect the files in the data folder to change apart from on editor version upgrades. You need to clear the shader cache to force Unity to rebuild the built in shaders.

    Go to your project's Library folder and delete the cache folder.

    However this will rebuild every shader and you have to do this if you want to make any tweaks to that custom lighting model, and if you do upgrade Unity it'll blow away those files and you'll have to replace them again.

    The easier path is to not use the built in shaders at all and just write your own shaders using whatever lighting model you want.
     
    Last edited: Aug 22, 2016
    andyz likes this.
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,251
    ok thanks - yeah copying lighting.cginc surface models and changing to create new ones for new shaders works - pity docs are out of date in this area, they still reference 4.x-style surface shaders (reported)