3dTim
May 21, 2025, 3:14pm
1
What if a project depends on overriding the beginning of the main function? Does that mean it can’t use engine v2.6+ until the replacement chunk is implemented in a future engine version?
playcanvas:main
← playcanvas:mv-lit-shader-code
opened 05:20PM - 27 Feb 25 UTC
- further lit-shader refactoring. `main` function of it is a single string now, … and will be moved to a chunk in the future. This will be so much easier to read what is going on.
<img width="559" alt="Screenshot 2025-02-27 at 17 21 47" src="https://github.com/user-attachments/assets/b1eb0892-94ac-4b4d-a517-c3df25009e49" />
removed chunks:
```
startPS
```
Correct.
Luckily, the replacement is ready, and will be out sometimes next week (2.8)
playcanvas:main
← playcanvas:mv-lit-user-chunks
opened 12:01PM - 30 Apr 25 UTC
- removed private and non-functional `StandardMaterial.customFragmentShader`
- … added custom empty chunks allowing vertex and fragment shader of `StandardMaterial` and `LitMaterial` to be customized:
```
litUserDeclarationPS: '', // empty chunk allowing user to add custom code
litUserDeclarationVS: '', // empty chunk allowing user to add custom code
litUserCodePS: '', // empty chunk allowing user to add custom code
litUserCodeVS: '', // empty chunk allowing user to add custom code
litUserMainStartPS: '', // empty chunk allowing user to add custom code
litUserMainStartVS: '', // empty chunk allowing user to add custom code
litUserMainEndPS: '', // empty chunk allowing user to add custom code
litUserMainEndVS: '', // empty chunk allowing user to add custom code
```
These are included into existing shader chunks, either at the very start of the shader, just before the main function, and also at the start and end of the main function, which should cover most common places to inject code (apart from replacing existing chunks)
- also created new chunk `litMainPS` (similar to existing `litMainVS`) which is the single entry point to fragment shader for all passes, removing any hardcoded parts. As long as the user knows this is the entry point, they can follow the rest of the shader from there:
<img width="395" alt="Screenshot 2025-04-30 at 13 05 49" src="https://github.com/user-attachments/assets/57de8181-b893-4035-88de-d657f6fa376b" />
1 Like
3dTim
May 21, 2025, 4:05pm
3
Thanks for the info. I’m trying to wrap up a migration to 2.6. Preliminary testing indicates that overriding the chunk litForwardMainPS works, at 2.6.
1 Like