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

Support multiple cameras #49

Closed
wants to merge 1 commit into from

Conversation

cpetzold
Copy link
Contributor

This is a first stab at multiple camera support. It currently assumes that the desired camera is on RenderLayer 0.

I'd like to allow flexibility on RenderLayer, but I wasn't sure how to support it properly. For example, if you have multiple render layers configured for an entity you want to render with bevy_vello, does that mean that you'd need to compute the affine for each camera targeted?

@simbleau simbleau requested a review from seabassjh May 13, 2024 16:51
@simbleau
Copy link
Member

Hey @cpetzold ! Thank you for the PR. One of us will review this soon.

cc: @seabassjh

camera: Query<(&ExtractedCamera, &ExtractedView)>,
mut render_vectors: Query<(Entity, &ExtractedRenderScene)>,
camera: Query<(&ExtractedCamera, &ExtractedView, &RenderLayers)>,
mut render_scenes: Query<(Entity, &ExtractedRenderScene)>,
Copy link
Member

Choose a reason for hiding this comment

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

Ahh, good spot! We definitely copy/pasted this wrong ;)

@seabassjh
Copy link
Collaborator

seabassjh commented May 13, 2024

if you have multiple render layers configured for an entity you want to render with bevy_vello, does that mean that you'd need to compute the affine for each camera targeted?

Yes. But if you're expecting that there will be n Vello scenes for n cameras, that will not be possible yet and requires something thinking and reworking on my render_scene system.

@seabassjh
Copy link
Collaborator

seabassjh commented May 13, 2024

if you have multiple render layers configured for an entity you want to render with bevy_vello, does that mean that you'd need to compute the affine for each camera targeted?

Yes. But if you're expecting that there will be n Vello scenes for n cameras, that will not be possible yet and requires something thinking and reworking on my render system.

To clarify, this would have to be called n times
https://github.com/loopystudios/bevy_vello/blob/d25d787f14c77533b9b038ad153847b0f13e1c46/src/render/systems.rs#L181-L195

@cpetzold
Copy link
Contributor Author

if you have multiple render layers configured for an entity you want to render with bevy_vello, does that mean that you'd need to compute the affine for each camera targeted?

Yes. But if you're expecting that there will be n Vello scenes for n cameras, that will not be possible yet and requires something thinking and reworking on my render_scene system.

Right that makes sense. I posted this on the bevy discord:

"I wonder if some sort of API where you add a VelloRenderer to a camera entity would make sense. A setup system would spawn the render target for that camera. Then it would create extracted instances per vello-rendered entity per overlapping camera with VelloRenderer."

Thoughts on that approach?

@seabassjh
Copy link
Collaborator

I agree on that approach. That was my initial idea as well!

@seabassjh
Copy link
Collaborator

What do you hope to accomplish with multiple cameras? Like split screen... because that would require us to revise the full screen triangle texture approach

@seabassjh
Copy link
Collaborator

I'm having a hard time thinking about what the practical uses of multiple "VelloRenderer" cameras would be. And what it would like look in a normal scenario-- multiple vello scenes overlayed right on top of each other on the full screen texture triangle?

@cpetzold
Copy link
Contributor Author

I don't have a use case for multiple VelloRender'ing cameras. My use case is that I want to render an infinite 2d grid alongside my vello scene, and my approach is to use a separate camera to render a screen space shader.

@simbleau
Copy link
Member

simbleau commented May 13, 2024

I don't have a use case for multiple VelloRender'ing cameras. My use case is that I want to render an infinite 2d grid alongside my vello scene, and my approach is to use a separate camera to render a screen space shader.

Ah, this is already possible with existing tooling.

image

In this, we're using egui + bevy_vello + a custom shader (infinite "transparency" grid).

This was all Sebastian's doing, so I'll wait for him to talk about how he did that.

@cpetzold
Copy link
Contributor Author

I did get it to work with a single camera approach, but it felt a bit bad because I had to scale the shader mesh with the camera to support zooming the camera. Though it does simplify the shader code since I can just use the View that's automatically passed!

@simbleau
Copy link
Member

@seabassjh

@simbleau
Copy link
Member

Merge conflict @cpetzold

@simbleau
Copy link
Member

Superseded by #68

@simbleau simbleau closed this Jul 25, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 27, 2024
This is a rebased version of #49 which looks like it only needed merge
conflicts resolved

---------

Co-authored-by: Conner Petzold <cpetzold@gmail.com>
Co-authored-by: Spencer C. Imbleau <spencer@imbleau.com>
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