-
-
Notifications
You must be signed in to change notification settings - Fork 36k
WebGPURenderer: Removed console warnings about missing attributes. #31788
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
base: dev
Are you sure you want to change the base?
Conversation
…t you are only working with classic geometries
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Could you share the WGSL compiled code of your vertex and fragment shader that is giving this warning? |
The fragment shader is very comprehensive. Perhaps the much smaller vertex shader will suffice. const vertexShader = wgslFn(`
fn main_vertex(
projectionMatrix: mat4x4<f32>,
cameraViewMatrix: mat4x4<f32>,
modelWorldMatrix: mat4x4<f32>,
instanceIndex: u32,
vertexIndex: u32,
vertexcount: u32,
displacementBuffer: ptr<storage, array<Displacement>, read>,
texelCoordBuffer: ptr<storage, array<TexelCoords>, read>,
) -> vec4<f32> {
let id = instanceIndex * vertexcount + vertexIndex;
let vtexelCoord0 = texelCoordBuffer[ id ].texelCoord0;
let vtexelCoord1 = texelCoordBuffer[ id ].texelCoord1;
let vtexelCoord2 = texelCoordBuffer[ id ].texelCoord2;
let vtexelCoord3 = texelCoordBuffer[ id ].texelCoord3;
let lodScale0 = texelCoordBuffer[ id ].lodScale0;
let lodScale1 = texelCoordBuffer[ id ].lodScale1;
let lodScale2 = texelCoordBuffer[ id ].lodScale2;
let lodScale3 = texelCoordBuffer[ id ].lodScale3;
let morphedPosition = displacementBuffer[ id ].morphedPosition;
let displacedPosition = displacementBuffer[ id ].displacedPosition;
let worldPosition = modelWorldMatrix * vec4<f32>( displacedPosition.xyz, 1.0 );
let clipPos = projectionMatrix * cameraViewMatrix * worldPosition;
let ndc = clipPos.xyz / clipPos.w;
var vUv = clipPos.xy / clipPos.w * 0.5 + 0.5;
vUv = vec2<f32>( vUv.x, 1.0 - vUv.y );
varyings.vCascadeScales = vec4<f32>( lodScale0, lodScale1, lodScale2, lodScale3 );
varyings.vDisplacedPosition = worldPosition;
varyings.vMorphedPosition = morphedPosition.xyz;
varyings.vTexelCoord0 = vtexelCoord0;
varyings.vTexelCoord1 = vtexelCoord1;
varyings.vTexelCoord2 = vtexelCoord2;
varyings.vTexelCoord3 = vtexelCoord3;
varyings.vClipPos = clipPos;
varyings.vUv = vUv;
return clipPos;
}
`, [ vDisplacedPosition, vMorphedPosition, vCascadeScales, vTexelCoord0, vTexelCoord1, vTexelCoord2, vTexelCoord3, vClipPos, vUv ] ); Before the vertex shader runs, a compute shader calculates the active areas and controls visibility via drawIndexedIndirect. The bottom line is that the vertex shader has no position, normal, or uv attributes. Everything comes from the two buffers. |
@Spiri0 Thank you, I would like to know the final output of the material (vertex+fragment), because I would like to know how the system is handling your code. result = await renderer.debug.getShaderAsync( scene, camera, mesh ); |
That's pretty extensive. Do you wish that I post it here? |
I imagine, but I would like. I would like just one material that has this problem. |
{fragmentShader: '// Three.js r179 - Node System\n\n// global\ndiagnost…0 ), object.nodeUniform28 );\n\n\treturn output;\n\n}\n', vertexShader: '// Three.js r179 - Node System\n\n// directives\n\n\n//…aryings.Vertex = nodeVar0;\n\n\treturn varyings;\n\n}\n'} ![]() I took the uv warning into account at the same time, because in my virtual geometry project, where I don't have any attributes, I kept getting the warning that the position attribute was missing. The WebGPU messages in the console are fine. Before I start threejs, I first create a simple adapter to read the GPU limits from it. I then immediately delete it before starting threejs with extended limits. |
Could you post in code format? |
This is what I got with the debug command you mentioned:
I would have to catch this in the WGSLNodeBuilder |
Yeah, I thought I had described that I needed the code #31788 (comment), with this function you can get the result of the compiled code, without having to hack or debug the |
Let's see if I can significantly reduce it. Otherwise, there's so much in there. I'll try to narrow it down later. |
I've now intercepted the fragment shader in WGSLNodeBuilder. I've also simplified the fragment shader considerably. I still see the warning with this much lighter fragment shader. I hope this helps.
These two weren't mine. They were inserted by the WGSLNodeBuilder. Could this be the cause of the warning? v_positionViewDirection : vec3, |
Yes, I suspected this might happen, so I'm in favor of polishing the approach or the system rather than removing the warnings. But I need to know the root cause of the problem. In this regard, I'll need more details on how the material was setup and post-processing if necessary. If you could provide some minimalist code, it would be very helpful. Thank you for simplifying this example. |
I'll try to get to it today. If not tomorrow. I've disabled post-processing. But I will write to you. |
Here, I have the same phenomenon with the position. Why there's a position warning but no normals warning is beyond me, since I don't have any normals attributes here, just like with the ocean. ![]() I'm trying to reproduce at least one of these warnings with this codepen, as it works similarly. Only there are no warnings. The main difference is that I use drawIndexedIndirect in my apps, but I can't yet tell if that might have something to do with it. https://codepen.io/Spiri0/pen/zxxvqYb?editors=0010 I'll try to reproduce this with a simple example. |
This happened because if you don’t use a parameter like You can solve this by adding a custom uv like |
Then I must apologize for my lack of knowlage. Sorry for the PR. I'll figure out what triggers the position warning. |
The PR is important because of the conclusion, analyzing again you are not using UV. It is something we can improve |
Thank you, then I'm relieved.
I might have the opportunity to present the power of Threejs at the university in Heilbronn. They've been teaching there in Unity so far. I was there in June, and they really liked the Ocean repo. Since then, however, I've implemented it much more efficiently and resource-friendly, without render hickups. Because I'm currently working intensively on further developing realistic water with transparency and refraction, I haven't had the time to continue working on dispatchWorkgroupsIndirect yet. The extension already works fine, but I haven't been able to continue with the count topic since then. |
I have removed two console warnings because these warnings assume that you are only working with classic attribute based geometries.
My ocean geometry is a pure bufferGeometry and has no attributes. The geometry datas are calculated by a compute shader and stored in buffers. The vertex shader only receives these buffers. uv's and normals wouldn't make sense for a dynamic geometry like mine anyway.
For dynamic procedural geometries like mine, this is the normal way.
compute -> vertex -> fragment
Since I also use drawIndexedIndirect here, attributes are obsolete in two respects.
This doesn't mean that attributes are obsolete or useless. It's just that attribute-based geometries in WebGPU are no longer the only way to generate geometries, and they're simply no longer the best choice for landscapes and dynamic geometries or virtual geometries.