Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## Re: [Algorithms] Projection

 Re: [Algorithms] Projection From: Joe Ante - 2000-11-30 22:44:42 ```Hi, What I have come up with is this, written for readability not speed: (Later I will of course only test BVs but I want to have the exact method first.) float CalculateTriangleAreaRotationless (Vector3D* v, float inFovy, float inScreenHeight, Vector3D& viewPoint) { float objectSpaceArea = Magnitude ((v[1] - v[0]) % (v[2] - v[0])) * 0.5F; Vector3D normal = GetNormal (v[0], v[1], v[2]); Vector3D centroid = (v[0] + v[1] + v[2]) / 3.0F; Vector3D difference = viewPoint - centroid; float distance = Magnitude (difference); // We want 1.0 when it faces the tri directly -> 0 degrees // We want 0.0 when the tri is invisible -> 90 degrees // It doesnt matter if the tri faces away from the viewer or not. float angle = fabs (normal * (difference / distance)); float screenSpaceArea = objectSpaceArea * sin (Deg2Rad (inFovy * 0.5F)) * inScreenHeight * angle / distance; return screenSpaceArea; } It seems to be wrong, but I dont really know why. (Propably because my knowledge about screenspace projection sucks, but that actually doesnt answer the question.) > For a quick hack, you could get it all working as you want for objects in > the centre > of the screen using just the Z-value, and then simply use the actual > distance to the > object centre instead. If a screen space area is something like object area > / z^2, then > a perception-space area is approximately area / dist^2. For objects on the > view axis, > this would give the same results. Using 1 / z^2 seems to give slightly better results but is not exactly correct too.(the ratio between zArea and distanceArea doesnt change that much) Exact imho means the same the same value you get with the zProjection method, when the object is in the center of the screen. Can anybody point out what is wrong with the above code. And why do some people say one should use z^2? I mean in the standard projection matrix you set element 3, 2 to -1. Thus when you project you scale x, y, z by -1.0/z. bye joe ```

