u,v barycentric coordinates vs. map coords


philippe.groarke@...
 

Hello OSL gurus,
 
Currently, there seems to be a mismatch between DCCs' interpretation of the u, v global variables. For example, Blender seems to output the current triangle barycentric coordinates vs. 3ds Max outputs the uvmap1 coordinates.
 
Are the u, v variables supposed to be barycentric coords or map coords?
 
If the answer is map coords, can we get barycentric globals? They are quite useful.
 
Thanks,
Philippe


Stephen Friedman
 

What actually ends up in the u,v globals isn't dictated by OSL -- it's renderer-dependent "local parametric coordinates" and will often be whatever happens to be most optimized for that renderer's internal representation of it's geometry (and can even vary based on primitive types).  You'll likely have to dig into the documentation of the renderer in question to see if there's a way to get barycentric coordinates in your particular case -- if not in global u,v's, it'll likely be through some form of the getattribute() call for that renderer. If not made available, you could do something like add a uv-map that has face-barycentric coordinates baked in, though that may not be optimal.

--Stephen


Chris Kulla
 

It can vary depending on the renderer. I believe Arnold and 3dsmax use the texture coordinates, but Prman has historically used the surface parameterization.

Are you thinking you would need the barycentric coordinates of the tessellated triangle of the mesh? What use cases do you have in mind for those?



Sam Assadian
 

We also tend to use the  coordinate system  of implicit  primitive for u and v (for both Angie and Clarisse's classic renderer). We felt that was more logical. We also added s and t for the first UV map available (on the classic Clarisse renderer exclusively). FYI

Face
Sam Assadian
CEO / Co-Founder
Phone+33 972 452 846
Isotropix
LinkedIn YouTube Facebook Twitter

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.



On Tue, Dec 14, 2021 at 9:53 AM Chris Kulla <ckulla@...> wrote:
It can vary depending on the renderer. I believe Arnold and 3dsmax use the texture coordinates, but Prman has historically used the surface parameterization.

Are you thinking you would need the barycentric coordinates of the tessellated triangle of the mesh? What use cases do you have in mind for those?



philippe.groarke@...
 

It seems OSL is a bit less renderer agnostic than I was expecting. Is cross-DCC eval a goal of OSL, or are these differences expected/accepted? I couldn't find any info on an official way to get the current renderer, but that would help if OSL is expected to have these kinds of discrepancies. I'm thinking a standardized way to ifdef according to renderer (not sure how that would be standardized). Or even a runtime call would help for these edge cases.

@Chris To answer your question. Currently I'm experimenting with interpolating tangents in screen space (tbd if it ever works). This may be an Arnold thing, but its tangents (dpdu, dpdv) are per triangle. I need this to compute a surface curvature map using the jacobian eigenvalues. Overall I'd say barycentric coords are very useful for any type of screen space interpolation.

Take care,
Philippe