Community
Arnold for Katana Forum
Rendering with Arnold in Katana using the KtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

9 REPLIES 9
Reply
Message 1 of 10
vlad_streltsov
526 Views, 9 Replies

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

Tags (1)
Labels (1)
  • OSL
9 REPLIES 9
Message 2 of 10
madsd
in reply to: vlad_streltsov

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

Message 3 of 10
vlad_streltsov
in reply to: madsd

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

Message 4 of 10

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

Message 5 of 10
madsd
in reply to: vlad_streltsov

Alright, let me know how it goes.

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

Message 6 of 10

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.



// Stephen Blair
// Arnold Renderer Support
Message 7 of 10

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.



// Stephen Blair
// Arnold Renderer Support
Message 8 of 10
madsd
in reply to: Stephen.Blair

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.

Message 9 of 10

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

Message 10 of 10

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report