Rendering an OpenGL texture where each pixel represents a fix area at a given distance from the camera

77 Views Asked by At

I wish to size an OpenGL texture so that at the maximum clipping distance each pixel will represent a fixed area, say 0.25 m2, i.e. each pixel represents a square of 0.5m by 0.5m.

For example.

GLint TextureWidth = GLint(HorizViewAngle*pi*RangeDistance / 180.0 / ResolutionAtDistance);
GLint TextureHeight = GLint(VertViewAngle*pi*RangeDistance / 180.0 / ResolutionAtDistance);

HorizViewAngle will be typically 120 degrees, with a VertViewAngle of 60, which is based around a humans field of view. Furthermore, RangeDistance value will be 100 and ResolutionAtDistance = 0.5

The above code is base on the formula of an Arc = θ × (π/180) × r.

For setting the clipping distance I am using OpenGL Utility Library (GLU) gluPerspective

GLdouble AspectRatio = HorizViewAngle / VertViewAngle ;
gluPerspective(VertViewAngle, AspectRatio, 0.01, RangeDistance);

I was wondering if anyone else has had experience of doing this in OpenGL and what issues I should be looking out for. Such as image distortion which could impact the projected image. For example, I believe if I was to extend the field of view to 180 degrees, then it would be better to render two 90 degree textures and stitch them together.

0

There are 0 best solutions below