engine
engine copied to clipboard
Remove BasicMaterial and allow better ways to create custom shaders using ShaderMaterial
Current status
BasicMaterial is a simple engine-provided material with the following key aspects:
- it generates low cost shader which supports skinning, morphing, vertex colors and a single texture with fog and picker compatibility
- it does not support lighting and does not provide a way to add a simple lighting, nor it provides a way for users to customize the generated shader
- does not support VSM shadows https://github.com/playcanvas/engine/issues/3298
- internally the engine and the Editor only use it to render lines, which is trivial to replace: https://github.com/playcanvas/engine/pull/6834
Plan for engine 2.0.0
The plan is to remove BasicMaterial from the engine. There are two replacement paths, one existing and one which will require some further work.
StandardMaterial
StandardMaterial can be used as a complete replacement, when using emissive texture slot with vertex format. It handles all features of the BasicMaterial (and many more), and generates code with very similar / same performance. It is exposed in the Editor inspector / Editor workflow. This should be the main replacement path for users not requiring custom modification.
ShaderMaterial
This is an under development material / shader system allowing users to use custom shaders, by providing a custom shader source code, which the engine implements or helps user to implement additional features. Main features / unfinished work:
- [x] internally, the shader code processing in the engine now supports
#include
pragma, allowing an existing shader chunks to be included in the custom shaders. Currently this is used to allow user to easily handle gamma / tone-mapping and fog. - [x] support for handling of render passes was added here https://github.com/playcanvas/engine/pull/6831
- [x] support for (semi)automatic shader support with skinning and morphing should be added https://github.com/playcanvas/engine/pull/6855
- [x] shader defines https://github.com/playcanvas/engine/pull/6865
- [ ] easier support to handle shadow pass needs to be added, using
#include
- [x] easier support to handle picker pass needs to be added, using
#include
https://github.com/playcanvas/engine/pull/6856 - [ ] support by the batching
- [x] write an engine example demonstrating most the these features
When this is done, it will give users an option to create a custom look shader, which can be skinned, which will handle tone-mapping and fog and many other features, opening a way for custom looking applications (targeting mostly non-photorealistic games here)
I look forward to a feedback here.