Skip to content

Rename Camera to RenderSurface#16248

Closed
aevyrie wants to merge 2 commits intobevyengine:mainfrom
aevyrie:rename-camera
Closed

Rename Camera to RenderSurface#16248
aevyrie wants to merge 2 commits intobevyengine:mainfrom
aevyrie:rename-camera

Conversation

@aevyrie
Copy link
Copy Markdown
Member

@aevyrie aevyrie commented Nov 5, 2024

I'm sure this will be controversial, but I wanted to start a discussion with a concrete first step.

There are other things to rename to be consistent, but rather than do everything at once, I've started very small.

Rough proposal on discord: https://discord.com/channels/691052431525675048/743663673393938453/1300556420881846323

Discord thread converted to issue: #16249

Related to #16247

Objective

  • Attempt to give Camera a more accurate name. Reading the docs and fields, this is what the component is for. The colloquial usage of Camera is more appropriate for our existing Camera3d or Camera2d, which split out of the old Camera struct, if I recall correctly.
  • Picking uses Camera as the common component to reason about where pointers are on screen. This is misleading, because Camera has nothing to do with 3d (although it still retains transforms, maybe erroneously). The reason picking uses this component is because a Camera, or RenderSurface just defines:
    • What target to write to (window or texture), and the dimensions of this target
    • A viewport within the target to constrain rendering to
    • The order to render each of these RenderSurfaces to the render target
    • The end result, is that the job of RenderSurface (Camera) is to define how to composite layers of 2d images onto a target.
  • Move UI and picking towards reasoning about a "render surface" as opposed to a "camera".
  • Next steps would be to update bevy_ui to make the root of every UI contain a RenderSurface.

Solution

  • Rename the component.

Migration Guide

  • Rename Camera to RenderSurface.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen X-Needs-SME This type of work requires an SME to approve it. S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Waiting-on-SME This is currently waiting for an SME to resolve something controversial labels Nov 5, 2024
@alice-i-cecile
Copy link
Copy Markdown
Member

The current docs, for reference https://docs.rs/bevy/latest/bevy/prelude/struct.Camera.html. I'm in favor of this direction. The important part is that the existing 2d/3D cameras are still called "cameras".

@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented Nov 5, 2024

I would like if we could also take this opportunity to rename the Camera::hdr field to something that doesn't imply HDR output to an HDR monitor.

@Jondolf
Copy link
Copy Markdown
Contributor

Jondolf commented Nov 5, 2024

@cart may or may not have thoughts on this based on the discussions around splitting and/or renaming Camera a month ago, starting here. My understanding was that he overall likes Camera as the defining and driving type for cameras, e.g. Camera2d "is a" Camera, and that it'd be good for people to think of it that way. I feel like renaming Camera to RenderSurface moves away from the concept of what people think of as a "camera" a bit, for better or for worse. Although the two are heavily related of course.

Personally, I would be in favor of the rename. I think RenderSurface is more fitting and accurate in this case, and the reasoning listed in this PR makes sense. I also just find the semantics of Camera and the associated compositional inheritance pattern re: Camera2d and Camera3d to be somewhat confusing currently.

@aevyrie
Copy link
Copy Markdown
Member Author

aevyrie commented Nov 5, 2024

I also just find the semantics of Camera and the associated compositional inheritance pattern re: Camera2d and Camera3d to be somewhat confusing currently.

Agreed, a camera entity currently has multiple Camera_ components, which is a bit odd.

My understanding was that he overall likes Camera as the defining and driving type for cameras, e.g. Camera2d "is a" Camera, and that it'd be good for people to think of it that way.

To me Camera is more like the "film" than the "camera". Camera (or RenderSurface) doesn't "capture" anything, it's just the surface the camera films onto, which we can then stack and composite. Camera3d and Camera2d make total sense to me as "cameras", they are the components that drive "capturing" the ECS, either by rendering 2d, or 3d entities.

Looking at the linked discussion, I don't think this change runs amok of Cart's reasoning - the fields are still monolithic and kept together, it's more about giving this a more accurate name for how it is already being used, and make it more obvious to newcomers how it is intended to be used.

e..g if I start a new project and search for a Camera component, I would see the multiple camera types, in addition to the Camera. After this change, only the actual "cameras" would show up. Additionally, thinking about what this would look like in the editor, I keep coming back to the idea of UX that allows you to reorder the RenderSurfaces on each render target. The name RenderSurface better conveys that you aren't shuffling and resizing cameras, you are modifying the surfaces that are rendered to, from cameras or otherwise. E.g. a compute shader, or 3rd party UI like bevy_egui might want to use a RenderSurface that can be ordered relative to everything else.

@BenjaminBrienen
Copy link
Copy Markdown
Contributor

The film analogy is 🤌

@cart
Copy link
Copy Markdown
Member

cart commented Nov 7, 2024

I don't outright hate it (as it does resolve the Camera vs Camera2d concerns), but I do have a number of sticking points that make it feel like a major downgrade to me:

  1. Camera to me does not feel like the "film". RenderTarget feels like the film (although the line is blurry, especially for the hdr field). The majority of Camera feels like the "camera" domain to me: selecting what film to write to (render target), selecting what lenses / filters / views of the world to use (CameraRenderGraph), choosing what part of the film is exposed (viewport), choosing whether or not the aperture is open (is_active), etc. Much like a camera, you can take out the film and put it in another camera (using render targets across multiple cameras, defining the order the cameras render in).
  2. RenderSurface feels way too ambiguous with RenderTarget. These both read as "the thing you render to" to me. People will find this confusing.

To me, it seems like the right "conceptual framing" is for something that has Camera to "be a camera". CameraRenderGraph is a bit like configuring the lens and choosing where to point. If you have those two things you are ready to film with your camera!. Camera2d and Camera3d are just the stock configurations with presets you buy off the shelf.

If Camera was a base class, I don't think we would be having this conversation. This whole conversation seems like resistance to the "required components / inheritance by composition" idea. And that is concerning because we have been using this pattern elsewhere (ex: MaterialNode requires Node, ImageNode requires Node, etc).

The concern that people will reach for an "empty" base Camera (ex: missing a lens) is reasonable. But I don't think the best solve to that problem is contorting the design to make less sense. I think our "camera" just needs a warning light when you try to film without a lens.

@BenjaminBrienen
Copy link
Copy Markdown
Contributor

Thanks for the great explanation! How would you prefer to see this resolved? Professionals buy a camera expecting to also need to give it a lens, so how do we create that expectation for Camera? Documentation?

@cart
Copy link
Copy Markdown
Member

cart commented Nov 7, 2024

I think the "warning light" should be a "warning log entry".

@BenjaminBrienen BenjaminBrienen added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Jan 22, 2025
@BenjaminBrienen BenjaminBrienen removed the S-Waiting-on-SME This is currently waiting for an SME to resolve something controversial label May 17, 2025
@BenjaminBrienen
Copy link
Copy Markdown
Contributor

triage: Has merge conflicts, received SME feedback. Probably needs to be closed and converted into a discussion where the design can be further discussed.

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 D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Needs-SME This type of work requires an SME to approve it.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants