diff options
-rw-r--r-- | src/shader/code/collide.glsl | 2 | ||||
-rw-r--r-- | src/shader/code/vertex.glsl | 22 |
2 files changed, 18 insertions, 6 deletions
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), |