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

Headless rendering to images #22

Closed
cart opened this issue Jun 9, 2020 · 12 comments · Fixed by #13006
Closed

Headless rendering to images #22

cart opened this issue Jun 9, 2020 · 12 comments · Fixed by #13006
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@cart
Copy link
Member

cart commented Jun 9, 2020

The RenderGraph should already be able to handle headless rendering scenarios. The only missing pieces are:

  • Adapt WindowTextureNode to a TextureNode, which produces a texture output for configured dimensions instead of window dimensions
  • Write code to copy texture data from the gpu to an image file so headless rendering can be verified
@karroffel karroffel added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Aug 12, 2020
@rmsc
Copy link
Contributor

rmsc commented Jan 24, 2021

It definitely does: https://github.com/mrk-its/bevy/tree/render_to_texture and https://github.com/rmsc/bevy/tree/render_to_file.

There are however a few open questions, namely:

  • The Camera system expects a WindowId. Maybe change that to an enum to also support a TextureId?
  • There is a Res<Windows> for WindowId-to-Window mapping, perhaps there should also be one for TextureId-to-Texture?
  • To me it's not clear how to properly interface with the ECS to move the texture from the GPU to the CPU (possibly also related to Distinguish between "GPU textures" and "CPU textures" #1234)

@alice-i-cecile
Copy link
Member

Complete! See #1927.

@mockersf
Copy link
Member

Complete! See #1927.

Not really. It's not possible to render to an image file as the issue was saying

@DGriffin91
Copy link
Contributor

I made a little example of this awhile back. If it would be helpful, I could update it.

Write code to copy texture data from the gpu to an image file so headless rendering can be verified

Are we looking for an example or a test here?

@mockersf
Copy link
Member

mockersf commented Mar 21, 2022

Nice!

Ideally we would need to have a nice api in Bevy to:

  • move data from gpu to cpu
  • move data from render app to main app

It could maybe be a more "hardcoded" capture plugin as you have in your example, that could already be useful...

@hymm
Copy link
Contributor

hymm commented Jul 24, 2023

Fixed in #7163

@hymm hymm closed this as completed Jul 24, 2023
@mockersf
Copy link
Member

@hymm does it work in headless mode? this issue was kept for that

@hymm
Copy link
Contributor

hymm commented Jul 24, 2023

probably not. will reopen.

edit: saw this message #7163 (comment) and thought it was fixed.

@hymm hymm reopened this Jul 24, 2023
@bes
Copy link
Contributor

bes commented Aug 26, 2023

Hello! Would this also cover the case where a pure headless pipeline could be built by outputting to a OpenGL (or Vulkan) texture?

Specifically, I am looking to do something like

              -------
Texture  --> | Bevy | --> Texture
              -------

Where Texture is a native (OpenGL, Vulkan) texture that can be fed into Bevy and then I can get a native texture out of Bevy (I expect there to be some manual wgpu steps involved, too).

I guess wgpu needs to be able to handle native textures in / out (which I don't think it does currently).

So for the Bevy part I think what's most important is to be able to render to a texture (and not be limited to an image on file).

I already have custom, non-Bevy, pipeline doing this, but there are a lot of unsafe { gl::... calls going on 😅, so getting this all into bevy would be a dream come true.

@jeertmans
Copy link

Hello! Is there any update on this?
I would be super interested in being able to use bevy_image_export in headless more :-)

@DGriffin91
Copy link
Contributor

DGriffin91 commented Oct 10, 2023

@jeertmans #5550 runs without a window. It may or may not be a helpful reference.

@jeertmans
Copy link

Thanks, @DGriffin91! I'll take a look at it when I have some time :-)
I'm quite new to Bevy, so I might reach back to you for questions ^^'

atlv24 pushed a commit to atlv24/bevy that referenced this issue Jan 19, 2024
Fix occlusion culling (partially) and add meshlet bounding sphere debug viewer
github-merge-queue bot pushed a commit that referenced this issue May 8, 2024
# Objective

Fixes #11457.
Fixes #22.

## Solution

Based on [another headless
application](https://github.com/richardanaya/headless/)

---

## Changelog

- Adopted to bevy 0.14

---------

Co-authored-by: BD103 <[email protected]>
Co-authored-by: François Mockers <[email protected]>
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-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants