Unity offers the possibility to access viewDir inside the lightmapping lighting functions like explaine in the documentation : Custom Lighting models in Surface Shaders
It seems that viewDir is not working… So I tried to transfer it from the Surface function to the lighting function using a custom SurfaceOutput but the result is quite funny…
I only get a black object… BUT, if I use Albedo to transfer my viewDir, it works…
To be honest I am quite bored by this as I don’t see any solution… and there is no answer from the Unity devs.
The only solution that comes in my mind is to build a full vertex/fragment shader that handles all types of passes for deferred and forward but I would prefer not doing it and use a surface shader.
The full vertex/fragment might be a bigger source of errors and incompatibility and there is no example of a standard Blinn-Phong shader that handles all the Unity defines and rendering.
I would like to know if there a way to send the view direction vector to the single lightmap lighting function ? Or maybe there is a workaround.
2. I tried to handle dual lightmaps lighting but it seems that this lighting function is simply not handled and not called. Instead, the single lightmaps lighting function is called.
How can I handle dual lightmap lighting with the view direction vector ?
3. I tried to handle directional lightmaps lighting but again I am facing a new issue. The function is well called but it seems that the view direction value is empty and outputs only black.
Is there a workaround for all those issues or maybe I am missing something. I would like to use the view direction vector inside all the lighting functions (forward, deferred, lightmap).
I’ve thought about building my own vertex/fragment shader without having to use a surface shader but I would need to handle all types of passes and defines for deferred and forward.
I would prefer not doing it and use a surface shader unless there is any sources of a simple Blinn-Phong shader handling everything (lightprobes, lightmaps, deferred, soft and hard shadows, etc.) with all defines and passes included. Maybe some kind of shader example or sample.
I hope somebody will be able to help me solving my problems because those issues are blocking my project. Of course, if you need more informations feel free to ask.
Thank you very much.