### Thread view

 [Algorithms] Projection From: Joe Ante - 2000-11-30 09:26:09 ```Hi, For my texture LOD I am calculating the areas of the projected bounding boxes or if i want the exact value the actual geometry. Now what I have noted is that the more an objects moves away from the center of the screen, the bigger its screenspace becomes. (For example if you simpy rotate the camera) Now I dont really believe that this happens in reality as well. At least I have always thought that if I move my head or eyes the objects i see dont become larger. Is there actually a way to get rid of effect? (using a 4x4Matrix) And if not, does anyone have a good method to calculate the screenspacearea of an object in a way that the rotation of the camera has no effect on the screenspace area. If possible it should give me back the area in screenspace of the object if the camera directly faced the object (the object is in the center of the screen) bye joe ```
 Re: [Algorithms] Projection From: David Hunt - 2000-11-30 10:56:35 ```Yes this is an interesting artifact of calculating z as the parallel distance to a projection plane instead of as the distance to the centre of the projection - the camera. This is different from the way the eye works which is reading the result of a projection onto the inside of a sphere - not a plane. Instead of imagining the camera rotating - imagine the object rotating around a stationary camera. Clearly the circle described by the object will be closer to the projection plane near the outside of the frustum and further away near the centre. I think this explains the screenspace difference. On a total side note (I know this may sound weird but try it): Next time you're in a park or anywhere that's wide open and the horizon is relatively "flat". Lie down on your back - slowly bend your neck back so you're looking upside down and backwards. The automatic wiring in your eye and brain that normally makes the horizon look like a straight line when in fact it actually wraps all the way round you like a circle will stop working because you're upside down. You'll see the horizon as a large ellipse - well it works for me;) David ----- Original Message ----- From: "Joe Ante" To: Sent: Thursday, November 30, 2000 9:26 AM Subject: [Algorithms] Projection > Hi, > > For my texture LOD I am calculating the areas of the projected bounding > boxes or if i want the exact value the actual geometry. > > Now what I have noted is that the more an objects moves away from the center > of the screen, the bigger its screenspace becomes. (For example if you simpy > rotate the camera) > Now I dont really believe that this happens in reality as well. At least I > have always thought that if I move my head or eyes the objects i see dont > become larger. > Is there actually a way to get rid of effect? (using a 4x4Matrix) > > And if not, does anyone have a good method to calculate the screenspacearea > of an object in a way that the rotation of the camera has no effect on the > screenspace area. If possible it should give me back the area in screenspace > of the object if the camera directly faced the object (the object is in the > center of the screen) > > bye joe > > _______________________________________________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list ```
 Re: [Algorithms] Projection From: Andrew Jones - 2000-11-30 12:34:33 ```----- Original Message ----- From: Joe Ante To: Sent: Thursday, November 30, 2000 9:26 AM Subject: [Algorithms] Projection > Hi, > > For my texture LOD I am calculating the areas of the projected bounding > boxes or if i want the exact value the actual geometry. > > Now what I have noted is that the more an objects moves away from the center > of the screen, the bigger its screenspace becomes. (For example if you simpy > rotate the camera) > Now I dont really believe that this happens in reality as well. At least I > have always thought that if I move my head or eyes the objects i see dont > become larger. The reason that this happens is because the perspective projection projects onto an imaginary 2d screen rectangle in front of your eyes. If you increase the FOV then this imaginary screen rectangle gets closer to your eyes (or relatively bigger). Your monitor screen is the actual physical embodiment of this. If you set your FOV in a game like quake to a high value, the visible screen distorts really badly. This is because your eyes are too far from the monitor for the given FOV. For any FOV in a game the apparaent projection will only look visually 'correct' if you have your eyes the right distance from the monitor. For a high FOV, you can move to within a few inches of the monitor and look straight forwards. You are then looking at the badly distorted outer regions of the monitor from a very high angle, and hey-presto - the apparent distortion disappears. In terms of texture LOD changes for an object at constant distance, allthough the screen space LOD changes, this is only because the ANGULAR pixel resolution of a monitor as you look at it varies. The pixels in the centre of the screen are larger, as percieved, than those around the egdes. A monitor has higher percived angular resolution around the edges than in the centre. Becuase texture LOD calculations are based on isotropic screen space pixels, a texture on an object will be more detailed in pixel space when viewed off-axis where the screen space pixels have a higher angular resolution. This is just the beginning of the whole perceptual resolution issue. If visitors to virtual worlds could be trusted to look at the centre of the monitor and always look with the mouse, then it would be worth your monitor having a 'fovea' to match your eye. (The fovea is a region on your retina corresponding to the centre of your vision which has much higher resolution than the rest of your vision). As well as the edges of the display having larger, low resolution pixels because of the projection from the monitor onto your eye, they could have even lower resolution as they would fall in your peripheral vision. Next step - write rasterizing hardware to deal with non-linear pixel distribution. Hell, we might not even need to use rectangular pixels. ;-) What we really need is VR projectors that sit inside your eyeballs to make sure you always know where the user is looking :). > > And if not, does anyone have a good method to calculate the screenspacearea > of an object in a way that the rotation of the camera has no effect on the > screenspace area. If possible it should give me back the area in screenspace > of the object if the camera directly faced the object (the object is in the > center of the screen) > For a quick hack, you could get it all working as you want for objects in the centre of the screen using just the Z-value, and then simply use the actual distance to the object centre instead. If a screen space area is something like object area / z^2, then a perception-space area is approximately area / dist^2. For objects on the view axis, this would give the same results. Andrew Jones ```
 Re: [Algorithms] Projection From: Joe Ante - 2000-11-30 22:44:42 ```Hi, What I have come up with is this, written for readability not speed: (Later I will of course only test BVs but I want to have the exact method first.) float CalculateTriangleAreaRotationless (Vector3D* v, float inFovy, float inScreenHeight, Vector3D& viewPoint) { float objectSpaceArea = Magnitude ((v[1] - v[0]) % (v[2] - v[0])) * 0.5F; Vector3D normal = GetNormal (v[0], v[1], v[2]); Vector3D centroid = (v[0] + v[1] + v[2]) / 3.0F; Vector3D difference = viewPoint - centroid; float distance = Magnitude (difference); // We want 1.0 when it faces the tri directly -> 0 degrees // We want 0.0 when the tri is invisible -> 90 degrees // It doesnt matter if the tri faces away from the viewer or not. float angle = fabs (normal * (difference / distance)); float screenSpaceArea = objectSpaceArea * sin (Deg2Rad (inFovy * 0.5F)) * inScreenHeight * angle / distance; return screenSpaceArea; } It seems to be wrong, but I dont really know why. (Propably because my knowledge about screenspace projection sucks, but that actually doesnt answer the question.) > For a quick hack, you could get it all working as you want for objects in > the centre > of the screen using just the Z-value, and then simply use the actual > distance to the > object centre instead. If a screen space area is something like object area > / z^2, then > a perception-space area is approximately area / dist^2. For objects on the > view axis, > this would give the same results. Using 1 / z^2 seems to give slightly better results but is not exactly correct too.(the ratio between zArea and distanceArea doesnt change that much) Exact imho means the same the same value you get with the zProjection method, when the object is in the center of the screen. Can anybody point out what is wrong with the above code. And why do some people say one should use z^2? I mean in the standard projection matrix you set element 3, 2 to -1. Thus when you project you scale x, y, z by -1.0/z. bye joe ```
 Re: [Algorithms] Projection From: Johan Hammes - 2000-11-30 14:07:20 ```> Now what I have noted is that the more an objects moves away from the center > of the screen, the bigger its screenspace becomes. (For example if you simpy > rotate the camera) > Now I dont really believe that this happens in reality as well. At least I > have always thought that if I move my head or eyes the objects i see dont > become larger. This is actually correct, remember that your screen is flat, so as objects go from the center to the side of your screen they actually go further away from your eye, so they have to be bigger in screenspace to stay the same size for your eye. The problem comes when the FOV from your eye to the screen differs from teh FOV of teh application, you have the same problem when looking the wrong way through binoculars. Johan ```
 [Algorithms] test From: Êåðèì Áîð÷àåâ - 2000-11-30 18:02:04
 Re: [Algorithms] Projection From: Stephen J Baker - 2000-11-30 15:43:11 ```On Thu, 30 Nov 2000, Joe Ante wrote: > For my texture LOD I am calculating the areas of the projected bounding > boxes or if i want the exact value the actual geometry. > > Now what I have noted is that the more an objects moves away from the center > of the screen, the bigger its screenspace becomes. (For example if you simpy > rotate the camera) > Now I dont really believe that this happens in reality as well. At least I > have always thought that if I move my head or eyes the objects i see dont > become larger. What's happening is that you have a field of view that's larger than it should be. When you sit in front of your CRT, your screen subtends an angle of maybe 40 or 50 degrees at your eye - but I'm betting that if this effect is significant - then your rendered field of view is more like 90 degrees. This is **wrong** - but we all do it (in games) in order to allow you to see things off to the side more easily. If things were set up with the correct field of view - then you should realise that the center of the screen is closer to your eyes than the edges of the screen. Hence, we have to draw things larger at the edges in order to compensate for the real-world perspective shrink due to that differing range from eye to screen. Hence, OpenGL draws things exactly correctly for a flat screen and an appropriate field of view. If you try to display on a curved screen - or with an incorrect field of view - then distortion is inevitable and all bets are off. > Is there actually a way to get rid of effect? (using a 4x4Matrix) No. Matrices can only do linear changes - and even if you could do it, you'd need to draw triangles with curved edges - and current rendering hardware can't do that. ---- Steve Baker (817)619-2657 (Vox/Vox-Mail) L3Com/Link Simulation & Training (817)619-2466 (Fax) Work: sjbaker@... http://www.link.com Home: sjbaker1@... http://web2.airmail.net/sjbaker1 ```