bevy_vello icon indicating copy to clipboard operation
bevy_vello copied to clipboard

Support multiple cameras

Open ConnerPetzold opened this issue 1 year ago • 11 comments

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?

ConnerPetzold avatar May 13 '24 01:05 ConnerPetzold

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

cc: @seabassjh

simbleau avatar May 13 '24 16:05 simbleau

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 avatar May 13 '24 17:05 seabassjh

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

seabassjh avatar May 13 '24 17:05 seabassjh

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?

ConnerPetzold avatar May 13 '24 18:05 ConnerPetzold

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

seabassjh avatar May 13 '24 18:05 seabassjh

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 avatar May 13 '24 18:05 seabassjh

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?

seabassjh avatar May 13 '24 18:05 seabassjh

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.

ConnerPetzold avatar May 13 '24 19:05 ConnerPetzold

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.

simbleau avatar May 13 '24 21:05 simbleau

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!

ConnerPetzold avatar May 13 '24 21:05 ConnerPetzold

@seabassjh

simbleau avatar May 17 '24 14:05 simbleau

Merge conflict @cpetzold

simbleau avatar Jun 13 '24 01:06 simbleau

Superseded by #68

simbleau avatar Jul 25 '24 05:07 simbleau