diff options
Purify collide shader
i.e. move fluid vertex placement to appropriate vertex shader.
Do not amplify or shift fluid moments in any way prior to
passing it to the display pipeline.
Diffstat (limited to 'src/shader/code/vertex.glsl')
-rw-r--r-- | src/shader/code/vertex.glsl | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl index 516f2c6..e132e5f 100644 --- a/src/shader/code/vertex.glsl +++ b/src/shader/code/vertex.glsl @@ -7,6 +7,11 @@ out VS_OUT { vec3 color; } vs_out; +uniform uint nX; +uniform uint nY; + +const float displayAmplifier = 10.0; + float unit(float x) { return 1.0/(1.0+exp(-x)); } @@ -15,8 +20,25 @@ 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() { - gl_Position = vec4(VertexPosition.xy, 0., 1.); - vs_out.color = getColor(unit(VertexPosition.z)); + const vec2 idx = fluidVertexAtIndex(gl_VertexID); + + gl_Position = vec4( + idx.x - nX/2, + idx.y - nY/2, + 0., + 1. + ); + + vs_out.color = getColor(unit(displayAmplifier * VertexPosition.z)); } )"; |