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

[Merged by Bors] - Allow prepass in webgl #7537

Closed
wants to merge 9 commits into from

Conversation

IceSentry
Copy link
Contributor

@IceSentry IceSentry commented Feb 7, 2023

Objective

  • Use the prepass textures in webgl

Solution

  • Bind the prepass textures even when using webgl, but only if msaa is disabled
  • Also did some refactors to centralize how textures are bound, similar to the EnvironmentMapLight PR
  • Also did some refactors of the example to make it work in webgl
  • To make the example work in webgl, I needed to use a sampler for the depth texture, the resulting code looks a bit weird, but it's simple enough and I think it's worth it to show how it works when using webgl

@IceSentry IceSentry added the A-Rendering Drawing game state to the screen label Feb 7, 2023
@IceSentry IceSentry added this to the 0.10 milestone Feb 7, 2023
@IceSentry IceSentry changed the title Allow prepass in webgl when msaa disabled Allow prepass in webgl Feb 7, 2023
@superdump superdump self-requested a review February 7, 2023 11:44
Copy link
Contributor

@superdump superdump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea generally. Mostly just nits.

assets/shaders/show_prepass.wgsl Outdated Show resolved Hide resolved
examples/shader/shader_prepass.rs Outdated Show resolved Hide resolved
examples/shader/shader_prepass.rs Outdated Show resolved Hide resolved
assets/shaders/show_prepass.wgsl Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added O-Web Specific to web (WASM) builds C-Feature A new feature, making something new possible C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change and removed C-Feature A new feature, making something new possible labels Feb 7, 2023
@IceSentry
Copy link
Contributor Author

IceSentry commented Feb 7, 2023

I don't know what's going on, but this just stopped working. It worked perfectly fine when I created the PR, but it seems like I squashed a change I shouldn't have and now it stopped working.

I still think we should bind the prepass textures even for webgl, but I can't get the example to work in webgl anymore.

@IceSentry
Copy link
Contributor Author

IceSentry commented Feb 7, 2023

@superdump For the sake of merging this in time. I removed the changes in the example to make it work in webgl.

So now all this does is some minor refactors and bind the textures in webgl when msaa is disabled. This way, we can figure out how to correctly sample the depth at a later time, but the textures will still be available for anyone to figure it out instead of being blocked by the engine.

@superdump
Copy link
Contributor

Please update.

@IceSentry
Copy link
Contributor Author

@superdump updated

Copy link
Member

@cart cart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and my tests appear to get as far as everyone else (Internal error in FRAGMENT shader: WGSL textureLoad from depth textures is not supported in GLSL)

@cart
Copy link
Member

cart commented Mar 2, 2023

bors r+

bors bot pushed a commit that referenced this pull request Mar 2, 2023
# Objective

- Use the prepass textures in webgl

## Solution

- Bind the prepass textures even when using webgl, but only if msaa is disabled
- Also did some refactors to centralize how textures are bound, similar to the EnvironmentMapLight PR
- ~~Also did some refactors of the example to make it work in webgl~~
- ~~To make the example work in webgl, I needed to use a sampler for the depth texture, the resulting code looks a bit weird, but it's simple enough and I think it's worth it to show how it works when using webgl~~
@bors bors bot changed the title Allow prepass in webgl [Merged by Bors] - Allow prepass in webgl Mar 2, 2023
@bors bors bot closed this Mar 2, 2023
@IceSentry IceSentry deleted the prepass-webgl branch March 15, 2023 03:59
Shfty pushed a commit to shfty-rust/bevy that referenced this pull request Mar 19, 2023
# Objective

- Use the prepass textures in webgl

## Solution

- Bind the prepass textures even when using webgl, but only if msaa is disabled
- Also did some refactors to centralize how textures are bound, similar to the EnvironmentMapLight PR
- ~~Also did some refactors of the example to make it work in webgl~~
- ~~To make the example work in webgl, I needed to use a sampler for the depth texture, the resulting code looks a bit weird, but it's simple enough and I think it's worth it to show how it works when using webgl~~
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 C-Code-Quality A section of code that is hard to understand or change O-Web Specific to web (WASM) builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants