Skip to content

Custom user chunks to customize lit / standard shaders #7632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Apr 30, 2025

  • 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:
Screenshot 2025-04-30 at 13 05 49

@Maksims
Copy link
Collaborator

Maksims commented Apr 30, 2025

This is amazing, as it will allow an easy injections into shaders!

@mvaligursky mvaligursky merged commit 133a99e into main Apr 30, 2025
7 checks passed
@mvaligursky mvaligursky deleted the mv-lit-user-chunks branch April 30, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants