From 303025eda4e10a0d962231c7b3349f8b9cb8cfa1 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 17 Apr 2019 20:50:49 +0200 Subject: Improve color palette of Knudsen criterion mode --- src/shader/code/collide.glsl | 2 +- src/shader/code/vertex.glsl | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl index 45e06f8..d3d004d 100644 --- a/src/shader/code/collide.glsl +++ b/src/shader/code/collide.glsl @@ -34,7 +34,7 @@ const float relaxationFrequency = 1 / relaxationTime; /// Unit conversion -const float convLength = physCharLength / nX; +const float convLength = physCharLength / max(nX,nY); const float convTime = (relaxationTime - 0.5) / invCs2 * convLength*convLength / physViscosity; const float convVelocity = convLength / convTime; const float convViscosity = convLength * convLength / convTime; diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl index 8958600..e64a983 100644 --- a/src/shader/code/vertex.glsl +++ b/src/shader/code/vertex.glsl @@ -51,6 +51,22 @@ float restrictedQuality(float quality) { } } +vec3 trafficLightPalette(float x) { + if ( x < 0.5 ) { + return mix( + vec3(0.0, 1.0, 0.0), + vec3(1.0, 1.0, 0.0), + 2*x + ); + } else { + return mix( + vec3(1.0, 1.0, 0.0), + vec3(1.0, 0.0, 0.0), + 2*(x - 0.5) + ); + } +} + void main() { const vec2 idx = fluidVertexAtIndex(gl_VertexID); @@ -69,11 +85,7 @@ void main() { vs_out.color = vec3(0.0, 0.0, 0.0); } else { if ( fluidQuality ) { - vs_out.color = mix( - vec3(0.0, 1.0, 0.0), - vec3(1.0, 0.0, 0.0), - restrictedQuality(VertexPosition.y) - ); + vs_out.color = trafficLightPalette(restrictedQuality(VertexPosition.y)); } else { vs_out.color = mix( vec3(-0.5, 0.0, 1.0), -- cgit v1.2.3