AcademySoftwareFoundation / OpenPBR

Specification and reference implementation for the OpenPBR Surface shading model
Apache License 2.0
425 stars 18 forks source link

Clarify handling of rays incident to the surface from the interior #110

Closed portsmouth closed 3 months ago

portsmouth commented 11 months ago

Currently we don't say much about how the model deals with the difference between rays exiting and entering the surface. This has to be handled in a renderer (at least one which tries to correctly render glass objects with a coat/fuzz, for example) so we should clarify this.

For example consider the case of a glass object, with a coat and fuzz. Rays entering from the exterior (i.e. the ambient dielectric medium) will enter through the fuzz, then the coat, then transmit into the base glass.

Rays which hit the surface from the interior of the glass (having refracted into the glass at some earlier point in the path) instead hit the bottom side of the coat, then the fuzz, then transmit into the ambient medium:

image

The physical effect of the layers differs in these case. For entering rays:

While for rays which are exiting:

However in Standard Surface (and MaterialX), we make no attempt to account for this in our albedo-scaling approximation of the layering. The Arnold implementation currently uses a rather crude approach where the normal is flipped so the surface always thinks the ray is entering 🤦‍♂️ (Then we have to use some messy logic to make nested dielectrics work despite this).

In reality there is kind of a symmetry between entering and exiting. In both cases the ray transmits from one external dielectric medium to another, via some intervening interfaces and layers of media, which we know. A sufficiently powerful layering formalism/system should be able to compute (within some reasonable approximation) the BSDF accounting correctly for this. It is possible to write down an albedo scaling approximation of this which looks symmetric, for example (which I didn't attempt in the spec).

It is probably too much detail for us to elaborate on this in the spec (at least at this stage), but I think we should at least discuss what would need to be done to correctly model the physics.

(Note, @iliyang and I discussed this issue previously in relation to Standard Surface).

portsmouth commented 11 months ago

A related issue is how we deal with rays which are exiting from the surface when the surface is locally (e.g.) a metal.

Arguably one can make sense of this by assuming the metal must be a thin sheet of foil covering the interior dielectric, so we would reflect from this foil back into the interior. This would allow for rendering of e.g. bottles with metallic labels, with the label visible through the glass (without the need for modelling a separate label).

In general though the interior properties are (currently) ill-defined if different parts of the surface specify different base interiors (i.e. metal, diffuse, subsurface, volume, or a mixture thereof). For the moment it probably has to remain implementation-dependent how this is handled. In the spec we just say something vague about the implementation "doing the best it can to make sense of it":

This physical picture of the mix operation becomes somewhat unrealistic in some cases where the bottom-most bulk materials being blended are not obviously consistent (e.g. blending dielectric and metallic bulks), but in such cases it is understood that the implementation should do the best it can to make sense of the physics (e.g. the metal bulk could be considered to actually be surface metallic flakes on top of a single consistent dielectric).

portsmouth commented 6 months ago

I think the effects I described are implicit in the physical description, so we don't need to elaborate on them. Implementations typically won't bother modeling these, but in future renderers which e.g. do full MC light transport in the layer structure, they might attempt it.

I could perhaps add a couple sentences to the spec noting that the entering/exiting rays encounter the layers in different order, which in principle should be accounted for in the layering math, but it isn't strictly necessary.

peterkutz commented 5 months ago

A related issue is how we deal with rays which are exiting from the surface when the surface is locally (e.g.) a metal.

Arguably one can make sense of this by assuming the metal must be a thin sheet of foil covering the interior dielectric, so we would reflect from this foil back into the interior. This would allow for rendering of e.g. bottles with metallic labels, with the label visible through the glass (without the need for modelling a separate label).

This still seems like the best way to reason about the meaning of a mixture of metal and transmission to me. If the surface is being hit from the inside, then the bulk must have been transparent, so the metal must be a foil on top of the surface.