question

Mina Ragaie avatar image
Mina Ragaie asked ·

Getting hair implicit uvs in a custom OSL shader

I'm trying to access the the implicit uvs of xgen curves exported to .ass from maya from a custom osl shader.

I'm trying to replicate the behavior of the maya ramp node in a custom OSL shader. It provides access to the implicit curve uvs (basically root to tip mapping). I've looked in the docs and found this:

https://support.solidangle.com/display/A5NodeRef/curves

I've exported 1 strand of xgen hair for testing as an ASCII .ass file and I reimported it in maya for testing

1- I don't see the uvs parameter mentioned in the link above in my .ass file.

2- getattribute("uvs", hair_uv); in my shader is returning 0.

3- The maya ramp seems to work regardless of the above.

As a side note: I'm also wondering if there is a shader in KtoA that can replicate the Maya ramp behaviour.

Thanks in advance!

shadersoslhairuv
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Mina Ragaie avatar image
Mina Ragaie answered ·

Cool! I don't see bu or bv in the exported ASCII .ass file. Are these implicit?

I've tried this in my osl shader with no luck.

float bv = 0.5;
float x = getattribute("bv", bv);
printf("%f \n", x);
out = bv;
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Zeno Pelgrims avatar image
Zeno Pelgrims answered ·

I think they're read from the geometry since they're in the shaderglobals: https://trac.solidangle.com/arnoldpedia/chrome/site/Arnold-5.0.2.0/doc/api/structAtShaderGlobals.html

10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Mina Ragaie avatar image
Mina Ragaie answered ·

Great! I got it to work using the "Utility" shader in maya and katana. that takes care of my immediate problem. I still need to get that data in a custom OSL shader.

Are barycentric coordinates calculated by the utility shader or read from the geometry?

10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Zeno Pelgrims avatar image
Zeno Pelgrims answered ·

You can replicate the implicit uv's of the ramp shader by feeding a flat utility shader set to the barycentric coordinates into the uv params. Not sure about the osl-side though.

10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.