0
$\begingroup$

Im writing a fake pleochroism shader for a project.. I need to know the rotation of each "crystal axis" (the object's euler coordinates basically)

Right now Im currently using a driver to sample the rotation and feed it directly to the script via a combine xyz node.

enter image description here

The driver pulls directly from the object properties. (it automatically puts them in radians when the driver outputs to the shader editor)

enter image description here

This is NOT an optimal solution. Youd have to declare custom axis for every single isometric crystal and its rotation.... I want something that can be automated / calculated per object based off its internal properties..

From what I could tell on blender's site, theres no attribute or builtin property to reference the rotation... only location.

Im sure theres a mathematical way to get the rotations with the local and global position, but I dont know how I can do that honestly.

$\endgroup$

1 Answer 1

0
$\begingroup$

One way to acquire the object rotation, without the use of drivers, is to use geometry nodes:

enter image description here

I am reading the XYZ Euler rotation of the object, in radians, and outputting that as a vector attribute "rot"; I can then reference that attribute in my shader. Because I am reading the "original" object rotation rather than the "relative" object rotation (which would be zero), I am getting the world space rotation, which may or may not matter for your purposes.

This can be built into an existing GN modifier. Modifiers can be copied easily to any number of objects by link/transfer data -> copy modifiers.

$\endgroup$
1
  • $\begingroup$ I was more looking for a way to it within OSL, so I can make the material self-contained, but thanks still. It seems blender just cant do what I want right now. $\endgroup$ Nov 23, 2023 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .