Draft 1
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:
Renderer | OSL call |
---|---|
RenderMan | getattribute("builtin", "Tn", tangent) |
Arnold | Vector tangent = normalize(dPdu) |
Vray | Vector tangent = normalize(dPdu) |
Cycles | getattribute("geom:tangent", tangent) |
RedShift | Vector tangent = normalize(dPdu) |
3Delight | getattribute("myUVs", uvSet); Vector tangent = normalize(Dx(uvSet)); 1 |
In 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
and v
are "The 2D parametric coordinates of P (on the particular geometric primitive you are shading)". When dPdu
is usable, it means the renderer is computing dPds
/dPdt
instead of dPdu
/dPdv
, and straying from the spec.
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.
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.
These attributes are already defined in the OSL standard, so this is just for completeness.
Note
We should also standardize the space in which geometric quantities are returned. It should ALWAYS be "common"
.
Attribute | Type | Description | |
---|---|---|---|
"geom:tangent" |
vector | The normalised surface tangent 12. | |
"geom:undisplaced_P" |
point | The surface position before displacement. | |
"geom:undisplaced_N" |
normal | The surface normal before displacement. | |
"geom:reference_P" |
normal | The surface position in reference pose in object space. | |
"geom:reference_N" |
normal | The surface normal in reference pose in object space. | |
"geom:reference_WP" |
normal | The surface position in reference pose in world space. | |
"geom:reference_WN" |
normal | The surface normal in reference pose in world space. |