Is there any way to obtain ray direction?

I would like to make a lightmap baking with directionality. Do we have a way to obtain ray direction?

what do you need the ray direction for? maybe there is a workaround or an easier solution

Im not sure if this is what you were looking for

I’m looking for the input direction of the light, to bake the lightmap directionality. That needs to bake various lights or area lights, direction vector.

How do you plan to store multiple vectors into 1 pixel?
How would area lights be stored? since they are made of multiple vectors…
Can you post an example of a ‘lightmap directionality’ map?

In the same way that you keep various lights in same pixel, mixing it… directional map at last image

to me it looks like a regular normal map

i’m guessing this is the type of effect you’re going for: https://docs.unity3d.com/Manual/LightmappingDirectional.html

i don’t think blender exposes enough information to construct a shader for this in a single pass, but you could conceivably create and bake a direction/intensity shader per light, and then mix them after the fact, which sounds pretty cumbersome outside of making some python tools to automate

Use object space instead of tangent space when you bake a normal map and that is exactly the same thing you were showing in the last picture (without that UV checkerbox)

and it doesn’t store any info about direction of lamp, (no one would need that anyway since you have their location) it stores the direction of the object.

a pixel can store up to 3 variables as it has 3 channels, RGB (sometimes also A for transparency).
a 3d vector also has 3 variables. That is why you can’t mix 2 vectors together and expect that you can sparate them later. By mixing 2 vectors you recive a 3rd unusable vector.

Directional lightmaps have limitations, but that is acceptable when we talk about videogames.

From I understood by quick reading this document, I think this might be what you’re after (not sure though):

2 Likes

That colors are not generated by light position, changes depending of the pov