spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.14k stars 381 forks source link

Remove resolution. #17

Open SuberFu opened 8 years ago

SuberFu commented 8 years ago

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 commented 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?

SuberFu commented 8 years ago

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 commented 5 years ago

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