linebender / bevy_vello

An integration to render with Vello in Bevy game engine.
https://linebender.org/bevy_vello/
Apache License 2.0
117 stars 12 forks source link

Support multiple cameras #49

Closed cpetzold closed 1 month ago

cpetzold commented 3 months ago

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 commented 3 months ago

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

cc: @seabassjh

seabassjh commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

seabassjh commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

@seabassjh

simbleau commented 2 months ago

Merge conflict @cpetzold

simbleau commented 1 month ago

Superseded by #68