MaterialX - Get light ray direction?

   1137   3   0
User Avatar
Member
66 posts
Joined: March 2017
Offline
In MaterialX, is it possible to get the vector from the surface to a particular light? Right now, I'm creating an attribute in SOPs to store the information, then reading it as a geometry attribute in the shader. It works, but seems inelegant. I can get similar info from a dot node and putting "ray" in the note field. Maybe there is something similar for light direction?

I'm trying to create a shader where the color changes based on the relationship between the light position and surface normal. Kinda like 3dsMax's "shadow/light falloff".

Thanks!

Brad T.
User Avatar
Member
1621 posts
Joined: March 2009
Offline
As far as I know, you still need to use your "manual" method. I believe there is currently no way around storing the light pos and calculating the light direction vector manually.

At least I have not found any.
Martin Winkler
money man at Alarmstart Germany
User Avatar
Member
7770 posts
Joined: Sept. 2011
Online
BradThompson
In MaterialX, is it possible to get the vector from the surface to a particular light? Right now, I'm creating an attribute in SOPs to store the information, then reading it as a geometry attribute in the shader. It works, but seems inelegant. I can get similar info from a dot node and putting "ray" in the note field. Maybe there is something similar for light direction?

I'm trying to create a shader where the color changes based on the relationship between the light position and surface normal. Kinda like 3dsMax's "shadow/light falloff".

Thanks!

Brad T.

You can in a light shader. A surface shader doesn't know about values that are created at light shader evaluation time.
User Avatar
Member
8555 posts
Joined: July 2007
Offline
for what you are doing, you can probably use coordsys [www.sidefx.com] to access position of your light or any transformable prim

it's probably not as elegant as being able to access light directly by defining relationship or by path, but should be better than having to store primvars

if however you need per sample access to any light that the surface shader is evaluating, I'm not sure that's possible from surface shader as jsmack mentioned, since I believe there is no illuminance loop equivalent in Karma
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links