SolvedglTF [PBR extension] Provide example implementation and specify (suggested) shading model

We need and simple, yet expressive reference application, and especially example shader code for reference.
Also, the shading model we use must be very concretely defined in either the spec or in the appendix, being a suggested shading model.

This also involves to create corresponding, extensive documentation in the spec, especially about the concrete shading model and exact behaviour / semantics of parameters.

42 Answers

✔️Accepted Answer

I just built a simple PBR example in Three.JS, using a basic custom shader without any textures (following the suggestion of @erich666) - the result should exactly match with the one obtained using THREE.MeshStandardMaterial. The shader code is reduced to the necessary parts though, I also did some formatting and added comments to make it a bit more readable. The application shows a matrix of spheres with varying "roughness" / "metalness" values.

Here's the first result:
tsturm@e0e419a

And here's a screenshot:
metalness-roughness

The shader shows that the lighting computations use Lambert for the diffuse term. For the cook-torrance specular computation, they use GGX Distribution, Schlick Fresnel and Smith for the Geometry term. Having this example code and the appendix of the draft spec, we could now check how well the example aligns with the proposed formulations, and adapt the code and formulas according to what we believe should be correct and best-suited for the use within glTF. Finally, imagery generated by the example application(s) could then also be used to illustrate the impact of the different parameters.

@emackey @erich666 What do you think, does that make sense?

Other Answers:

There are references implementation well documented:

There is no only one way to write PBR shader so if we provide an example / code sample we will need to choose one implementation.

I have updated my workflow conversion page with updated math for specular-glossiness energy conservation, merged @mlimper's environment map changes, and improved the specular-glossiness to metallic-roughness conversion.

https://bghgary.github.io/glTF/convert-between-workflows/

It should match better now.

Related Issues:

5
glTF [PBR extension] Provide example implementation and specify (suggested) shading model
I just built a simple PBR example in Three.JS We need and simple yet expressive reference applicatio...