Replies: 1 comment 3 replies
-
This is a really great proposal and a good initiative. Here are a few comments (including on stuff that we've already mentioned in the docs but are a bit under-specified):
Where does the 3delight expression
Should we attempt to define a set of queries for standard attributes in hair shading? Most hair generation systems have standard attributes for the position (current and reference) of the root follicle, colors, texture coordinates, etc ... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Common attributes standardisation proposal
Draft 1
Table of contents
Motivation
OSL has been tremendously successful at standardising shading but there are still non standardised areas, especially around each renderer’s internal nomenclature.
Although the same compiled shaders can run in any renderer, it is difficult in 2024 to write a shader that performs correctly in multiple renderers because each renderer names primitive attributes differently and may return some quantities in different spaces.
For example, if you wish to use the surface tangent:
getattribute("builtin", "Tn", tangent)
Vector tangent = normalize(dPdu)
Vector tangent = normalize(dPdu)
getattribute("geom:tangent", tangent)
Vector tangent = normalize(dPdu)
getattribute("myUVs", uvSet);
Vector tangent = normalize(Dx(uvSet));
1In this case, the shader writer hopes that u, v is not the parametric uv on meshes, otherwise dPdu may be non-smooth and pretty useless. But there is no guarantee.
Note
In the spec,
u
andv
are "The 2D parametric coordinates of P (on the particular geometric primitive you are shading)". WhendPdu
is usable, it means the renderer is computingdPds
/dPdt
instead ofdPdu
/dPdv
, and straying from the spec.Standard attribute names
Here is a list of proposed names for common attributes, inspired by various sources. Of course, some of these attributes should be computed on-demand, if possible.
Renderer Infos
Shader writers have no way to tell which renderer is executing our code. I think this would be useful as there are other types of discrepancies that need to be taken care of by shader writers, like the space in which some attributes are returned or the meaning of uv (face or mesh-wide coordinates ?).
This could be fixed by adding 2 standard attributes.
"osl:version"
Major*10000 + Minor*100 + patch
."shader:shadername"
"shader:layername"
"shader:groupname"
"renderer:name"
"renderman"
"renderer:version"
Major*10000 + Minor*100 + patch
.Camera
These attributes are already defined in the OSL standard, so this is just for completeness.
"camera:resolution"
"camera:pixelaspect"
"camera:projection"
"camera:fov"
"camera:clip_near"
"camera:clip_far"
"camera:clip"
"camera:shutter_open"
"camera:shutter_close"
"camera:shutter"
"camera:screen_window"
Geometry
Note
We should also standardize the space in which geometric quantities are returned. It should ALWAYS be
"common"
.Geometric Quantities
"geom:tangent"
"geom:undisplaced_P"
"geom:undisplaced_N"
"geom:reference_P"
"geom:reference_N"
"geom:reference_WP"
"geom:reference_WN"
Identifiers
"geom:id"
"geom:id2"
"geom:instance_id"
"geom:curve_id"
"geom:point_id"
classifications
"geom:is_mesh"
"geom:is_subdiv"
"geom:is_curve"
"geom:is_point"
"geom:is_volume"
Rendering
"stage:displace"
"stage:shade"
"hit:direct"
"hit:indirect"
"hit:roughness"
Footnotes
u,v are parametric, so dPdu and dPdv won't be smooth on meshes: need a uv set and compute its derivative. ↩ ↩2
I didn't define a bitangent attribute, as it is easily computed with N and T. ↩
Beta Was this translation helpful? Give feedback.
All reactions