How to get the world position of a light in Karma material

   479   5   1
User Avatar
Member
9 posts
Joined: Aug. 2020
Offline
Hi

I need the transformed world position of a distant light in my karma material, not just the TX/TY/TZ
how can I get it?

thx
kuszi
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
materials can't get any information about lights because they are evaluated before lighting happens.
User Avatar
Member
9 posts
Joined: Aug. 2020
Offline
Well, okay

Then I change my question

I have two textures and I want to mix them together based on how much light hits the object at that point.

how can I do that.

thx
User Avatar
Member
82 posts
Joined: June 2020
Offline
I need the transformed world position of a distant light in my karma material, not just the TX/TY/TZ

Can't you do this with a coordsys to the get the position of the shading point in light space, then transform to world space?
Edited by freshbaked - Feb. 27, 2024 11:49:57
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
freshbaked
I need the transformed world position of a distant light in my karma material, not just the TX/TY/TZ

Can't you do this with a coordsys to the get the position of the shading point in light space, then transform to world space?

You can certainly pass information about the light to the material, but there is no mechanism for the material to evaluate the light shader directly. You would have to re-implement everything about the light's shading in your material, but you wouldn't be able to find out how much light is hitting because you can't calculate shadowing. From the original question, for a distant light, calculating the amount of light hitting an object while ignoring shadowing is easy, it's always 100% of the light intensity.
Edited by jsmack - Feb. 27, 2024 12:24:09
User Avatar
Member
9 posts
Joined: Aug. 2020
Offline
Thank you everyone for the answers

I think I made a wrong question.

In unreal I have a light, and an object.
I know exactly the light position, so with a simple dotproduct I can calculate the angle between the light and the surf pos.

Btw, because my light is only translated and rotated, I simply put this math into the shader and it is working (not the best solution) as you can see on the attached image, where the final dotproduct is connected into the emission
Image Not Found

Attachments:
light.png (1019.9 KB)

  • Quick Links