-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KHR_materials_volume #1726
KHR_materials_volume #1726
Conversation
Very nice start. For realtime rasterizers, I feel that it is necessary for this extension to support a thickness texture. It’s very difficult, in practice, to make rasterizers efficiently render volumetric properties of a closed mesh. It’s not impossible, of course, and some viewers (like ours at Adobe) may opt to go this route if that is a critical feature but, in general, performance-minded game engines aren’t going to support this. Thickness textures allow you to very efficiently define thin volumes like panels of glass. For example, the window panes of an old building where the glass at the bottom is thicker and rippled. Modeling this (and rendering this) as a volume is far more difficult and costly. So, I suggest a dual-mode extension where either thickness is defined or the true volume of the mesh (must be closed) is used. The thickness texture would be accompanied by min/max scaling factors to scale the 0-1 texture values. A constant thickness could be defined by just supplying the min factor and no texture. A boolean flag (or maybe just the presence of the min/max values) could indicate that the thickness mode should be used. Here are some more thoughts related to this:
|
For this reason a thickness texture would also make sense for ray tracers. We have to be a bit careful how the thickness is interpreted so that it works for path tracing, light tracing, and rasterizers. The following definition should work: The material can be either thin-walled or volumetric, the user has to choose via a Boolean parameter. Thin-walled means that the mesh geometry defines two surfaces: the actual surface and a "virtual" surface underneath that is not modeled, but implicitly given by the thickness texture. This applies to both closed and non-closed meshes. Non-closed meshes could be rippled windows, leaves, ... Closed meshes could be light bulbs, ... Volumetric means that the mesh geometry defines a surface boundary. The mesh has to be closed. It is possible to have nested closed objects, which could make them hollow like thin-walled closed meshes, but I guess that's a rare case. In the volumetric case, a thickness texture can (or must) be provided to help rasterizers render the volumetric properties. Ray tracers will ignore the texture. That means that the texture must not be used for artistic effects, it is basically an automatically generated texture, the "baked" volume thickness at each surface point. Please tell me what you think about it, I will update the document accordingly.
That's a good question. sigmaT should probably be given in world space, because I am not sure if applying non-uniform scaling to the distance works well...
I'd suggest attaching priority values to shapes/nodes in the scene graph that determine which of several overlapping objects "wins". The technique is described in this paper, and I think a lot of ray tracers implement it like this. Not sure if this is really a problem we can (or have to) solve for rasterizers. I am afraid I don't have answers to the other questions, maybe others with more experience in rasterization and glTF have thoughts on it. |
Okay, so the two modes would toggled with a boolean and would work like this?
Is that right? |
Do you think we could add some more information about how the single-scatter albedo and attenuation coeff are used to calculate the colour of transmitted light? |
Yes. It is just an idea at the moment, I don't know it if works well. The volumetric part with participating media inside the volume boundary should be easy. The tricky part is the thin configuration: the combination of thin, rough transmission with the dipole approximation.
Of course. I think this will mostly be important for thin materials. The implementation for volumes/homogeneous participating media should use brute-force SSS as reference solution. Maybe we can shortly describe the algorithm (sample distance according to attenuation coeff, weight with albedo, sample phase function and spawn scatter ray), but there is probably enough literature out there that we don't have to go into details for ray tracing. If you already have ideas, it would be great if you could add it to the PR. |
The more I think about the idea, the less I like it. Maybe we should concentrate first on the volumetric part and keep thin-walled for later. I looked at a few ray tracers (V-Ray, Corona, Arnold, Maxwell, Iray, ...) and they all seem to require properly modeled volumes for random walk SSS. Although we might be able to come up with a good solution for thin-walled with thickness textures, it won't help if the renderers out there do not support it... |
I understand the concern. The problem is, glTF is mainly used (and intended) for real-time rendering. An extension that only supports closed volumes might not get much support. A related question about SSS; I know that this extension can be used for SSS but, in realtime, there are usually SSS approximation techniques that don't involve complex transparency or refraction. Do we leave it up to the runtime to fallback to these approximations when the scattering parameters hit a certain threshold? Or do we define a separate SSS extension for the explicit purpose of real-time SSS? |
Yes, I agree. To sum up:
Renderers can now freely choose between the two representations. Ray tracing uses the mesh. Real-time could use the mesh (some depth map and shadow map based volume approximations) or the thickness map. This will give us consistent renderings in real-time and ray tracing. Did I miss anything? If not, I will go on and add the parameters to the document.
I am also unsure about that. A separate extension which limits the range of supported effects to SSS would certainly help real-time renderers, but on the other hand it adds redundancy. |
I'm not sure about the "make closed meshes mandatory" part. For commerce-related assets it might be fine (assuming those assets are CAD or not created for realtime initially anyway) but, for game assets, I'm not sure that it's reasonable to expect every pane of glass to have two sides and an appropriate thickness. If we don't want an explicit flag for this, perhaps having a closed mesh is a suggestion and not a requirement in the spec? |
Maybe this use-case can be covered by KHR_materials_transmission extension alone? If KHR_materials_volume is not enabled, the surface is automatically thin-walled and, therefore, doesn't require closed meshes. The volumetric effects in a thin glass pane can be squeezed into effects on the surface. Absorption becomes the surface color (transmission only). Roughness can be used to build ground glass. Milk glass can be achieved with a combination of these effects and, if needed, a clearcoat layer. A thickness texture is not needed in these cases: thickness will influence surface color and roughness, so it can be baked into the base color texture and the roughness texture (saving texture lookups and computations in the shader). |
caea754
to
81e157c
Compare
Need to merg with #1766 |
Added suggested changes and removed references to KHR_materials_translucency |
extensions/2.0/Khronos/KHR_materials_volume/schema/glTF.KHR_materials_volume.schema.json
Show resolved
Hide resolved
…terials_volume.schema.json Co-authored-by: Ed Mackey <elm19087@gmail.com>
- Remove explicit unit info 'meters' - Add node/world space info
@emackey @proog128 Just to flag that while this extension appears to be nearing consensus, there are still several un-resolved comment threads in this PR. I say "unresolved" in the sense that the GitHub "Resolve Conversation" button has not been pressed; whether the questions were resolved elsewhere I'm not sure. The definition of |
@donmccurdy Thanks for bringing this up! From my point of view all conversations are resolved and the button could be pressed. Not sure what the others think? The wording may be improved though. If I remember correctly, we settled on the following behavior:
So maybe the following is less ambigous:
|
I'm trying to resolve the appropriate attenuation settings for the hanging amber beads in the StainedGlassLamp asset. glTF Sample Viewer screenshot: Dimensions of the beads model, in z-up coordinate space. The node has no additional transform in glTF, it should be 1-to-1. Dimensions of a single bead (although all the beads are actually in a single mesh in the glTF): The current material. I'm just not sure what to use for thicknessFactor and attenuationDistance. So if I want the beads to show some attenuation on the thickest beads, would I use something like this? I'm not using a thickness texture, thus I don't have per-texel values to scale, so I would want the mesh itself to determine thickness. In other words, I want the thickness to be per-bead. Is that right? |
@echadwick-wayfair The thicknessFactor tells the renderer how large the geometry is, so the 0.013 must go into the thicknessFactor. A ray tracer would ignore this value, because it can infer it from the mesh. A rasterizer needs a correct thickness. It's crucial that the thicknessFactor matches the actual thickness of the geometry, otherwise the renderings will be inconsistent between rasterizer and ray tracer. Once thickness is set up, you can adjust the attenuationDistance and attenuationColor such that it has the intended look. |
extensions/2.0/Khronos/KHR_materials_volume/schema/glTF.KHR_materials_volume.schema.json
Outdated
Show resolved
Hide resolved
Based on the feedback from yesterday I tried to improve the description of attenuation distance and the section about the thickness texture. Please have another look and let me know what you think. |
Looks good to me. Thanks! |
Thanks for the changes, the thicknessTexture is easier to understand now! |
For the "Scales with the transformation of the parent node(s)" part, should the spec indicates how to derive the final value from the x/y/z scaling values of the parent node(s)? In the non-uniform scaling case, should we take Adding @emackey and @MiiBond as there is a discussion about this here |
extensions/2.0/Khronos/KHR_materials_volume/schema/glTF.KHR_materials_volume.schema.json
Outdated
Show resolved
Hide resolved
We'll add a non-normative note discouraging folks from using nonuniform scales. That can go in a new PR when it's ready. Merging this. Status will remain "Draft" for at least a few more weeks, but it will be hosted in the main glTF repository. |
An extension for the metallic-roughness material that adds volumetric parameters for effects like refraction and subsurface scattering. It requires
KHR_materials_transmission
(#1698) and should be combined withKHR_materials_ior
(#1718). At the moment, it lacks a suitable model and parameters for rasterizer implementations.