-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Custom shader support for WebGPURenderer #26719
Comments
WebGPU uses WGSL rather than GLSL, so code like what you've linked to is not going to work with WebGPURenderer. We do not, to my knowledge, plan to transpile shaders from GLSL to WGSL. A WebGPU-compatible version of troika should probably use the NodeMaterial system, either by linking a node graph declaratively or by writing code in ShaderNode (see #22603). Shaders defined in this way should be supported in both WebGL and WebGPU. I don't know the plan for /cc @sunag |
AFAIK, there was no plan to support There is no support for |
All the node materials allow various parts of the shaders to be overridden and the base NodeMaterial allows overriding the default vertex and fragment code flows entirely, so there should not be any problem implementing equivalents. This should be a lot more reliable that using onBeforeCompile() where you rely on the shader code remaining consistent over releases. |
Ok sorry to waste your time. I'll look into it. So the shader in MeshBasicMaterial isn't even used or converted. So NodeMaterial can be used for WebGLRenderer also and it converts it back to the shader it needs ? I'll look into it to my bmfont fork first. |
No it isn't.
The idea is to always use |
Sounds like it's being setup how I was asking. Trying to look at the node thing now for the bmfont basic shader for now for text rendering. However they still yet have a WebXR proposal for webgpu yet sadly. It's all theoretical still. |
Description
I'm not sure where to put this. There seems to be some portability issues between WebGL and WebGPU as far as custom shaders in materials go. I found a problem rendering troika text in webgpu rendererer. Which is manipulating the shaders of MeshBasicMaterial within
onBeforeCompile
.onBeforeCompile does not run with WebGPURenderer.
https://github.com/protectwise/troika/blob/main/packages/troika-three-text/src/TextDerivedMaterial.js#L75
https://danrossi.github.io/three-troika/test/webgpu_text.html
I'm trying to get my own modified bmfont shaders that were previously using RawShaderMaterial but this material isn't supported with WebGPU renderer. So all my RawShaderMaterial setups have to be changed to something else.
https://github.com/danrossi/three-bmfont-text/blob/8a82f08a3629e00ca6865f24791dd93f66705383/src/shaders/MSDFShader.js#L43
Should these be converting automatically like what is happening by default with MeshBasicMaterial or is there a requirement to build some node system after webgpu feature detection instead ? So requiring setup material setups for different renderers ?
I can see portability issues between rendererers. I noticed WebGPURenderer now falls back to WebGLRenderer internally so should hopefully accept
onBeforeCompile
or WebGLRenderer support the undocumented nodes system to build shaders so there is only one setup needed.Solution
A uniform way to modify MeshBasicMaterial shader or a custom shader for both renderers. Hopefully this is not confusing.
Alternatives
na
Additional context
#protectwise/troika/issues/264
The text was updated successfully, but these errors were encountered: