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

feat(rendering): Add OrthographicCamera component #1335

Merged
merged 2 commits into from
Sep 29, 2024

Conversation

mkuritsu
Copy link
Contributor

Description

Added OrthographicCamera component to update the Camera with a orthographic projetion.

One thing I'm not sure if its the best approach is the size parameter added, I put it as a multiplier to the viewport the camera is drawing to. Would it be better to leave it like that or change it to be values to represent the plane size, something like a vec2{800, 600}?

Checklist

  • Self-review changes.
  • Update render main sample.
  • Add entry to the changelog's unreleased section.

@mkuritsu mkuritsu linked an issue Sep 28, 2024 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Sep 28, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://GameDevTecnico.github.io/cubos/preview/pr-1335/
on branch gh-pages at 2024-09-29 14:24 UTC

@mkuritsu mkuritsu force-pushed the 1182-add-ortographiccamera-component branch from f6d6795 to 00eba9b Compare September 28, 2024 17:27
Copy link

codecov bot commented Sep 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.

Project coverage is 42.45%. Comparing base (f19856a) to head (3ecdf2d).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
engine/src/render/camera/plugin.cpp 0.00% 20 Missing ⚠️
engine/src/render/camera/orthographic.cpp 0.00% 12 Missing ⚠️
engine/src/render/split_screen/plugin.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1335      +/-   ##
==========================================
- Coverage   42.49%   42.45%   -0.05%     
==========================================
  Files         409      410       +1     
  Lines       29229    29260      +31     
==========================================
  Hits        12421    12421              
- Misses      16808    16839      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@kuukitenshi kuukitenshi left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@tomas7770
Copy link
Contributor

One thing I'm not sure if its the best approach is the size parameter added, I put it as a multiplier to the viewport the camera is drawing to. Would it be better to leave it like that or change it to be values to represent the plane size, something like a vec2{800, 600}?

With the multiplier approach, does the visible area become smaller/larger depending on the viewport size? It doesn't seem right that different players see more or less of the game world just because their display resolution is different, atleast not by default. There is a lot of variance in display resolution/size combinations, ranging from things like 800x600 (usually windowed) all the way to 4K/8K, and small laptop displays to large TVs, which could result in very different experiences.

@mkuritsu
Copy link
Contributor Author

One thing I'm not sure if its the best approach is the size parameter added, I put it as a multiplier to the viewport the camera is drawing to. Would it be better to leave it like that or change it to be values to represent the plane size, something like a vec2{800, 600}?

With the multiplier approach, does the visible area become smaller/larger depending on the viewport size? It doesn't seem right that different players see more or less of the game world just because their display resolution is different, atleast not by default. There is a lot of variance in display resolution/size combinations, ranging from things like 800x600 (usually windowed) all the way to 4K/8K, and small laptop displays to large TVs, which could result in very different experiences.

Ok yes true, wasn't thinking in that way, my mistake I will change and commit with the other approach.

@RiscadoA
Copy link
Member

RiscadoA commented Sep 29, 2024

One thing I'm not sure if its the best approach is the size parameter added, I put it as a multiplier to the viewport the camera is drawing to. Would it be better to leave it like that or change it to be values to represent the plane size, something like a vec2{800, 600}?

With the multiplier approach, does the visible area become smaller/larger depending on the viewport size? It doesn't seem right that different players see more or less of the game world just because their display resolution is different, atleast not by default. There is a lot of variance in display resolution/size combinations, ranging from things like 800x600 (usually windowed) all the way to 4K/8K, and small laptop displays to large TVs, which could result in very different experiences.

Ok yes true, wasn't thinking in that way, my mistake I will change and commit with the other approach.

I guess we have four options here:

a) User specifies the final ortographic projection size - we simply don't take into account the target and viewport in the projection matrix math; leads to stretching but the user might want this in some cases I guess? I'm not sure

b) Multiply user specified size by the target*viewport size (what you have right now); AR is correct among all possible viewport configs, but users will be able to see a larger region of the world (in all directions) when rendering at higher resolutions.

c) User specifies the width of the projection matrix, and the height is calculated by multiplying the width by the aspect ratio of the target+viewport. AR is also correct on all possible configs, but users with higher display resolutions won't be able to view more of the world. Instead, users with weird aspect ratios might get to see more or less than what they should, but only in the vertical direction.

d) Same as above, but user specifies the height of the projection matrix instead of the width. I think this is more fitting than c), as in the previous options, users with extra wide displays would have their 'vertical view' very reduced. By specifying the height, we get the opposite. Users with extra wide displays get a larger 'horizontal view' but the 'vertical view' remains constant.

In my opinion, options c) and d) are the most useful, and we should probably allow the user to opt between them.
Maybe keep a float size; + an enum or boolean specifying which axis is being specified. What do you think?

Copy link
Member

@RiscadoA RiscadoA left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Pointed out some nitpicks + check out my comment above

CHANGELOG.md Outdated Show resolved Hide resolved
@tomas7770
Copy link
Contributor

In my opinion, options c) and d) are the most useful, and we should probably allow the user to opt between them.
Maybe keep a float size; + an enum or boolean specifying which axis is being specified. What do you think?

Looks good. I think the perspective camera basically follows d)? Alternatively we could have a) and let a separate plugin manage the size, but that might be adding unneeded complexity.

@mkuritsu
Copy link
Contributor Author

In my opinion, options c) and d) are the most useful, and we should probably allow the user to opt between them.
Maybe keep a float size; + an enum or boolean specifying which axis is being specified. What do you think?

Yes seems good, I was already making the d) option but I will add the enum to also allow for c) then.

@mkuritsu mkuritsu force-pushed the 1182-add-ortographiccamera-component branch from 00eba9b to df222d8 Compare September 29, 2024 13:07
@kuukitenshi kuukitenshi self-requested a review September 29, 2024 13:16
@RiscadoA
Copy link
Member

Just noticed this, don't use uppercase in the first letter of the commit messages; it should be: feat(scope): hey, not feat(scope): Hey

@mkuritsu mkuritsu force-pushed the 1182-add-ortographiccamera-component branch 2 times, most recently from 4e844ee to 4c2ae2f Compare September 29, 2024 13:39
Copy link
Member

@RiscadoA RiscadoA left a comment

Choose a reason for hiding this comment

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

Added my last two comments, after resolving my comments it should be good to go.
Don't forget to remove the _camera suffix from the files!

@RiscadoA RiscadoA added this to the 0.4 milestone Sep 29, 2024
@mkuritsu mkuritsu force-pushed the 1182-add-ortographiccamera-component branch from 4c2ae2f to 10d74a5 Compare September 29, 2024 14:24
@mkuritsu
Copy link
Contributor Author

mkuritsu commented Sep 29, 2024

Added my last two comments, after resolving my comments it should be good to go. Don't forget to remove the _camera suffix from the files!

ok I think all should be fixed sorry for the small mistakes

@RiscadoA
Copy link
Member

Added my last two comments, after resolving my comments it should be good to go. Don't forget to remove the _camera suffix from the files!

ok I think all should be fixed sorry for the small mistakes

Dw about it, sorry for being so picky!

Copy link
Contributor

@tomas7770 tomas7770 left a comment

Choose a reason for hiding this comment

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

LGTM!

@mkuritsu mkuritsu force-pushed the 1182-add-ortographiccamera-component branch from 10d74a5 to 3ecdf2d Compare September 29, 2024 18:11
@mkuritsu mkuritsu merged commit 7205c59 into main Sep 29, 2024
11 checks passed
@mkuritsu mkuritsu deleted the 1182-add-ortographiccamera-component branch September 29, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OrtographicCamera component
4 participants