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

Upgrade to 0.7 #6

Merged
merged 4 commits into from
Apr 23, 2022
Merged

Upgrade to 0.7 #6

merged 4 commits into from
Apr 23, 2022

Conversation

chrisburnor
Copy link
Contributor

So far this just attacks the low hanging fruit for upgrading to 0.6.

Still To be Done:

  • Figure out how to do borders in new renderer
  • Examples

@drakmaniso
Copy link
Owner

Thanks for working on this! I haven't look at the changes in bevy 0.6 yet...

Concerning the borders, it's just 4 sprites with a system to correctly position them each time the camera is updated. Have the sprites or the cameras changed a lot in the new renderer? If not, the border system should not require many changes.

@oledfish
Copy link

SpriteBundles no longer use Meshes as of 0.6, so I'm not sure how you can replicate that effect now

@chrisburnor
Copy link
Contributor Author

Yeah, there are some significant changes on how the renderer works. @awalker Seems to be the furthest along with https://github.com/awalker/bevy_pixel_camera which aims to use this PR as a base bevyengine/bevy#3463 .

Is the custom mesh needed for only the outlines? or is it needed to ensure the correct alignment as well? It looked from the code errors I was seeing like it was the former, but I'm not sure how else you'd be doing the latter without the custom mesh.

@drakmaniso
Copy link
Owner

The custom mesh was needed for the correct alignment of all sprites; the default origin point of sprites in 0.5 was in the center, so sprites with odd dimensions would not be aligned on pixels.

After a quick look at 0.6 docs, there doesn't seem to be an official way to set the origin point of sprites. The mesh is now hardcoded here and here.

So I think the options are (ordered from ideal to hackish):

  1. Ask to add a configurable origin point to the official sprite system and just use that;
  2. Write a whole new system just to render (i.e. "extract") the pixel sprites;
  3. Add a system to sanitize sprites coordinates, which would round all pixel sprites coordinates, and add 0.5 to sprites with odd dimensions;
  4. If it's possible to change the shaders used for a sprite, using vertex_uv instead of vertex_position in the vertex shader might do the trick;

@drakmaniso
Copy link
Owner

drakmaniso commented Jan 26, 2022

Oh, I hadn't seen the PR linked above by @chrisburnor, which correspond to solution 1... So it's probably best to just wait for that.

@chrisburnor
Copy link
Contributor Author

I think now that Bevy supports Sprite Anchors, it should be possible to complete this PR and upgrade to bevy 0.7.

https://docs.rs/bevy/0.7.0/bevy/sprite/enum.Anchor.html

@drakmaniso
Copy link
Owner

Yes, sprite anchors should solve the problem.

Does that mean you intend to finish the PR, or do you want me to do it?

@chrisburnor
Copy link
Contributor Author

It would probably be much faster if you did it. I'm happy to continue to play around with it, but I likely wont' be able to make any serious progress for a few weeks until my calendar clears up.

@drakmaniso
Copy link
Owner

No problem! I should be able find some time in the coming days.

And thank you for the heads-up about the sprite anchors implementation!

@drakmaniso
Copy link
Owner

I've got it working!

Except there is a very strange bug: sprites are not displayed if the ClearColor is set to pure black... Any other color will work! I have no idea how this is even possible.

The bug seems to happen with bevy's own OrthographicCameraBundle too, so it's either a bug on their side, or something has changed in the way to set background color that I'm not aware of.

Other than that, the code is now much simpler, thank to the sprite anchors.

@drakmaniso drakmaniso changed the title Upgrade to 0.6 Upgrade to 0.7 Apr 22, 2022
@drakmaniso drakmaniso marked this pull request as ready for review April 22, 2022 10:04
@drakmaniso
Copy link
Owner

The ClearColor bug happens on linux but not on windows, so it may not even be specific to bevy, but a bug in the intel GPU driver, or wayland...

So I'm going to merge the PR.

@drakmaniso drakmaniso merged commit 99c9625 into drakmaniso:main Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants