Search Unity

Render light per vertex with Legacy/Diffuse shader

Discussion in 'Shaders' started by ChanzDog, Oct 17, 2018.

  1. ChanzDog

    ChanzDog

    Joined:
    Sep 28, 2017
    Posts:
    43
    I read an article about how the most important lights (up to 4) with the Legacy/Diffuse shader are rendered per pixel and then 4 more are rendered per vertex. The reason I'd like to do this is to minimize draw calls with multiple lights in forward rendering mode.

    Apparently, you can set the light to "Not Important" and it should be rendered in per vertex lighting. I have checked it and indeed, the draw calls do not increase with more "Not Important" lights. The problem is that the light doesn't actually show the light in this mode unless I GREATLY increase the range (10x).

    Is this expected? How do I just have these lights render per vertex as opposed to per pixel and display normally. important.png notimportant.png
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    Per vertex lights are per vertex. If your mesh doesn't have a lot of vertices, and if the light isn't close to a vertex, then your mesh won't receive much light. The solutions are:
    1. Significantly increase the range and size of your lights.
    2. Significantly increase the tessellation of your mesh.
    3. Write a fully custom vertex fragment shader that calculates per-pixel lights using the per-vertex light data.