diff options
author | Adrian Kummerlaender | 2018-12-19 19:31:10 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2018-12-19 19:31:10 +0100 |
commit | 8df8940bced82cad259bc8144aa3668871222d22 (patch) | |
tree | 97a28fbbf181a6b21a0a44936638950bdbb55cb2 | |
parent | 994f70f0dd8fff208fab050a8a58f7fdf7bcfb24 (diff) | |
download | compustream-8df8940bced82cad259bc8144aa3668871222d22.tar compustream-8df8940bced82cad259bc8144aa3668871222d22.tar.gz compustream-8df8940bced82cad259bc8144aa3668871222d22.tar.bz2 compustream-8df8940bced82cad259bc8144aa3668871222d22.tar.lz compustream-8df8940bced82cad259bc8144aa3668871222d22.tar.xz compustream-8df8940bced82cad259bc8144aa3668871222d22.tar.zst compustream-8df8940bced82cad259bc8144aa3668871222d22.zip |
Use GLSL's mix function for color scaling
-rw-r--r-- | src/main.cc | 4 | ||||
-rw-r--r-- | src/shader/code/vertex.glsl | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/main.cc b/src/main.cc index c19b32d..3048979 100644 --- a/src/main.cc +++ b/src/main.cc @@ -23,8 +23,8 @@ #include "timer.h" -constexpr GLuint nX = 512; -constexpr GLuint nY = 512; +constexpr GLuint nX = 256; +constexpr GLuint nY = 256; constexpr int lups = 50; // max lattice updates per second diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl index 1051d8f..700a9b7 100644 --- a/src/shader/code/vertex.glsl +++ b/src/shader/code/vertex.glsl @@ -24,17 +24,12 @@ float norm(vec2 v) { return sqrt(sq(v.x)+sq(v.y)); } -vec3 getColor(float x) { - return x*vec3(1.0,0.0,0.0) + (1-x)*vec3(-0.5,0.0,1.0); -} - vec2 fluidVertexAtIndex(uint i) { const float y = floor(float(i) / float(nX)); return vec2( i - nX*y, y ); - } void main() { @@ -47,6 +42,10 @@ void main() { 1. ); - vs_out.color = getColor(unit(displayAmplifier * VertexPosition.z * norm(VertexPosition.xy))); + vs_out.color = mix( + vec3(-0.5, 0.0, 1.0), + vec3( 1.0, 0.0, 0.0), + displayAmplifier * VertexPosition.z * norm(VertexPosition.xy) + ); } )"; |