-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Allow ShaderChunk overrides in materials (feature request/idea) #13364
Comments
Have you checked out There is also an example that illustrates the approach: https://threejs.org/examples/webgl_materials_modified.html |
@nhalloran
It seems intuitive and natural that you would pass bits, or chunks of data into the material. Even the name
It's very unlikely that |
Please use |
I know that the challenge of customizable materials has been discussed quite a bit, but here is a feature I would love to see to that end. I've included proposed (incomplete) code changes, and I could try doing the PR, but I am not sure if the idea is well conceived.
Problem:
I often run into situations where I want to use an existing material, e.g.
THREE.MeshPhongMaterial
and modify the shaders. Rebuilding such materials from scratch as aTHREE.ShaderMaterial
is cumbersome, but my current solution.This tool I found allows you to insert code into existing shaders, which is nice, though a bit hacky.
https://www.npmjs.com/package/three-material-modifier
But in some cases I would like to modify a line or more.
Proposed Solution:
Materials allow a
shaderChunks
argument to be passed, which is an object containing glsl strings that overrideShaderChunks
used byShaderLib
. For example:Implementation
I started making some changes to see how hard it would be:
nhalloran@7795a9a
nhalloran@44d35a5
But a tricky part would be the handling the
#include
s in the ShaderLib directoryhttps://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderLib
I'm not exactly sure how those are built....
Would love feedback before going any further towards a PR.
The text was updated successfully, but these errors were encountered: