question

vlad streltsov avatar image
vlad streltsov asked ·

How to create an OSL shader that shows edge length on polygonal geometry?

Hi,

I would like to create an OSL shader that gives an edge length between vertices on any given geo.

Any help would be greatly appreciated.

-Vlad

osl
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.

Stephen Blair avatar image
Stephen Blair answered ·

Utility uses an API call that isn't available in OSL.

Can't you compute the edge lengths in Katana with an opscript and save that as user data on the object? Then shaders can get that user data to do stuff...

We can put together an example if you need it.

3 comments Share
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.

I wonder if I can do the same thing then.


Data channel modifier can cook up all kinds of things now that I think about it, there should be other ways to parse vertex array on an ID and conform it so we can read that id and some vector in some form and shape and syncronize OSL vector locations in the shader in a map (p) so we can drive implicit and hide source geo.

0 Likes 0 · ·

Hi Stephen,

Would it be possible for you to put together an example of such OP script?

Ultimately what we're trying to do is to show stretching of the vertices (the distance that a vertex travels over time) between "Pref" and "p" positions.

We have both Pref and p attributes in katana coming from geometry and all we need is to get edge length between those vertices to show how far they moved from the original position of Pref.

We're trying to do thins using an OSL shader, however if one can do this in an OP script that might work for us as well.

Thanks

-Vlad

0 Likes 0 · ·

I'll try to get you an example katana recipe with an opscript adding stretch/strain as user data.

0 Likes 0 · ·
Stephen Blair avatar image
Stephen Blair answered ·

What are you going to do with the edge length?

The Utility shader can get edge length, but I don't know if the same technique can be used in OSL. Will check it out.

Share
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.

Mads Drøschler avatar image
Mads Drøschler answered ·

Same thing applies here, we can't easily access the vertex set from OSL.

3 comments Share
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.

This seems strange, since an OSL shader can get any parameter from geometry.
OSL can get any parameters and user data that are available through getattribute().
https://docs.arnoldrenderer.com/display/A5ARP/OSL+Shaders

In katana one has access to Pref attribute as well as p attribute from geo, as well as which vertices are connected in one triangular polygon.

All we need is to get the edge length between each vertex.

Since we're not using 3d Studio Max, we should be able to get any attribute from a given geo.

-Vlad

0 Likes 0 · ·

This is what it says in the Arnold documentation.

"Standard attributes

Using the following attributes, if the getattribute() function specifies an objectname parameter, the value specific to that object is retrieved. If no specific object is named, the current object is implied."

Using this we can get Pref and p attributes from geo.

-Vlad

0 Likes 0 · ·

Alright, let me know how it goes.

Its not a concept I have got working through generic OSL.

0 Likes 0 · ·

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.