THREE.MeshLine icon indicating copy to clipboard operation
THREE.MeshLine copied to clipboard

Remove resolution.

Open SuberFu opened this issue 9 years ago • 3 comments

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

SuberFu avatar May 20 '16 22:05 SuberFu

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?

spite avatar May 22 '16 09:05 spite

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).

SuberFu avatar May 23 '16 14:05 SuberFu

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

LightingRobot avatar Jul 23 '19 19:07 LightingRobot