Created
August 11, 2022 14:21
-
-
Save companje/3c9f64ca8a763aeb4db774e479da2802 to your computer and use it in GitHub Desktop.
Mercury Elevation map waterlevels /
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//based on Mercury MESSENGER Global DEM 665m v2 | |
//https://web.archive.org/web/20210903191157/https://astrogeology.usgs.gov/search/map/Mercury/Topography/MESSENGER/Mercury_Messenger_USGS_DEM_Global_665m_v2 | |
PImage palette, heightmap, colormap, normalmap; | |
PShader shader; | |
float progress = 0; | |
void setup() { | |
size(2048, 1024, P3D); | |
shader = loadShader("shader.glsl"); | |
palette = loadImage("palette.png"); | |
heightmap = loadImage("16k-8bit-elevation-Mercury_Messenger_DEM_Global_665m.png"); | |
colormap = loadImage("GlobalColor2017_equi_64ppd.1000.750.430.10percent.png"); | |
} | |
void draw() { | |
background(0); | |
shader.set("colormap", colormap); | |
shader.set("heightmap", heightmap); | |
shader.set("palette", palette); | |
shader.set("progress", progress); | |
shader(shader); | |
image(heightmap, 0, 0, width, height); | |
} | |
void mouseWheel(MouseEvent event) { | |
progress += event.getCount() *.0001; | |
progress = constrain(progress, 0, 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform sampler2D colormap; | |
uniform sampler2D heightmap; | |
uniform sampler2D palette; | |
uniform sampler2D borders; | |
uniform float progress; | |
varying vec4 vertTexCoord; | |
const float fade = 0.0025; | |
float map(float value, float min1, float max1, float min2, float max2) { | |
return min2 + (value - min1) * (max2 - min2) / (max1 - min1); | |
} | |
void main() { | |
vec4 terrainColor = texture2D(colormap, vertTexCoord.st); | |
vec4 heightColor = texture2D(heightmap, vertTexCoord.st); | |
float elevation = (heightColor.r*256 + heightColor.g) / 256; //0..1 | |
vec4 waterColor = texture2D(palette, vec2(map(elevation,0,progress,0,1),0)); | |
float d = smoothstep(progress-fade, progress+fade, elevation); | |
gl_FragColor = mix(waterColor, terrainColor, d); | |
} |
Author
companje
commented
Aug 11, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment