From 8dea8d1ed9e94085577a835ecd2cbc59060fb366 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Sun, 11 May 2014 10:52:45 +0200 Subject: [PATCH] refined shaders - grid is now visible - grid-points are different colored - tesselated triangles wont get "gridded". --- shaders/map/fragment.shader | 14 +++++++++++++- shaders/map/tessEval.shader | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/shaders/map/fragment.shader b/shaders/map/fragment.shader index ec6ac9f..e211418 100644 --- a/shaders/map/fragment.shader +++ b/shaders/map/fragment.shader @@ -106,6 +106,7 @@ smooth in vec3 tePosition; smooth in float fogDist; smooth in float gmix; in vec4 teColor; +in vec3 tePatchDistance; out vec4 fgColor; @@ -116,6 +117,10 @@ void main(void) { //fog color vec4 fogColor = vec4(0.6,0.7,0.8,1.0); + //grid color + vec4 grid = vec4(0.0,0.0,0.0,1.0); + //point color + vec4 point = vec4(1.0,0.9,0.1,1.0); //heliospheric lighting vec4 light = vec4(1.0,1.0,1.0,1.0); @@ -154,4 +159,11 @@ void main(void) fgColor = Color * mix(dark, light, a); fgColor = mix(fgColor,fogColor,fog(fogDist)); -} \ No newline at end of file + + //mix onto tri-borders + float mixer = clamp(exp(1.0-50.0*min(tePatchDistance.x,min(tePatchDistance.y,tePatchDistance.z))),0,1); + fgColor = mix(fgColor, grid, mixer); + + mixer = clamp(exp(1.0-50.0*min(tePatchDistance.x+tePatchDistance.y,min(tePatchDistance.x+tePatchDistance.z,tePatchDistance.y+tePatchDistance.z))),0,1); + fgColor = mix(fgColor, point, mixer); +} diff --git a/shaders/map/tessEval.shader b/shaders/map/tessEval.shader index 513df69..c4abf04 100644 --- a/shaders/map/tessEval.shader +++ b/shaders/map/tessEval.shader @@ -106,6 +106,7 @@ smooth out vec3 tePosition; smooth out vec3 teNormal; smooth out float fogDist; smooth out float gmix; //mixture of gravel +out vec3 tePatchDistance; //out vec3 tePatchDistance; //constant projection matrix uniform mat4 ProjectionMatrix; @@ -126,6 +127,7 @@ void main() vec3 p1 = gl_TessCoord.y * tcPosition[1]; vec3 p2 = gl_TessCoord.z * tcPosition[2]; tePosition = p0 + p1 + p2; + tePatchDistance = gl_TessCoord; //sin(a,b) = length(cross(a,b)) float i0 = (1-gl_TessCoord.x)*gl_TessCoord.x * length(cross(tcNormal[0],tessNormal));