aboutsummaryrefslogtreecommitdiff
path: root/src/shader/code
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-12-17 19:09:25 +0100
committerAdrian Kummerlaender2018-12-17 19:09:25 +0100
commitede5386d53a453cb56c9b1c80de0a80322ddc6f1 (patch)
treeab9b8b9e0659fa7c9da1bc35d9f943b072de843e /src/shader/code
parent85ad73153d1193e51e77ca825416df3794443fa4 (diff)
downloadcompustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar.gz
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar.bz2
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar.lz
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar.xz
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.tar.zst
compustream-ede5386d53a453cb56c9b1c80de0a80322ddc6f1.zip
Try out velocity norm color mapping
Diffstat (limited to 'src/shader/code')
-rw-r--r--src/shader/code/collide.glsl32
-rw-r--r--src/shader/code/geometry.glsl10
-rw-r--r--src/shader/code/vertex.glsl10
3 files changed, 29 insertions, 23 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 3982ad8..f960dcd 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -13,7 +13,19 @@ uniform uint nY;
const uint q = 9;
const float omega = 0.6;
-const float displayAmplifier = 1000.;
+const float displayAmplifier = 10.;
+
+float comp(int x, int y, vec2 v) {
+ return x*v.x + y*v.y;
+}
+
+float sq(float x) {
+ return x*x;
+}
+
+float norm(vec2 v) {
+ return sqrt(sq(v.x)+sq(v.y));
+}
float get(uint x, uint y, int i, int j) {
return collideCells[q*nX*y + q*x + (i+1)*3 + j+1];
@@ -24,9 +36,9 @@ void set(uint x, uint y, int i, int j, float v) {
}
void setFluid(uint x, uint y, vec2 v, float d) {
- fluidCells[3*nX*y + 3*x + 0] = float(x)-nX/2 + displayAmplifier*v.x;
- fluidCells[3*nX*y + 3*x + 1] = float(y)-nY/2 + displayAmplifier*v.y;
- fluidCells[3*nX*y + 3*x + 2] = d;
+ fluidCells[3*nX*y + 3*x + 0] = float(x)-nX/2;// + displayAmplifier*v.x;
+ fluidCells[3*nX*y + 3*x + 1] = float(y)-nY/2;// + displayAmplifier*v.y;
+ fluidCells[3*nX*y + 3*x + 2] = displayAmplifier * norm(v);
}
float density(uint x, uint y) {
@@ -70,18 +82,6 @@ float w(int i, int j) {
}
}
-float comp(int x, int y, vec2 v) {
- return x*v.x + y*v.y;
-}
-
-float sq(float x) {
- return x*x;
-}
-
-float norm(vec2 v) {
- return sqrt(sq(v.x)+sq(v.y));
-}
-
void main() {
const uint x = gl_GlobalInvocationID.x;
const uint y = gl_GlobalInvocationID.y;
diff --git a/src/shader/code/geometry.glsl b/src/shader/code/geometry.glsl
index 6ecfc99..e74d52f 100644
--- a/src/shader/code/geometry.glsl
+++ b/src/shader/code/geometry.glsl
@@ -17,7 +17,7 @@ vec4 project(vec4 v) {
}
void emitSquareAt(vec4 position) {
- const float size = 0.2;
+ const float size = 0.5;
gl_Position = project(position + vec4(-size, -size, 0.0, 0.0));
EmitVertex();
@@ -30,10 +30,8 @@ void emitSquareAt(vec4 position) {
}
void main() {
- if ( gl_in[0].gl_Position.xyz != vec3(0.,0.,0.) ) {
- color = gs_in[0].color;
- emitSquareAt(gl_in[0].gl_Position);
- EndPrimitive();
- }
+ color = gs_in[0].color;
+ emitSquareAt(gl_in[0].gl_Position);
+ EndPrimitive();
}
)";
diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl
index 453b6fa..516f2c6 100644
--- a/src/shader/code/vertex.glsl
+++ b/src/shader/code/vertex.glsl
@@ -7,8 +7,16 @@ out VS_OUT {
vec3 color;
} vs_out;
+float unit(float x) {
+ return 1.0/(1.0+exp(-x));
+}
+
+vec3 getColor(float x) {
+ return x*vec3(1.0,0.0,0.0) + (1-x)*vec3(-0.5,0.0,1.0);
+}
+
void main() {
gl_Position = vec4(VertexPosition.xy, 0., 1.);
- vs_out.color = vec3(VertexPosition.z, 0., 0.);
+ vs_out.color = getColor(unit(VertexPosition.z));
}
)";