Here is a tough calculation problem !
Knowing
- the # of pixel of a texture (like earth 16K)
- the radius of the body (6378km)
- the screen resolution (1024x768)
What is the lowest altitude that brings the most detailed picture ?
(I mean being lower does not improve the details and gives blur)
Who could give the formula ?
The next question is how big should be the texture if I want a detailed picture on my screen at a given altitude ?
Or what Screen dimension should I have to .... etc.
Eric
Altitude Max Res Formula
-
Topic authorCalculus
-
- Posts: 169
- Joined: 31.01.2002
- With us: 22 years 9 months
- Location: Wisconsin
figure 1 pixel = 1 km....What is the circumference of the earth? average it out to be roughly that in one of the standard sizes....I would put that at 16,384 x 8192 as the next step up acceptable...
or even further 1 meter = 1 pixel....Right now nothing can handle this hehe....maybe 2 gigs of video RAM using a dds file....
If your wanting an average 1 km altitude should be sufficant for a 16k texture....
or even further 1 meter = 1 pixel....Right now nothing can handle this hehe....maybe 2 gigs of video RAM using a dds file....
If your wanting an average 1 km altitude should be sufficant for a 16k texture....
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!
-
- Posts: 169
- Joined: 31.01.2002
- With us: 22 years 9 months
- Location: Wisconsin
Rassilon wrote:figure 1 pixel = 1 km....What is the circumference of the earth? average it out to be roughly that in one of the standard sizes....I would put that at 16,384 x 8192 as the next step up acceptable...
or even further 1 meter = 1 pixel....Right now nothing can handle this hehe....maybe 2 gigs of video RAM using a dds file....
If your wanting an average 1 km altitude should be sufficant for a 16k texture....
Well, maybe within as little as 2-3 years, we could see an NV45, or an R500. With 2 GB of video RAM at 1066 MHz =P
It's been a while since I've done any pythagoras but wouldn't the formula be:
tan(FOV/2) = (horizontal km in FOV / 2) / Altitude
?
So if:
FOV = field of view
A = horizontal size of celestia window in pixels
B = resolution of texture in km/pixel
H KM in FOV = A * B
let's say FOV = 45, A = 1000 & B = 4.75 (for an 8192x4096 Earth texture)
tan(45) = (1000*4.75 / 2) / Altitude
0.414214 = 2375 / Altitude
Altitude = 2375 / 0.414214
Altitude = 5733.75km when the texture's pixels are at 1:1 with the display's pixels
NB: Doesn't take into account the curvature of the Earth
Does that sound right? Seems a bit too high...
tan(FOV/2) = (horizontal km in FOV / 2) / Altitude
?
So if:
FOV = field of view
A = horizontal size of celestia window in pixels
B = resolution of texture in km/pixel
H KM in FOV = A * B
let's say FOV = 45, A = 1000 & B = 4.75 (for an 8192x4096 Earth texture)
tan(45) = (1000*4.75 / 2) / Altitude
0.414214 = 2375 / Altitude
Altitude = 2375 / 0.414214
Altitude = 5733.75km when the texture's pixels are at 1:1 with the display's pixels
NB: Doesn't take into account the curvature of the Earth
Does that sound right? Seems a bit too high...
The formula I get is:
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
where:
R = radius of planet (km)
T = number of texels in the texture map around the circumference
F = field of view (in radians)
P = pixels across width of window
A = altitude (above surface) at which one texel fills one pixel at the center of the window (km)
PI = the ratio of circumference to diameter for a circle
Using the values:
R = 6378
F = PI/4 (45 degrees)
P = 1024
PI = 3.14159
I get the following altitudes for the given texture width:
1024 ... 48373 km
2048 ... 24187 km
4096 ... 12093 km
8192 ... 6047 km
16384 ... 3023 km
32767 ... 1512 km
65536 ... 756 km
131072 ... 378 km
...unless I've made some mistake (always a possibility).
But my value of 6047 km for a 8192 texture is close to Ortolan's value of 5734 km, which suggests we're in the ballpark. Notice that you need a very large texture to get full resolution at ISS altitude.
If anyone's interested, here's my derivation:
Suppose we look through a pixel at the center of the window, and the edges of the pixel match the edges of a single texel on the planet's surface. Viewed in cross-section from the top, we have two isoceles triangles with a common base, the chord connecting the texel edges. One of these triangles connects the points on the texel edges to the eye point, the other triangle connects those points to the center of the planet.
We'll use the following symbols:
C = angle subtended by texel at planet's Center
E = angle subtended by pixel/texel at Eyepoint
D = Distance from planet's center to eyepoint
R = Radius of planet
We can divide the two isoceles triangles down the middle to get two right triangles, again with a common base.
If we let X be the length of the base, then basic trigonometry gives us:
SIN(C/2) = X / R
and
TAN(E/2) = X /(D-R*COS(C/2))
Combining these equations gives us:
R*SIN(C/2) = (D-R*COS(C/2))*TAN(E/2)
and solving for D gives us:
D = R*(COS(C/2)+(SIN(C/2)/TAN(E/2)))
Now since the texture maps uniformly around the circumference, we have:
C = 2*PI/T
Substituting for C in the formula for D gives us:
D = R*(COS(PI/T)+SIN(PI/T)/TAN(E/2))
Because the screen is flat the angle subtended at the eyepoint is a bit more complicated to calculate. If V is the distance (in pixel widths) from the eyepoint to the central pixel then:
TAN(F/2) = (P/2)/V
so
V = P/(2*TAN(F/2))
and
TAN(E/2) = (1/2)/V = 1/(2*V) = TAN(F/2)/P
so
E = 2*ARCTAN((TAN(F/2)/P)
Now substituting for E in the formula for D gives us:
D = R*(COS(PI/T)+SIN(PI/T)/TAN((2*ARCTAN((TAN(F/2)/P))/2))
D = R*(COS(PI/T)+SIN(PI/T)/TAN(ARCTAN((TAN(F/2)/P)))
D = R*(COS(PI/T)+SIN(PI/T)/(TAN(F/2)/P))
D = R*(COS(PI/T)+P*SIN(PI/T)/TAN(F/2))
To get the altitude we subtract the radius and get:
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
Does that sound right?
- Hank
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
where:
R = radius of planet (km)
T = number of texels in the texture map around the circumference
F = field of view (in radians)
P = pixels across width of window
A = altitude (above surface) at which one texel fills one pixel at the center of the window (km)
PI = the ratio of circumference to diameter for a circle
Using the values:
R = 6378
F = PI/4 (45 degrees)
P = 1024
PI = 3.14159
I get the following altitudes for the given texture width:
1024 ... 48373 km
2048 ... 24187 km
4096 ... 12093 km
8192 ... 6047 km
16384 ... 3023 km
32767 ... 1512 km
65536 ... 756 km
131072 ... 378 km
...unless I've made some mistake (always a possibility).
But my value of 6047 km for a 8192 texture is close to Ortolan's value of 5734 km, which suggests we're in the ballpark. Notice that you need a very large texture to get full resolution at ISS altitude.
If anyone's interested, here's my derivation:
Suppose we look through a pixel at the center of the window, and the edges of the pixel match the edges of a single texel on the planet's surface. Viewed in cross-section from the top, we have two isoceles triangles with a common base, the chord connecting the texel edges. One of these triangles connects the points on the texel edges to the eye point, the other triangle connects those points to the center of the planet.
We'll use the following symbols:
C = angle subtended by texel at planet's Center
E = angle subtended by pixel/texel at Eyepoint
D = Distance from planet's center to eyepoint
R = Radius of planet
We can divide the two isoceles triangles down the middle to get two right triangles, again with a common base.
If we let X be the length of the base, then basic trigonometry gives us:
SIN(C/2) = X / R
and
TAN(E/2) = X /(D-R*COS(C/2))
Combining these equations gives us:
R*SIN(C/2) = (D-R*COS(C/2))*TAN(E/2)
and solving for D gives us:
D = R*(COS(C/2)+(SIN(C/2)/TAN(E/2)))
Now since the texture maps uniformly around the circumference, we have:
C = 2*PI/T
Substituting for C in the formula for D gives us:
D = R*(COS(PI/T)+SIN(PI/T)/TAN(E/2))
Because the screen is flat the angle subtended at the eyepoint is a bit more complicated to calculate. If V is the distance (in pixel widths) from the eyepoint to the central pixel then:
TAN(F/2) = (P/2)/V
so
V = P/(2*TAN(F/2))
and
TAN(E/2) = (1/2)/V = 1/(2*V) = TAN(F/2)/P
so
E = 2*ARCTAN((TAN(F/2)/P)
Now substituting for E in the formula for D gives us:
D = R*(COS(PI/T)+SIN(PI/T)/TAN((2*ARCTAN((TAN(F/2)/P))/2))
D = R*(COS(PI/T)+SIN(PI/T)/TAN(ARCTAN((TAN(F/2)/P)))
D = R*(COS(PI/T)+SIN(PI/T)/(TAN(F/2)/P))
D = R*(COS(PI/T)+P*SIN(PI/T)/TAN(F/2))
To get the altitude we subtract the radius and get:
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
Does that sound right?
- Hank
-
Topic authorCalculus
Good work!
Actually both formulas are correct.
I just like better the first one (from Ortolan) that gives:
Altitude A = P * PI * R / T / TAN(F/2)
Where
R = radius of planet (km)
T = number of texels in the texture map around the circumference
F = field of view
P = pixels across width of window
A = altitude (above surface) at which one texel fills one pixel at the center of the window (km)
PI = the ratio of circumference to diameter for a circle
It gives exactly the same results as HankR's formula.
The discrepancy for the 8196 texture is due to the figure 4.75 km/pixel in Ortolan formula.
For the moon (R= 1737.53) the results are
1024 13178km
2048 6589km
4096 3295km
8192 1647km
16384 824km
32768 412km
65536 206km
131072 103km
For mars (R=3394)
1024 25742km
2048 12871km
4096 6435km
8192 3218km
16384 1609km
32768 804km
65536 402km
131072 201km
It seems that we'll have to wait a while to have full resultion at low altitude!!!
---Eric
Actually both formulas are correct.
I just like better the first one (from Ortolan) that gives:
Altitude A = P * PI * R / T / TAN(F/2)
Where
R = radius of planet (km)
T = number of texels in the texture map around the circumference
F = field of view
P = pixels across width of window
A = altitude (above surface) at which one texel fills one pixel at the center of the window (km)
PI = the ratio of circumference to diameter for a circle
It gives exactly the same results as HankR's formula.
The discrepancy for the 8196 texture is due to the figure 4.75 km/pixel in Ortolan formula.
For the moon (R= 1737.53) the results are
1024 13178km
2048 6589km
4096 3295km
8192 1647km
16384 824km
32768 412km
65536 206km
131072 103km
For mars (R=3394)
1024 25742km
2048 12871km
4096 6435km
8192 3218km
16384 1609km
32768 804km
65536 402km
131072 201km
It seems that we'll have to wait a while to have full resultion at low altitude!!!
---Eric
-
Topic authorCalculus
Nice work Hank...
I wonder if there will be a possible future in rendering a texture according to distance...The problem with this is how would the texture be handled?...If we want perfect resolution all the way to the surface the texture would have to be a monster...but I have seen where like in dds format the texture is broken down to load faster...The next step I suppose is being drawn according to eyesight...similar to raytracing in such games as Quake or Doom...
Might have to have multiple dds files for each section of the planet...then of course theres displacement maps for mountains and hills...Cant wait to see this done effectively...Might be a while so I wont hold my breath
I wonder if there will be a possible future in rendering a texture according to distance...The problem with this is how would the texture be handled?...If we want perfect resolution all the way to the surface the texture would have to be a monster...but I have seen where like in dds format the texture is broken down to load faster...The next step I suppose is being drawn according to eyesight...similar to raytracing in such games as Quake or Doom...
Might have to have multiple dds files for each section of the planet...then of course theres displacement maps for mountains and hills...Cant wait to see this done effectively...Might be a while so I wont hold my breath
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!
For the curious (like me), I believe the two formulae give (nearly) identical results for large textures because for small angles (in radians):
COS(A) ~ 1
and
SIN(A) ~ A.
So if T is large, PI/T is small, and:
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
~ R*(1+(P*(PI/T)/TAN(F/2))-1)
= R*((P*(PI/T)/TAN(F/2)))
= R*P*PI/T/TAN(F/2)
= P*PI*R/T/TAN(F/2)
- Hank
COS(A) ~ 1
and
SIN(A) ~ A.
So if T is large, PI/T is small, and:
A = R*(COS(PI/T)+(P*SIN(PI/T)/TAN(F/2))-1)
~ R*(1+(P*(PI/T)/TAN(F/2))-1)
= R*((P*(PI/T)/TAN(F/2)))
= R*P*PI/T/TAN(F/2)
= P*PI*R/T/TAN(F/2)
- Hank
-
- Posts: 986
- Joined: 16.08.2002
- With us: 22 years 3 months
- Location: USA, East Coast
-
Topic authorCalculus
excel spreadsheet for calculating optimum altidude
I worked up a quick and dirty excel sheet to calculate the best viewing distance to a planet or object. It does contain macros, so feel free to disable them if you're concerned about such things. Hope someone enjoys it...
http://www.textbat.org/celestia_optimum_altitude.xls
http://www.textbat.org/celestia_optimum_altitude.xls