Hi, I have been writing my own shaders that are basically modifications of the standard shaders, nothing fancy, but I combine noise with textures so that walls in the environment look dirty, etc. I also bake the lighting, so I wonder, how does Unity deal with custom shaders when baking light?
My understanding is that in order to get the right lighting, when determining the light bounces on the different objects, you need the information of the albedo, normals, smoothness, metallicity, etc. of the material the light is bouncing on, at that specific location. So you’ll need to compute the shader there, is this actually computed during the baking process? or does Unity use default values of smoothness, and other parameters? What about if I modify the vertex shader so that the triangle changes its location? this is going to mess with the triangle tree optimizations, is the vertex shader also taken into account?
And if I use an interior mapping shader, is the baked lighting going to look right?
Thanks in advance
Custom Shaders can provide inputs to the lighting system via a special shader pass known as the ‘Meta Pass’. It affects both fully baked and realtime GI. The pass determines how the shaded object will look from the light bakers point of view. Relevant doc page is here Unity - Manual: Lightmapping and shaders
For shadows (rendering to the camera’s depth buffer) those are handled in the ‘ShadowCaster’ pass. Example near the bottom of this page Unity - Manual: Custom shader fundamentals