Open SuberFu opened 8 years ago
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?
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).
The pixelWidthRatio isn't calculated correctly when the camera is in orthographic mode.
You don't need resolution to get the aspect ratio. You can replace the following line...
float aspect = resolution.x / resolution.y;
withfloat aspect = projectionMatrix[1][1] / projectionMatrix[0][0];
SinceprojectionMatrix[1][1] = f
, the field of view, whileprojectionMatrix[0][0] = f / aspectRatio
. https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_model_view_projection