Accessing RIS builtin Variables
Things that are accessible via the RIS GetBuiltin shading call are exposed in OSL via
getattribute("builtin", "varname", val);
unless they are already available via standard OSL globals. The following are available via this call (see the RixShading documentation for their definitions):
Note that the du/dv/dw/dPdu/dPdv values obtained this way during ray-traced hit shading will represent radius based differentials as used throughout RIS, instead of the usual diameter based differentials provided in OSL globals and via implicit differentiation via Dx()/Dy() calls.
OSL uses implicit differentiation to track the derivatives of variable where needed. RenderMan maps the x and y space of derivatives to the implicit u and v space of the underlying geometry. Implicit derivatives are used to control texture filtering, and can also be used to create new shading normals for bump-mapping. However, this only works if the original values coming from the renderer are "primed" with derivatives, because they must be computed along with the variables from those initial values, transformed through other mathematical operations, until they are used in a texture() or calculatenormal() call. The main place these derivatives will come from is the shader global P, and indeed prman primes this shader global with appropriate derivatives. Additionally, interpolated varying primitive variables on the geometry that are accessed with getattribute("primvar","primvarname",value), or simply just getattribute("primvarname", value) will have derivatives provided.