Skip to content

Commit

Permalink
Extended rear clipping plane logic, color-coding
Browse files Browse the repository at this point in the history
- Far clipping plane pushed way back; mountains were being clipped that
  shouldn't have been

- Terrain coloring now uses a different far clipping plane, to boost the dynamic
  range of the color

- Reversed coloring direction: near terrain is bright red; far terrain is dark
  red
  • Loading branch information
dkogan committed Jun 13, 2013
1 parent 4efea60 commit 27fce36
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ varying float red;

const float Rearth = 6371000.0;
const float pi = 3.14159265358979;
const float znear = 100.0, zfar = 30000.0;

// these define the front and back clipping planes, in meters
const float znear = 100.0, zfar = 300000.0;

// Past this distance the render color doesn't change, in meters
const float zfar_color = 40000.0;


void main(void)
Expand Down Expand Up @@ -66,7 +71,7 @@ void main(void)
else if( at_right_seam ) az += 2.0;

// coloring by...
red = clamp( (zeff - znear) / (zfar - znear ),
red = clamp( (zfar_color - zeff) / (zfar_color - znear ),
0.0, 1.0 ); // ... distance from camera
//red = vin.z / 3500.0; // ... elevation

Expand Down

0 comments on commit 27fce36

Please sign in to comment.