Skip to content
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

WebGL2: can't render StandardMaterial #12081

Closed
mockersf opened this issue Feb 24, 2024 · 2 comments · Fixed by #12110
Closed

WebGL2: can't render StandardMaterial #12081

mockersf opened this issue Feb 24, 2024 · 2 comments · Fixed by #12110
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds O-WebGL2 Specific to the WebGL2 render API

Comments

@mockersf
Copy link
Member

Bevy version

main since #11904

[Optional] Relevant system information

This is on Wasm on WebGL2

What you did

Try to run an example using StandardMaterial like lighting or load_gltf

What went wrong

Nothing renders

@mockersf mockersf added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen O-Web Specific to web (WASM) builds O-WebGL2 Specific to the WebGL2 render API labels Feb 24, 2024
@janhohenheim
Copy link
Member

janhohenheim commented Feb 24, 2024

@superdump the error is drawElementsInstanced: Buffer for uniform block is smaller than UNIFORM_BLOCK_DATA_SIZE.
Looks like our cool packing for Affine2 is the problem, since the issue is gone if I pass a Mat3 instead. What should I do about it? I see the following possibilities:

  • Pass in a mat3x3 all the time
  • Pass in a mat3x2 on non-webgl targets and a mat3x3 otherwise
  • Do something about UNIFORM_BLOCK_DATA_SIZE (idk how)

@janhohenheim
Copy link
Member

@mockersf if this is super important to fix ASAP, I can whip up a hotfix right now by passing slightly less optimized data structures to the standard material. Just let me know :)

github-merge-queue bot pushed a commit that referenced this issue Feb 25, 2024
# Objective

- Fixes #12081

## Solution

Passing the `Affine2` as a neatly packed `mat3x2` breaks WebGL with
`drawElementsInstanced: Buffer for uniform block is smaller than
UNIFORM_BLOCK_DATA_SIZE.`
I fixed this by using a `mat3x3` instead.
Alternative solutions that come to mind:
- Pass in a `mat3x2` on non-webgl targets and a `mat3x3` otherwise. I
guess I could use `#ifdef SIXTEEN_BYTE_ALIGNMENT` for this, but it
doesn't seem quite right? This would be more efficient, but decrease
code quality.
- Do something about `UNIFORM_BLOCK_DATA_SIZE`. I don't know how, so I'd
need some guidance here.

@superdump let me know if you'd like me to implement other variants.
Otherwise, I vote for merging this as a quick fix for `main` and then
improving the packing in subsequent PRs :)

## Additional notes

Ideally we should merge this before @JMS55 rebases #10164 so that they
don't have to rebase everything a second time.
msvbg pushed a commit to msvbg/bevy that referenced this issue Feb 26, 2024
# Objective

- Fixes bevyengine#12081

## Solution

Passing the `Affine2` as a neatly packed `mat3x2` breaks WebGL with
`drawElementsInstanced: Buffer for uniform block is smaller than
UNIFORM_BLOCK_DATA_SIZE.`
I fixed this by using a `mat3x3` instead.
Alternative solutions that come to mind:
- Pass in a `mat3x2` on non-webgl targets and a `mat3x3` otherwise. I
guess I could use `#ifdef SIXTEEN_BYTE_ALIGNMENT` for this, but it
doesn't seem quite right? This would be more efficient, but decrease
code quality.
- Do something about `UNIFORM_BLOCK_DATA_SIZE`. I don't know how, so I'd
need some guidance here.

@superdump let me know if you'd like me to implement other variants.
Otherwise, I vote for merging this as a quick fix for `main` and then
improving the packing in subsequent PRs :)

## Additional notes

Ideally we should merge this before @JMS55 rebases bevyengine#10164 so that they
don't have to rebase everything a second time.
msvbg pushed a commit to msvbg/bevy that referenced this issue Feb 26, 2024
# Objective

- Fixes bevyengine#12081

## Solution

Passing the `Affine2` as a neatly packed `mat3x2` breaks WebGL with
`drawElementsInstanced: Buffer for uniform block is smaller than
UNIFORM_BLOCK_DATA_SIZE.`
I fixed this by using a `mat3x3` instead.
Alternative solutions that come to mind:
- Pass in a `mat3x2` on non-webgl targets and a `mat3x3` otherwise. I
guess I could use `#ifdef SIXTEEN_BYTE_ALIGNMENT` for this, but it
doesn't seem quite right? This would be more efficient, but decrease
code quality.
- Do something about `UNIFORM_BLOCK_DATA_SIZE`. I don't know how, so I'd
need some guidance here.

@superdump let me know if you'd like me to implement other variants.
Otherwise, I vote for merging this as a quick fix for `main` and then
improving the packing in subsequent PRs :)

## Additional notes

Ideally we should merge this before @JMS55 rebases bevyengine#10164 so that they
don't have to rebase everything a second time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds O-WebGL2 Specific to the WebGL2 render API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants