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

Add support for scale to OrthograpicProjection #322

Closed
wants to merge 2 commits into from

Conversation

DJMcNab
Copy link
Member

@DJMcNab DJMcNab commented Aug 24, 2020

Example:
image

Before this change, it was impossible to get a larger (or smaller) image from an OrthographicProjection - this is what the new example looks like with scale set to 1 (old behaviour):
image

Notes:
The scale could be inverted, but this interpretation also makes sense
Maybe there's a better name than scale - what do other engines call this?
Maybe it could use the Scale component - would require passing a scale parameter to CameraProjection::update, which would be meaningless for PerspectiveProjection, unless it effected fov somehow

@Moxinilian Moxinilian added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Aug 24, 2020
@MichaelHills
Copy link
Contributor

If you used a Vec3, aka NonUniformScale (or supported both?), would that let you flip Y? I think right now, X is right and Y is up but I wanted to flip it so Y is down.

@DJMcNab
Copy link
Member Author

DJMcNab commented Aug 31, 2020

The issue with that is how would NonUniformScale work for PerspectiveProjection?

@MichaelHills
Copy link
Contributor

I was purely talking about OrthographicProjection as that's where you added the scalar scale.

@chemicstry
Copy link

I believe you can always flip, scale, rotate by just camera Transform?

This PR makes it easier by detaching projection from screen size. You could do the same with existing orthographic projection, but you would have to constantly rescale camera Transform based on window size.

@chemicstry
Copy link

Sorry I mixed this with other similar PR #400. I think it is better, because you can adjust scale with just Transform, no need to introduce additional variable.

@MichaelHills
Copy link
Contributor

Thanks I was able to use Transform to flip Y (and ran into face culling issues because the winding order flipped!). Just using Scale here makes sense.

@chemicstry
Copy link

What Transform did you use? Maybe you inverted y?

I just tested horizontal and vertical flipping by setting x or y scaling to -1.0 and there were no issues. Rotation around y should work too

@DJMcNab
Copy link
Member Author

DJMcNab commented Sep 3, 2020

I've experimented some more with this, and discovered that using a scale does work, thanks to

let camera_matrix: [f32; 16] =
(camera.projection_matrix * transform.value.inverse()).to_cols_array();

However, the actual problem is with the clipping planes. I do think the whole projection scheme could do with some work to fix the clipping issue (see also #400).

@DJMcNab DJMcNab closed this Sep 3, 2020
@DJMcNab DJMcNab deleted the orthograpic-scale branch February 19, 2021 20:55
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 C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants