mrk-its / bevy_webgl2

WebGL2 renderer plugin for Bevy game engine
MIT License
172 stars 46 forks source link

Update for bevy master #24

Closed rparrett closed 3 years ago

rparrett commented 3 years ago

Fixes #23.

But in a pretty half-assed way. I do not know how to implement the render/render resource context stuff, so they are just stubs.

Providing this for anyone else who's tracking bevy master and just wants to get this working again.

CI obviously failing because this won't work with bevy 0.4.

rparrett commented 3 years ago

Up to date with current bevy master, but the new wgpu stuff was rough on me and I've done the bare minimum only to get my 2d game working.

rparrett commented 3 years ago

Oops! Thanks for that.

I'm super happy to keep working on this. But if someone with any experience at all with opengl wants to take the reins, that's great too.

Some of the examples are looking to be in pretty bad shape now that I've actually even run them.

The biggest known problem I have is here: https://github.com/mrk-its/bevy_webgl2/pull/24/commits/d30ac8ee23a78dc987425e6e7a1c9409e9b3586a#diff-a731f7f5f708022a34572ab832954c802f7fd77de1e8c38418ed7049717912f7R150

Which (I think) is resulting in a glGenerateMipmap / GL_INVALID_OPERATION in my project (but no visible problems weirdly), but must be causing all sorts of other issues, right?

rparrett commented 3 years ago

Here's a survey of the examples:

Example Status (This PR) Status (0.4) Status (Bevy Master/Native)
font_atlas_debug panic same bit broken but no panic
z_sort_debug broken working broken

Everything else seems to be working.

font_atlas_debug (same panic in master branch)

wasm.js:338 panicked at 'called `Option::unwrap()` on a `None` value', src/webgl2_render_pass.rs:227:89

z_sort_debug - cubes appear completely black

rparrett commented 3 years ago

Oops. I wanted PerspectiveCameraBundle, not a 3d orthographic camera. Will fix that up.

rparrett commented 3 years ago

I am not sure why I've been manually fixing examples instead of just copying them and using fix_bevy_example.sh.

edit: oh, that strategy doesn't quite work for shader/* and contributors

rparrett commented 3 years ago

Issue with the contributors example was fixed in bevy

mrk-its commented 3 years ago

Thanks, you've done a lot of work! I'll take a closer look tomorrow.

mrk-its commented 3 years ago

load_gltf

appears to work, but GL_INVALID_OPERATION : glGenerateMipmap: in console

Do you still have this warning? I cannot reproduce it

rparrett commented 3 years ago

I am (chrome 88, macos).

image

But my assumption that this is caused by my having basically removed support for anything but the default textureformat is a totally blind one.

I'm pretty sure that I don't remember seeing this with bevy 0.4 / bevy_webgl2 but I could be wrong.

mrk-its commented 3 years ago

The only place mipmaps are generated is https://github.com/mrk-its/bevy_webgl2/blob/637ca07c75ffbd29ab4661aed54f148eb11a39b4/src/renderer/webgl2_render_context.rs#L117 - It seems we can simply remove it because mipmaps are not used at all (because of hardcoded TEXTURE_MIN_FILTER = Gl::NEAREST). All texture filtering support has yet to be implemented - so let's remove this mipmap generation now (It would be great to run all texture-related examples after that, but I think everything should work exactly the same way)

rparrett commented 3 years ago

Cool. That seems to resolve the scary error message. I double checked load_gltf, sprite, sprite_sheet, texture and they continue to work.

Any leads on what might be going on with z_sort_debug?

mrk-its commented 3 years ago

Cool. That seems to resolve the scary error message. I double checked load_gltf, sprite, sprite_sheet, texture and they continue to work.

Any leads on what might be going on with z_sort_debug?

Not yet, will take a look

mrk-its commented 3 years ago

It seems z_order_debug in bevy's master is also broken, I've filled an issue: https://github.com/bevyengine/bevy/issues/1411

JeanMertz commented 3 years ago

Nice work @rparrett. It looks like this PR is ready to review/merge, correct? cc @mrk-its.

rparrett commented 3 years ago

It's probably not a goal to get this merged until we're much closer to bevy 0.5 being released.

JeanMertz commented 3 years ago

Got it. Makes sense. I'll just point to this branch meanwhile 👍

mrk-its commented 3 years ago

@rparrett @JeanMertz I think it is good idea to merge it (if everything still works with current bevy master), and we can keep syncing with bevy in separate PR's. Some time ago I've created separate branch https://github.com/mrk-its/bevy_webgl2/tree/v0.4 for 0.4.x version of bevy_webgl2, so we can sync with bevy's master on master branch here.

Let's simply check few examples with current bevy - if it works I'll merge it.

rparrett commented 3 years ago

Looks like all bevy_webgl2 examples that are expected to work (everything but font_atlas_debug) are working on my end.