Skip to content

Commit

Permalink
shaders needed for night vision demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Your user name committed Jul 20, 2016
1 parent 9f7f6f0 commit 51b2e36
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
37 changes: 37 additions & 0 deletions shaders/night_vision.fs
@@ -0,0 +1,37 @@
precision mediump float;

uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform vec3 unib[4];
// see docstring Buffer
uniform vec3 unif[20];
// 16,0 is time
// 16,1 is luminance threshold
// 16,2 is luminance applificaiton

varying vec2 texcoordout;
varying float dist;



void main(void) {
vec2 uv;
uv.x = 0.4 * sin(unif[16][0] * 50.0);
uv.y = 0.4 * cos(unif[16][0] * 50.0);
float m = 1.0 - texture2D(tex1, texcoordout).a;
vec3 n = texture2D(tex2, texcoordout * 3.5 + uv).rgb;
vec3 c = texture2D(tex0, texcoordout + n.rg * 0.005).rgb;

float lum = dot(vec3(0.30, 0.59, 0.11), c);
if (lum < unif[16][1]) {
c *= unif[16][2];
}

vec3 visionColor = vec3(0.1, 0.95, 0.2);
gl_FragColor.rgb = (c + n * 0.2) * visionColor * m;

gl_FragColor.a = unif[5][2];
}


24 changes: 24 additions & 0 deletions shaders/night_vision.vs
@@ -0,0 +1,24 @@
precision mediump float;

attribute vec3 vertex;
attribute vec3 normal;
attribute vec2 texcoord;

uniform mat4 modelviewmatrix[3]; // [0] model movement in real coords, [1] in camera coords, [2] camera at light
uniform vec3 unib[4];
//uniform float ntiles => unib[0][0]
//uniform vec2 umult, vmult => unib[2]
//uniform vec2 u_off, v_off => unib[3]
uniform vec3 unif[20];
//uniform vec3 eye > unif[6]
//uniform vec3 lightpos > unif[8]

varying vec2 texcoordout;
varying float dist;

void main(void) {
texcoordout = texcoord * unib[2].xy + unib[3].xy;
gl_Position = modelviewmatrix[1] * vec4(vertex,1.0);
dist = gl_Position.z;
gl_PointSize = unib[2][2] / dist;
}

0 comments on commit 51b2e36

Please sign in to comment.