Qt Quick 3D - Custom Materials Example
Demonstrates writing shaded custom materials.
The custom material implemented in the example has its shadingMode property set to CustomMaterial.Shaded
. This means that rather than providing a completely custom snippet to serve as the vertex and fragment shader main function, the shader snippets provide multiple functions that are then invoked by the shader code generated by Qt. This way the resulting material participates in lighting, shadow mapping, and is compatible with light probes.
The objects in the scene all have a CustomMaterial on them. Yet, they take the lights in the scene into account, can receive shadows, and can also generate useful rendering results when the SceneEnvironment has a light probe set. This is achieved by effectively augmenting the shader code that would be generated for a PrincipledMaterial with our own custom functions that get called at certain stages in the vertex and fragment shaders.
This example is the counterpart to the customshaders example, which demonstrates the other group of custom materials: unshaded custom materials that provide most of the vertex and fragment shader code on its own.
Files: