Making fake light

Greetings gentelmens :slight_smile:

I stuck on that task :frowning: I need quite simple fake light inside material.
So, lets use Dot product from Vec3 (light) and PixelNormalWS:

Nice but:

  1. object position will not change how object recieve the light
  2. changing light position will work as it should only if object location are 0.0.0

Well, lets transform light position vector from Absolute World Space to Local Space:

Nice:

  1. we can move light or object and light recieving will be correct
  2. object can be everywhere in the world
    But…:
    If we rotate our object, the light will be also rotating.

How we can solve that? I try different transormations but looks like im missing something :frowning:

you should use a direction vector rather than a position vector for the sun.

So you could feed the collection parameter the forward vector of your sun, assuming you’ve made it an actor. so when you rotate the sun actor it will work like a directional light.

alternatively if you want more of a point light, I suppose you could also take the light’s position minus the actor’s position (or pixel worldposition) to get a direction vector as well. So then by moving the light actor’s position the gradient changes. in that scenario you could also check the vector length before you normalize to create a falloff based on the distance from the light.

usually i’ll add a constant bias scale in there too just after the dot product so the gradient is in a 0-1 range and not a -1 to 1 range.

3 Likes

you could also take the light’s position minus the actor’s position (or pixel worldposition) to get a direction vector as well

Work like a charm! Thanks, Cel! :slight_smile:

1 Like