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

Bevy render to texture #9

Closed
samsamai opened this issue Feb 13, 2021 · 3 comments
Closed

Bevy render to texture #9

samsamai opened this issue Feb 13, 2021 · 3 comments

Comments

@samsamai
Copy link

Please excuse this non-issue, just looking for some help.
I'm looking to render a 3D scene with bevy and show it in a egui window as an image, the bevy_gui example is very close to what I want. I was wondering if you had any pointers or examples of how to render to a texture instead of the screen in bevy.

@vladbat00
Copy link
Owner

Hi! No problem, I think this actually a good use-case to explore.

I believe you can find several useful examples of rendering something to a texture in this thread: bevyengine/bevy#1207

Here's one of them: https://github.com/mrk-its/bevy/blob/29fe738daeb05165ee6459a87b72c7c0f2699109/examples/3d/render_to_texture.rs

And I believe this is a live version of it: https://mrk.sed.pl/bevy-showcase/#render_to_texture

I think this is already achievable with bevy_egui, but I'm not sure how optimal it is at the moment. You'd need to create a texture node, which would be used for rendering a scene into it, and you'd pass the related texture handle to set_egui_texture. But I'm afraid that would involve reading data from GPU to RAM, doing several copies, which is somewhat inefficient.

I'd like to learn how to avoid that, and probably there's something that we could provide via bevy_egui interface to pass device textures directly.

@samsamai
Copy link
Author

Thanks @mvlabat for the link to the source of that example, that will be very helpful. I'll see if I can get it working with bevy_egui.

@vladbat00
Copy link
Owner

Sure. :) Let me know if you get any results. I've also created an issue to track the feature that would provide an optimal way of rendering such a texture inside of bevy_egui widgets: #11.

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

No branches or pull requests

2 participants