diff options
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.
Diffstat (limited to 'src/shader/code/vertex.glsl')
-rw-r--r-- | src/shader/code/vertex.glsl | 16 |
1 files changed, 14 insertions, 2 deletions
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) ); } } |