OSL getAttribute from Custom Attribute

OSL getAttribute from Custom Attribute

sijo_animech
Contributor Contributor
148 Views
4 Replies
Message 1 of 5

OSL getAttribute from Custom Attribute

sijo_animech
Contributor
Contributor

I'm trying to get Custom Attributes (located on an Attribute Holder modifier) via OSL. The docs only mention that User Defined Properties can be accessed using the usr_xxxxx prefix. However, I want to use Custom Attributes, not User Defined Properties.

 

Does anyone know if Custom Attributes are accessible via OSL, and if so, how?

0 Likes
149 Views
4 Replies
Replies (4)
Message 2 of 5

MartinBeh
Advisor
Advisor

I doubt OSL has direct access to Custom Attributes but you might be able to feed the Custom Attribute value into an input slot of your OSL shader, using SME nodes.

What values does your Custom Attribute contain?

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 3 of 5

sijo_animech
Contributor
Contributor

My Custom Attributes is just a float value. I want to control an edge-rounding shader, where I set a radius per object. The only way I've managed to do it until now is via User Defined Properties, where I manually write like corner_radius=0.02 and then use the built-in OSL Map Named Attribute to fetch the value. However, User Defined Properties don't scale well, and are prone to errors. CA's would allow me to set the radius on an Attribute Holder modifier, which is a much nicer workflow.

 

How would I access the CA values using SME? I played around with float controllers before but couldn't get it to work. 

0 Likes
Message 4 of 5

MartinBeh
Advisor
Advisor

Sorry, I was mistaken - Float Controllers is what I had in mind but they will not give you "per-object" values but rather "per-material" or "per-scene" values...

FWIW: You could try to add code to the CA to auto-set the User Defined Properties value when you change the CA value...?

 

PS: I'd be interested to learn how you do a rounded-edge shader in OSL?

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 5 of 5

sijo_animech
Contributor
Contributor

Yeah, that's the problem I was running into before.

Interesting idea. I've been experimenting with a similar idea, but in the form of a custom modifier that sets User Defined Properties. I've gotten it to work well enough, where it reads and writes properties, handles instances, etc. However there are still issues regarding copy-pasting the modifier, deleting it, toggling it on and off, etc. I'll have a look at implementing this on a CA and see if that can solve any problems.

 

Sorry, the edge rounding shader is not actually OSL - it's a VRayEdgesTex map. I just use the OSL Named Attribute map to get the radius value and plug it into the radius multiplier slot on the VRayEdgesTex map.

0 Likes