Search Unity

Surface Shader - Light Probes

Discussion in 'Shaders' started by MaT227, Aug 27, 2014.

  1. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Hi everyone !
    Is it possible to handle Light Probes in a Surface Shader ?
    It seems to be linked with lightmaps but I don't see any specific documentation concerning Light Probes and Surface Shaders.
    Is it possible to handle light direction in Surface Shaders lightmap pass ?

    Thank you very much !
     
  2. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Light probes are handled in surface shaders unless you write your own section of the program to change the way they behave (as in the case with Shadowgun).
     
  3. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thank you for your answer !
    Yes, it seems that the ambient lighting and light probes are automaticaly handled by using or not noambient and novertexlights.
    But if I deactivate those properties how can I handle those my way ?
     
  4. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
  5. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thank you for the link ! it seems that this topic is not well documented but you can control the Spherical Harmonics and the Ambient by using the ShadeSH9 in the vertex function to retrieve the lighting data.

    I have one last question. Lets consider you have a simple lightmapped scene with :
    • Directional Light (used for lightmapping)
    • Light Probes
    • Static Objects
    • No-static Object
    It seems that the Directional Light has no influence over the No-static Object if it uses the Use Light Probes property.
    But if I add a Point Light, the No-static Object is lit by the Light Probes and the Point Light.

    I don't know if this behavior could be corrected in the shader or if this is linked with the Directional Light in this case.

    In a more general way, it seems that it's not possible to use the lightmapped lights used for lightmapping for the objects that use Light Probes.

    Am I right or is it more complicated than that ?
    Thank you.
     
  6. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    More complex than that, I presume you are talking about the provided light probes character shader from the demo scene, if you look inside of the shader itself you see they have their own lighting function, as this is a surface shader however, it will recognise further passes to include point lights beyond the initital directional light unless explicitly stated, its perfectly possible to create a shader which takes both directional light and light probe information. However in the case of this demo I believe it is set up so the "sun" is also baked.

    It also seems like you are on about a few things here, if you wish to bake your directional light information into the probe then selected "Baked only" from the option in the light itself, otherwise, the probes will only take point light information.

    Sorry if this is a bit of ramble. Long day, ask away if anything is unclear/ if anyone else wants to add/ correct me?
     
  7. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thank you again for your answer ! :)

    I was not talking about the provided demo scene especially.
    I understand that it's possible to handle directional light and light probe information in the Surface Shader lighting function.

    But it seems that if your use your light for baking probes, and you use probes on you object, the light won't be used anymore but the probes will. If you deactivate probes for you object, the light will be used and of course not the probes.

    I don't understand that behavior, for me you could be able to use the light information and the probes information and not choose between one of them. That's why I would like to know if it's possible to bypass that behavior.

    I precise that if you use lights that are not used for baking and if you use light probes for your object, the object will use both light and probes informations.