From 8df8940bced82cad259bc8144aa3668871222d22 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 19 Dec 2018 19:31:10 +0100 Subject: Use GLSL's mix function for color scaling --- src/main.cc | 4 ++-- src/shader/code/vertex.glsl | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src') 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) + ); } )"; -- cgit v1.2.3