MaterialX - Get light ray direction?

   1766   4   0
User Avatar
Member
67 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
1719 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
8045 posts
Joined: Sept. 2011
Offline
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
8837 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
User Avatar
Member
73 posts
Joined: July 2006
Offline
Hi, I've been trying to do various things related to this. I can get coordsys to do what I need but there is a note in the docs:

PARAMETERS
Space
The space to which the position should be transformed.

Karma supports paths to an xformable prim, or a camera. Also supported are Coordinate Systems.

Coordinate Systems works, as does a camera path but I haven't managed to get 'paths to an xformable prim' to work. Perhaps it's a syntax issue?

Attachments:
Screenshot from 2024-12-02 14-11-45.png (13.1 KB)

john @ goodbyekansas
  • Quick Links