Link to here: walter.bislins.ch/RefractionSim
The Demos behind the black buttons are based on the excellent website about An Introduction to Mirages by Andrew T. Young. Please follow the links below the buttons shown as "more infos" to go to the specific page on his website where he explains the phenomena in detail (sometimes you have to press F5 to see the contents).
Intro Reset Std 2km 4.8km 9.5km Looming Towering Stooping Inferior Mirage Superior Mirage Oil Platforms Chicago strong Looming Chicago Superior Mirage Salt Lake City Stooping Sunset FE Curved God Rays
The images of the simulation are composed of pixels. Each pixel has at least one assosiated light ray comming from the scene and carrying a color value from the surface of at least one object.
Each light ray is divided into many Ray Segments. The start point and direction of the first Ray Segment is determined by the location of the image pixel with respect to the observer.
Then depending on the position and direction of the Ray Segment the Refraction Coefficient and from that the bending of the Ray Segment is calculated as described at How Custom Refraction is derived. From this bending the end position and direction of the Ray Segment can be calculated. This gives the start point of the next Ray Segment and so on.
Each Ray Segment is checked against all Targets of the scene. If the Ray Segment intersects a Target, the exact intersection point is calculated and which target coordinates are hit by the Ray Segment. The target coordinates are used to determine the color of the target at this coordinates. If the target is opaque, the calculation of the light ray ends here and the image pixel color is defined. If the Target is transparent, the color is stored for later and the calculation of the light ray continues until the next opaque Target or the Horizon is hit. Then all stored colors are combined and define the image pixel color of this light ray. It is also possible to assign multiple light rays to one pixel to get smoother edges in the image (antialiasing). This is accomplished with the Obersampling setting.
Because the simulation makes use of curved Ray Segments, only very few segments are needed, compared to simulations that use a straight Ray Segment approach, to achieve the same accuracy. This allows to simulate even Astronomical Refraction with very long light rays in a short time, see the Sunset Demo.
The bending of each light ray is dependent on the Refraction Curve along the path of the light ray. The simulation splits each light ray into a number of segments and calculates the bending of each segment and joins the segments together to a single light ray.
The curvature of a Light Ray Segment depends on the Refraction Coefficient at the location of the Ray Segment. The Refraction Coefficient depends on the atmospheric conditions at the location of the Ray Segment and the vertical direction of the light ray segment.
The atmospheric conditions are derived from the inputs in the Barometric Settings panel. You can specify two different barometric parameter sets for two different locations, eg. for the location of the observer via Baro Measure Dist at the Baro Observer panel and the location of the farthest Target or the Horizon at the Baro Target panel. If you don't specify barometric data for the second panel, the parameters from the first panel are used along the whole light path. If you specify separate target parameters, the values between are interpolated and for distances beyond that the target parameters are kept fixed.
You can enter Pressure, Pressure Altitude and some pairs of (altitude, temperature). The simulation contains a default barometric model as defined by the Standard Atmosphere. The entered parameters modify this model accordingly:
The simulation can now calculate the Refraction Coefficient for any point in the atmosphere between observer and Horizon. The Refraction Coefficient, together with the vertical angle of the Ray Segment at a certain position and altitude, determine the curvature of the Ray Segment.
To calculate the Refraction Coefficient from the barometric data and the vertical angle of the Ray Segment the following equation is used:
Note: The constants in the equation above are slightly different in different parts of the world due to different mean atmospheric conditions. Their visual differences are minute but must be taken into account on precise survey measurements over long distances.
The curvature of the Ray Segment is then calculated by the following equation:
Note: The same equations are used for Globe and Flat Earth, because the physics of Refraction is not dependent on the shape of the earth. The curvature or flatness of the air gradient is taken into account by the simulator. The equations do NOT assume a globe earth! The radius of the earth RE in the equation is due to the way the Refraction Coefficient k is defined. k could be defined as the curvature of the light ray without scaling it with the readius of the earth. You can modify (1) accordingly so that you can calculate the curvature of the light ray directly without any reference to the radius of the earth:
The App can be called with some URL parameters to set a specific stored App State:
On the Save/Restore Panel click Get App URL to get an URL from the current state of the App. Copy this URL into any Web-Form (e.g. YouTube comment). Clicking the link will call this page with the saved state.
The parameters may be combined in one URL, eg. &demo=Sunset&tab=Targets
A Target can be sized as needed. This is important if you use images that show a certain scene like a skyline.
A Target can have Boundaries/Limits or it can be infinetely extended in any direction. If a Target is an image without boundary limits, the image is repeated.
To create a new Target, open the Targets panel and click on New. A copy of an internal Target Template is created. You can also create a Copy of the current selected Target by clicking Clone and then change some parameters. Or you can create one of the Preset Targets.
Note: Targets are treated differently in the Model Flat Earth and Globe Earth. On the Flat Earth model the targets are always flat planes. On the Globe Model the same targets are wraped around the globe, so targets that are not entirely vertical are curved. This allows to create targets like water images that are flat on the Flat Earth display but curved on the Globe Earth display.
Note: For some scenes the order of the Targets may be important. You can move the Targets in the sequence with the buttons Move Up and Move Down.
Because each simulated Light Ray is dividet into many Ray Segments, a limit must be defined so that the calculation is stopped if no opaque Target is hit. This limit is called the Horizon.
A color gradient can be specified for the Horizon, so that a light ray hitting the horizon has a defined color assigned to it. The specified Horizon Distance limits how far a light ray has to be calculated.
In the simulation each light ray is dividet into many Ray Segments. For each Ray Segment the Ray Curvature is calculated separately from the Refraction Coefficient at the position of the Ray Segment, see How Custom Refraction is derived.
The Refraction Coefficient is a measure of the Ray Curvature of a light ray with respect to the radius of the earth. The Refraction Coefficient is defined as:
A value of k = 0 means the Ray Segment is straight. A value of k = 1 means the Ray Segment has the same curvature radius as the earth. Ray segments with negative Coefficients are bent upwards.
The Refraction Coefficient can be calculated from atmospheric properties such as Pressure, Temperature and Temperature Gradient at any position of a light ray segment. It also depends on the vertical angle of the ray segment, see equation (1).
The Refraction Coefficient in reality is slightly different at each location of a light ray from the observer to the Target. In practical applications like survey a mean Refraction Coefficient may be used as an approximation. The simulation calculates the individual Refraction Coefficient for each Ray Segment along the whole way from the observer to a target.
The Refraction Curve describes the Refraction Coefficient as a function of altitude, so each altitude is a certain Refraction Coefficient assigned. The Refraction Curve is derived from the Barometric Settings, see How Custom Refraction is derived.
The simulation calculates two Refraction Curves, one for the observer location and one for a Target location the user can specify. For all locations between observer and target the Refraction Coefficient is derived by interpolating the Refraction Coefficient from this two curves according to the altitude and location of a Ray Segment. If no Barometric Settings are defined for a target location, the observer Refraction Curve is used everywhere.
The Pressure changes with altitude. Such a change is described by a Pressure Curve, which gives the Pressure as a function of altitude.
The temperature changes with altitude. Such a change is described by a Temperature Curve, which gives the Temperature as a function of altitude.
The simulation uses some discrete user specified temperature values to calculate a smooth Temperature Curve through these points. The calculated curve blends into the curve as defined by the Standard Atmosphere above the highest specified Temperature point.
The Temperature Gradient Curve is a mathematically curve that connects all Temperature Gradient values for a specific altitude and is derived from the Temperature Curve. The Temperature Gradient Curve is used in the calculation of the Refraction Curve.
The Standard Atmosphere defines curves for Temperature, Pressure, air Density and Temperature Gradient for each altitude up to about 85 km. These curves are derived from mean values and used as a reference in many applications, eg. in aviation.
The simulation contains the Standard Atmosphere model and uses it for regions the user does not provide atmospheric data data.