From 389da8159978571e8156ff7692bc595d957e846e Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 23 Feb 2019 16:10:08 +0100 Subject: Store material in fluid buffer and improve visualization Replaces the density value which is actually not that useful for visualization. Encoding integer values as floats by casting and comparing them using exact floating point comparison is not very safe but works out for now. --- src/shader/code/vertex.glsl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/shader/code/vertex.glsl') diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl index 69bbaef..e0ce9a8 100644 --- a/src/shader/code/vertex.glsl +++ b/src/shader/code/vertex.glsl @@ -32,6 +32,14 @@ vec2 fluidVertexAtIndex(uint i) { ); } +bool isInactive(int material) { + return material == 0; +} + +bool isWallFrontier(int material) { + return material == 2 || material == 3; +} + void main() { const vec2 idx = fluidVertexAtIndex(gl_VertexID); @@ -42,13 +50,17 @@ void main() { 1. ); - if ( VertexPosition.z < -1.0 ) { + const int material = int(round(VertexPosition.z)); + + if ( isInactive(material) ) { + vs_out.color = vec3(0.5, 0.5, 0.5); + } else if ( isWallFrontier(material) ) { vs_out.color = vec3(0.0, 0.0, 0.0); } else { vs_out.color = mix( vec3(-0.5, 0.0, 1.0), vec3( 1.0, 0.0, 0.0), - displayAmplifier * VertexPosition.z * norm(VertexPosition.xy) + displayAmplifier * norm(VertexPosition.xy) ); } } -- cgit v1.2.3