What is PBR and why do we want it in X3D? - michaliskambi/x3d-tests GitHub Wiki
This page is the 1st part (out of 3) of the Include PBR (PhysicalMaterial and related concepts) in the official X3D specification series. It describes PBR, how others integrate PBR, and the reasons behind it.
Table of Contents:
- What is Physically-based Rendering?
- Metallic-roughness terms
- Useful resources to learn about PBR
- Why do we want it?
- Compatibility
- Is this critical to include in X3D?
- Personal summary (Michalis)
- How does this affect my other proposals?
- Metallic-roughness or specular-glossiness workflow?
What is Physically-based Rendering?
It's a different lighting model. It uses terms like "albedo" (or, equivalent, "baseColor"), "metallic", "roughness".
In comparison, the current (non-PBR) Phong lighting model uses terms like "diffuse" and "specular". There is no simple 1-1 correspondence between these two lighting models. There is no automatic conversion possible -- equations are just different, neither is a generalization of the other.
Metallic-roughness terms
This image visualizes the meaning of "metallic" and "roughness" terms. (For the exact mathematical equations, see the glTF 2.0 materials specification.)
This image was made with an environment of uniform medium gray. An interactive version of this is available, where you can change the environment map.
This display was built using XSeen, which is built on top of THREE.js. Thank you to Leonard Daly for creating this!
Useful resources to learn about PBR
- https://www.marmoset.co/posts/basic-theory-of-physically-based-rendering/
- https://www.marmoset.co/posts/physically-based-rendering-and-you-can-too/
- glTF 2.0 materials use PBR:
- Unity3d:
- Unreal Engine: https://docs.unrealengine.com/en-us/Engine/Rendering/Materials/PhysicallyBased
- Sketchfab: https://help.sketchfab.com/hc/en-us/articles/204429595-Materials-PBR-
- Note that PBR is not a precise standard ( https://en.wikipedia.org/wiki/Physically_based_rendering ). If you're looking for a precise, mathematical equations about PBR, then just look at glTF 2.0 specification (above) or X3D proposal (below). And remember that other PBR implementations (Unity, Unreal) will use similar but not necessarily exactly the same terms.
- Links from x3d-public mailing list:
- Mail from Leonard Daly to x3d-public about glTF materials, linking to even more useful resources: http://web3d.org/pipermail/x3d-public_web3d.org/2017-September/007470.html
- Mails from Andreas Plesch about gltf and x3d: http://web3d.org/pipermail/x3d-public_web3d.org/2017-December/007921.html , http://web3d.org/pipermail/x3d-public_web3d.org/2017-December/007926.html
- http://www.pbr-book.org/
Paper presenting PBR in X3D
In the context of X3D, this paper proposes new X3D nodes PhysicalMaterial
and PhysicalEnvironmentLight
: "A unified GLTF/X3D extension to bring physically-based rendering to the web" (by Timo Sturm, Miguel Sousa, Maik Thöner, Max Limper) from the Web3D 2016 conference.
- https://dl.acm.org/citation.cfm?id=2945293
- https://instantuv.org/wp-content/uploads/2017/03/pbr2016.pdf
- The paper presents extensions to X3D and glTF 1.0.
- Andreas Plesch posted the most relevant excerpt from the above paper (and added useful links about implementation): http://web3d.org/pipermail/x3d-public_web3d.org/2017-December/007892.html .
If you don't have time to read all the above references, then read only this
- What is PBR: https://www.marmoset.co/posts/basic-theory-of-physically-based-rendering/ (and for nice examples what all these terms mean in practice, also https://www.marmoset.co/posts/physically-based-rendering-and-you-can-too/ )
- A concise summary how PBR could look like in X3D: http://web3d.org/pipermail/x3d-public_web3d.org/2017-December/007892.html
- A detailed information How to add PBR to X3D?
Why do we want it?
-
Looks better.
- Because it is more physically-accurate (although the mere usage of PBR equations doesn't make you physically-accurate, you still have to choose correct parameters for everything).
- Because "everything is shiny", which means that things have more realistic (and interesting) reflections. Typically, you need for this environment textures (cubemaps), which in the simplest case could be
ImageCubeMapTexture
(although of course could be alsoGeneratedCubeMapTexture
, if you want dynamic environment).
-
Is a standard:
- In glTF 2.
- In Unity3d 5.
- In Unreal Engine 4.
-
It can be easily used in other software too:
- Blender (although defaults still present Phong lighting model).
Compatibility
If we don't want to break backward compatibility, then the old Material
node must still be kept in X3D specification, along with it's lighting equations. Using PhysicalMaterial
instead of Material
is just an option for new models. So Apperance.material
is either Material
or PhysicalMaterial
.
It's not that weird having both PBR and non-PBR lighting models possible.
Unity3d has it too. Unity3d 5 still offers old (non-PBR) materials from Unity3d <= 4. It also does not convert non-PBR materials to PBR when importing a project (as there's no perfect conversion).
Is this critical to include in X3D?
Yes and no...
It is standard in some popular technologies (glTF, and at least two big proprietary game engines) nowadays.
That said, the old lighting model also still works, and is successfully used in existing applications (including games).
- For applications that don't strive to have maximum realism, PBR is not really critical.
- Unity3d 5 still offers old (non-PBR) materials from Unity3d <= 4. It also does not convert non-PBR materials to PBR when importing a project (as there's no perfect conversion). So the projects started in Unity 4 still use non-PBR materials, even if opened in Unity 5, unless you manually update all the materials (adjusting parameters) -- which is generally a substantial work for the graphic artist.
Personal summary (Michalis)
-
The old model (non-PBR) must be kept anyway. It is normal to have both non-PBR and PBR possible.
I do not think that X3D 4.x can break backward-compatibility, like glTF 2.0 did. We have more history, more data to preserve.
So we should do it like Unity: new models can use PBR (but do not have to). Existing models keep using non-PBR if you don't manually update them.
-
The new model (PBR) is well-researched and specified. We have glTF spec, we have spec how to do it in X3D.
The new model (PBR) is the way of the future, but I think no-one will stop using X3D because it has non-PBR materials as of today (early 2018). As long as we will make it clear that we plan to incorporate PhysicalMaterial
in the near future. I'm fine with deferring it for X3D 4.1 (not doing it for X3D 4.0), if we officially acknowledge that we want it in 4.1, and we have a proposition how it could look like: "We plan to include PhysicalMaterial
in X3D 4.1. In the meantime, this is how it will probably look like: " ... and point people to the paper A unified GLTF/X3D extension to bring physically-based rendering to the web (or maybe to this wiki page -- I'm trying to document here consensus reached on x3d-public).
This is sensible because:
- X3D 4.0 is taking time to be released. Let's not burden it more than necessary.
- X3D 4.0 may include glTF support for meshes. It seems reasonable to integrate X3D with glTF incrementally:
- X3D 4.0 allows to use glTF for meshes (using
ExternalGeometry
, like X3DOM is already doing). - X3D 4.1 allows to use glTF for lighting too (using
Inline
). - This allows existing X3D implementors to also incrementally integrate with glTF.
- X3D 4.0 allows to use glTF for meshes (using
How does this affect my other proposals?
-
The need for
CommonSurfaceShader
(see Include CommonSurfaceShader in the official X3D specification) is no longer critical. (Assuming that we want to encourage everyone to switch to PBR eventually, like glTF does.) Many features ofCommonSurfaceShader
extend the Phong lighting model, and have no use for PBR model.But note that some features of
CommonSurfaceShader
are useful for all lighting models: normalmaps, displacement maps. PBR still benefits from normalmaps, just like Phong lighting model. So we should "extract" these features and allow them in some new way. So normalmaps should be specified outside ofCommonSurfaceShader
, outside ofMaterial
, outside ofPhysicalMaterial
. Displacement maps can probably be rejected for now from the X3D spec (only X3DOM implements them).The answer to this question is dealt with more detail in How to add PBR to X3D?.
Here, in summary:
-
To upgrade the Phong lighting model, let's extract from
CommonSurfaceShader
useful concepts, likediffuseTexture
,specularTexture
,emissiveTexture
, and add them to the normalMaterial
. This will also makeMaterial
consistent with PBR'sPhysicalMaterial
, asPhysicalMaterial
already does incorporate mechanism to parametrize everything using textures (albedoFactor
,albedoMap
). -
We need to invent a way to add normalmaps (and maybe displacement maps) for
PhysicalMaterial
, as the need for normalmaps is the same for old and new (non-PBR and PBR) lighting models. X3D standard currently does not allow to reliably provide normalmaps (without writing your own shaders), which is a pity -- normalmaps are an absolute norm in modern 3D content creation.CommonSurfaceShader
was a solution for this, but only in case of non-PBR. If we want to include normalmaps for both non-PBR and PBR, we need to design a new solution for this. For starters, I propose a new simple field on Appearance likeAppearance.normalMap
, like this view3dscene/Castle Game Engine extension: https://castle-engine.io/x3d_implementation_texturing_extensions.php#section_ext_bump_mapping
-
-
The need to Make RGB and grayscale textures treatment consistent remains.
-
Although the problem described there (inconsistent RGB and grayscale texture treatment) applies only to the old lighting model, it still remains, since the old lighting model stays. Existing browsers treat it inconsistently, let's make it consistent in X3D 4.0.
-
Of course, let's not repeat the same mistake when designing PBR model. Let's make RGB and grayscale texture treatment consistent, from the start, in PBR workflow. If we just use the same equations as glTF, we'll be fine.
-
Metallic-roughness or specular-glossiness workflow?
There are actually two ways to express PBR parameters, the
- metallic-roughness
- specular-glossiness
The 2nd version (specular-glossiness) has parameters that resemble the Phong model a bit more, and may be easier to upgrade (so Phong lighting model -> PBR with specular-glossiness parameters). But it seems that it only means "easier to upgrade for a graphic artist", and not "so easy to upgrade that it can be done automatically".
See e.g.
- https://jmonkeyengine.github.io/wiki/jme3/advanced/pbr_part1.html about the pros/cons of each model.
- https://instantuv.org/wp-content/uploads/2017/03/pbr2016.pdf mentions both these approaches.
- https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html shows both workflows in Unity PBR (standard) material.
However, it seems to me that X3D should adopt the "metallic-roughness" model of PBR. Reasons:
-
This is what glTF did. That's the most important reason. glTF only uses the metallic-roughness version. So if we want easy and perfect interoperability with glTF 2.0 (and I think we should), then we need to also adopt the metallic-roughness version, or (like e.g. Unity3d) allow to choose between metallic-roughness and specular-glossiness .
-
Allowing both PBR models (metallic-roughness and specular-glossiness) means more complication in the spec. If the glTF decided that only metallic-roughness is enough, then it's likely also true for X3D.
-
Even though Unity allows to choose between these two approaches, they still do not convert non-PBR materials to PBR with specular-glossiness. This suggests that the automatic conversion is not possible, at least not in a way that would be acceptable to all the models in the wild.
-
Some more arguments are in https://jmonkeyengine.github.io/wiki/jme3/advanced/pbr_part1.html (see the "pros" / "cons" in "Metalness workflow" / "Specular workflow" there. To me, it seems that the metallic-roughness workflow is a winner: less texture space, easier color concept. The only advantage of specular-glossiness is that it allows easier upgrade for graphic artists, but since this upgrade cannot be automated anyway, this advantage is not big.
Also note that in X3D standard (if you don't consider
CommonSurfaceShader
, which is not a standard node), there is no way to specify specular maps in X3D. So upgrading from "Phong lighting model -> PBR metallic-roughness" may pose a similar difficulty as upgrading "Phong lighting model -> PBR specular-glossiness" for the artists. TODO: This is something that would be nice to check in practice, of course. I hope to check it once I implement PBR in view3dscene/Castle Game Engine.