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

Remove resolution. #17

Open
SuberFu opened this issue May 20, 2016 · 3 comments
Open

Remove resolution. #17

SuberFu opened this issue May 20, 2016 · 3 comments

Comments

@SuberFu
Copy link

SuberFu commented May 20, 2016

You don't need resolution to get the aspect ratio. You can replace the following line...
float aspect = resolution.x / resolution.y;
with
float aspect = projectionMatrix[1][1] / projectionMatrix[0][0];
Since projectionMatrix[1][1] = f, the field of view, while projectionMatrix[0][0] = f / aspectRatio.
https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_model_view_projection

@spite
Copy link
Owner

spite commented May 22, 2016

That's very useful, but it doesn't really remove the need for resolution, since I'm using it in the following line I'm using it to calculate the size of 1px on screen.

float pixelWidthRatio = 1. / (resolution.x * projectionMatrix[0][0]);

If it wasn't for that, I could remove the uniform. Do you know a way?

@SuberFu
Copy link
Author

SuberFu commented May 23, 2016

Hm, that's a good point. I'm not sure how to remove that.
For better or worse, at least now you just need to pass in resolution.x (one float) instead of vec2 (two floats).

@LightingRobot
Copy link

The pixelWidthRatio isn't calculated correctly when the camera is in orthographic mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants