Coordinate systems: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
==Introduction==
==Introduction==
This page describes the various reference frames for coordinates used in flightgear. This is mostly targeted at shader development, for cartesian/geodetic etc. systems, we have other pages.
This page describes the various reference frames for coordinates used in flightgear. This is mostly targeted at shader development, for cartesian/geodetic etc. systems, we have other pages.
==Disclaimer==
I wrote these from my memory, if you notice some is wrong, please fix it! :)


==Coordinates in shader programs==
==Coordinates in shader programs==
Line 20: Line 23:
Terrain is referenced with origo (0,0,0) being at the center of the tile, lying on the mean sea level.
Terrain is referenced with origo (0,0,0) being at the center of the tile, lying on the mean sea level.
Reference frame is z = up, x and y are in lat and lon directions.
Reference frame is z = up, x and y are in lat and lon directions.
Every tile's frame is in relation to that tile, so the z is always up on that tile's center point.
===Objects===
Objects depend a bit on the modeller, but usually origo is at the bottom of the building, in the center.
Z is up, x and y most likely are lat and lon, since usually people use some reference images underneath. But not always, x and y might be to any direction depending on the modeller.


===Clouds===
===Clouds===
Clouds/cloudlets have origo at the center of the cloud. gl_Color has the center of each cloudlet with relation to origo.
Clouds/cloudlets have origo at the center of the cloud. gl_Color has the center of each cloudlet with relation to origo.
Z is up, x and y are lat/lon direction.
Cloud layer used to be flat, so that z is same way on all clouds, but I think this got fixed and now the layers are curved. I don't know if z is relative to that position or not.
===Skydome===
Skydome is always centered on the camera, so that origo is under the view, at mean sea level.
Z is up, x and y are rotated so that x (or y...) axis points towards the sun. That way the sunset effects are easier to do.

Revision as of 10:53, 2 October 2011

Introduction

This page describes the various reference frames for coordinates used in flightgear. This is mostly targeted at shader development, for cartesian/geodetic etc. systems, we have other pages.

Disclaimer

I wrote these from my memory, if you notice some is wrong, please fix it! :)

Coordinates in shader programs

Vertex program

Vertex program handles every vertex of a model. It is executed for every vertex only, and can use attributes like vertex position, color, normal etc. Vertex program's purpose is to transform vertices to screen space (i.e. calculate their position on the display).

gl_Vertex has the vertex in object's reference frame. After multiplying by gl_ModelViewMatrix, we get the vertex coordinate with relation to camera (eye point). We call this later on the eye frame. Further multiplying this with gl_ProjectionMatrix (or with the combined gl_ModelViewProjectionMatrix) we get a screen space coordinate. We call this later screen or view frame.

Fragment program

Fragment program handles all pixels that are on the screen. It cannot change pixel's position, but only calculate its color and transparency. It gets parameters from a vertex shader, and interpolates between the values at those points.

You can access the screen coordinate with gl_FragCoord and gl_FragDepth.


Coordinate reference frames

Terrain

Terrain is referenced with origo (0,0,0) being at the center of the tile, lying on the mean sea level. Reference frame is z = up, x and y are in lat and lon directions.

Every tile's frame is in relation to that tile, so the z is always up on that tile's center point.

Objects

Objects depend a bit on the modeller, but usually origo is at the bottom of the building, in the center. Z is up, x and y most likely are lat and lon, since usually people use some reference images underneath. But not always, x and y might be to any direction depending on the modeller.

Clouds

Clouds/cloudlets have origo at the center of the cloud. gl_Color has the center of each cloudlet with relation to origo. Z is up, x and y are lat/lon direction.

Cloud layer used to be flat, so that z is same way on all clouds, but I think this got fixed and now the layers are curved. I don't know if z is relative to that position or not.

Skydome

Skydome is always centered on the camera, so that origo is under the view, at mean sea level. Z is up, x and y are rotated so that x (or y...) axis points towards the sun. That way the sunset effects are easier to do.