-
-
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
Need a Raw Shader solution for WebGPURenderer #29781
Comments
One of the main advantages of TSL is that we are doing things so that the shaders communicate without hacks, and work on multiple backends , which will allow your codes to be easily added to third-party projects without breaking due to any update or respecting any optimizations and changes made in the library. TSL is not only about shader language, TSL is also related to rendering manipulation, so we won't see functions like
The groups are controlled by the system and allow customizations to be made in a simpler way when using TSL using
The first official implementation of TransformFeedback for Three.js came with
I think for raw shaders, we could have a class like We actually have a lot of nodes to handle this in TSL, but I think you'd want to use it as a key phrase in the GLSL string, similar to what we do in TSL. three.js/src/nodes/accessors/Camera.js Lines 5 to 12 in 841ca14
three.js/src/nodes/accessors/ModelNode.js Lines 35 to 42 in 841ca14
|
ShaderNodeMaterial sounds like it can be a good compromise if it gives the end user more control over the GLS/WGSL and keep most of it portable. I can understand I'll need to do some extra tweaking to port all my raw shaders over but I dont want the extent to be that its something that can't be ported back to any other webgl/webgpu based system. The next question is how feasible is it to get ShaderNodeMaterial working? The raw shader thing is a big blocker for me as I need it for things I work on for my employer and all of my visual debugging tools are written with raw shaders. |
@sketchpunk I make very complex apps with raw wgsl code but maybe I don't understand your concern well enough. https://github.com/Spiri0/Threejs-WebGPU-IFFT-Ocean-V2?tab=readme-ov-file I also have several codePens that show other use cases for raw wgsl. Maybe I can help you switch entirely to WebGPU if you are absolutely dependent on WebGPU functionalities, because I don't think deliberately mixing WebGPU with WebGL is a good solution. I personally see WebGL functionality in |
@Spiri0 At the moment I have no real need for WebGPU but I do need more functionally available for WebGL as its more widely available & still runs more stable then WebGPU, I dont know how many times WebGPU examples in threejs has crashed my graphics card by this point. For both my personal & professional, I utilize compute shaders in WebGL threw transformfeedback but I have to use a modified version of the library to get GL references to buffer objects to have access to modify them with transformfeedback. In my more public example, I built a mesh autoskinning prototype that runs on a modified 3js library but everything from data textures, shader compiling and transformfeedback execution I had to write from scratch using raw WebGL API with threejs really just rendering the results. Ideally, I shouldn't have to do that since the feature has been around for almost a decade & yet 3js has no support for it... till now in the new backend but in the process lost the ability to execute raw shaders which is a big requirement if you really want to squeeze out performance or do niche things. https://sketchpunklabs.github.io/autoskinning/ As a side note... In the new backend, How do I go about grabbing the GL references of an attribute buffer? I'd like to slowly transition my stuff to the new renderer but I'd like to do it in incremental steps away from raw webgl and onto the compute functionality. |
Currently with |
@vlucendo I'm far from the limit of bindings, but bundling data efficiently is a topic. That's why I'm thinking about structs. A struct with 12 bundled uniforms only uses one binding instead of the 12 individual uniforms and more efficient. @sketchpunk I assume you mean this with your last point about the matrices. This is pretty similar to rawShader
and with the positionNode:
The big advantage of the matrixNodes is that you no longer have to worry about the update, the node system does that. Of course you can also assign the matrices directly from the camera and the model and update them manually like in WebGL |
Yes, RawShaderMaterials was able to update those sort of values automatically, anything else custom I had to handle updates. |
Description
I need access to certain aspects of 3js like TransformFeedback/Compute with WebGL, To do so I need to run things with WebGPURenderer with forceWebGL set to true. The hitch is that RawShaderMaterial or something like it is no longer supported. This is a requirement because I have almost a decade worth of raw shaders plus, I need a simple way to keep shader code free & portable. TSL isn't a solution when there is a need to work in various webGL/openGL environments, be it shadertoys, pixiJS, babylonjs, godot, etc. I've even grabbed raw glsl code out of the blender project to use in 3js projects.
So far, the furthest I've managed to get TSL to work with raw shaders doesn't really work. Even using uniforms seems broken as even though I gave it a name, it changed its name plus threw it in a UBO of an unknown name instead of a simple uniform. I understand the idea to match how webgpu works, but there should be more control over uniforms in general that is predictable & known without having to output the GLSL code to see what really was created.
I dont know what the final solution should be, just bring back raw shaders for both GLSL & WGSL or provide some nodes that allows just a big text dump containing code, uniforms, attributes, varying. Also be nice to still have easy access to some of the main matrices like model, view & perspective plus cameraPosition was always nice to have around. I do want to use UBOs more but I want it to be optional if possible to better match WebGL / OpenGL shader standards.
As a side note, I even tried to extend nodeMaterial to see if I can hijack the builder to swop out the vertex/fragment shader before they're compiled into a program but that wasn't successful either.
@sunag
Outputs
Solution
xxx
Alternatives
xxx
Additional context
No response
The text was updated successfully, but these errors were encountered: