-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Voxel shadow fixes for interleaved buffers #17376
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: master
Are you sure you want to change the base?
Conversation
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
1 similar comment
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17376/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/17376/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/17376/merge#BCU1XR#0 |
|
Devhost visualization test reporter: |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
|
Devhost visualization test reporter: |
1cee238 to
ce4c445
Compare
|
@Popov72 I've included your fix and also made once that fixes the voxelization when calling it repeatedly. This allows the voxelization to work with all the animated assets that I've tried. |
|
Devhost visualization test reporter: |
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
| // Calculate offset in float32 elements | ||
| const offset = vertexBuffer.effectiveByteOffset / sizeInBytes; | ||
| defines[`${upperName}_OFFSET`] = offset; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"_COMPONENT_BYTES" is not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to uniforms now.
| } | ||
|
|
||
| // Add vertex buffer metadata defines for proper stride/offset handling | ||
| const geometry = renderingMesh.geometry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to use the new PrepareDefinesForVertexPullingMetadata function instead?
Also, I think we should pass stride and offset as a byte count instead of a float count, to more easily handle all type conversions we will have to support (for example, type of position could be a (u)byte, (u)short, (u)int, float, and for the integer types, they could be normalized or not - these are type conversions we will have to perform in the shader).
Another thing is that we should probably use uniforms and not defines to pass data, else we will basically generate a new shader for each mesh, as (at least) offset will be different for each mesh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good idea. I've changed to uniforms now.
|
@MiiBond fyi cause I think some of the comments went in late :-) |
ce4c445 to
33b07ed
Compare
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
I didn't have time today, but I will review the PR tomorrow. |
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
You should remove package-lock.json from the PR. |
| * @param metadata The vertex pulling metadata | ||
| */ | ||
| export function BindVertexPullingUniforms(effect: Effect, metadata: Map<string, IVertexPullingMetadata>): void { | ||
| if (!metadata || !effect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If metadata and effect can be null/undefined, you should update their declaration in BindVertexPullingUniforms accordingly.
| for (const [attribute, data] of metadata.entries()) { | ||
| const uniformName = `vp_${attribute}_info`; | ||
| // Pack into vec3: (offset, stride, type) | ||
| effect.setVector3(uniformName, new Vector3(data.offset, data.stride, data.type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use setFloat3 to avoid creating a new Vector3 for each attribute every frame (you could also use setInt3, if ints are easier to handle than floats in the shader).
| // Add vertex buffer metadata defines for proper stride/offset handling | ||
| const geometry = renderingMesh.geometry; | ||
| if (geometry) { | ||
| this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should normally update the uniforms array passed to createEffect with the names of the new uniforms. I'm not sure why it works without this code...
| pos.y = position[index * 3 + 1]; | ||
| pos.z = position[index * 3 + 2]; | ||
| return pos; | ||
| uniform vp_position_info: vec3f; // (bufferIndex, offset, stride, type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what bufferIndex refers to?
This PR adds defines to assist with vertex pulling when the vertex buffers are interleaved.
I'm also including a fix by @Popov72 for IBL shadow voxelization when using bones.