I want to access the light direction from a directional light map in a shader I am writing. I have hardly been able to find any information or example on how to do so.
I tried doing it the same way as a regular light map:
You haven’t been able to find any information, because what you want to do isn’t how lightmaps tend to work. Lightmaps usually store light contribution data for a given surface and know nothing about the lights affecting said surface - they have no concept of the direction from which the light is coming from (if they did, they probably wouldn’t be much cheaper than dynamic lights), ergo, you cannot get it.
I’m under the impression that is exactly what a “directional lightmap” is. One map is the light contribution data for a given surface as you say, and the other map is direction information stored as a color. Am I misunderstanding something?
That would be helpful but I am trying to avoid using surface shaders. I want to know exactly what my shader is doing, and surface shaders seem to do a lot of mysterious things behind the scenes. There are lots of examples of decoding regular lightmaps in vert/frag shaders… I didn’t think this information would be so hard to come by…
It is possible to take a look at the vertex and fragment shaders created by surface shaders using #pragma debug. It isn’t always easy to read, but majority of the time, the information you need is there.