Verein

Abriss der 30 jährigen alten Materialhütte

Manu · 03.05.2022

// vertex-shader specifies the position of each pixel // uniform: must be assigned before gl.drawArrays() call ; attribute: will receive data from a buffer (only accesible in vertex) ; varying: val asigned by vertex-shader and interpolated then sent to fragment-shader precision mediump float; attribute vec2 a_position; attribute vec2 a_texCoord; uniform vec2 u_resolution; varying vec2 v_texCoord; void main() { // convert the rectangle from pixels to 0.0 to 1.0 vec2 zeroToOne = a_position / u_resolution; // convert from 0->1 to 0->2 vec2 zeroToTwo = zeroToOne 2.0; // convert from 0->2 to -1->+1 (clipspace) vec2 clipSpace = zeroToTwo - 1.0; clipSpace.y = clipSpace.y - 1.0; // to unmirror images gl_Position = vec4(clipSpace, 0, 1); // 1, -1 - best -1, -1 v_texCoord = a_texCoord; // pass the texCoord to the fragment shader } // fragment-shader specifies the color of each pixel // uniform: must be assigned before gl.drawArrays() call ; attribute: will receive data from a buffer (only accesible in vertex) ; varying: val asigned by vertex-shader and interpolated then sent to fragment-shader precision mediump float; // =========================== Variables =========================== uniform sampler2D u_image; varying vec2 v_texCoord; // passed from the vertex-shader void main() { gl_FragColor = texture2D(u_image, v_texCoord); } // Source: cyberpunk.net precision mediump float; attribute vec2 a_position; attribute vec2 a_texCoord; uniform vec2 u_resolution; varying vec2 pos; void main() { // convert the rectangle from pixels to 0.0 to 1.0 vec2 zeroToOne = a_position / u_resolution; // convert from 0->1 to 0->2 vec2 zeroToTwo = zeroToOne 2.0; // convert from 0->2 to -1->+1 (clipspace) vec2 clipSpace = zeroToTwo - 1.0; clipSpace.y = clipSpace.y -1.0; // to unmirror images gl_Position = vec4(clipSpace, 0.0, 1.0); pos = a_texCoord; // pass the texCoord to the fragment shader } // Source: cyberpunk.net // Author: paniq // License: MIT precision mediump float; // =========================== Forward Declare Functions =========================== vec4 getFromColor(vec2 target); vec4 getToColor(vec2 target); vec4 transition(vec2 goal); // =========================== Variables =========================== uniform float progress; uniform float strength; uniform sampler2D last, next; varying vec2 pos; void main(){ gl_FragColor = transition(pos); } vec4 getLastColor(vec2 target) { return texture2D(last, target); } vec4 getNextColor(vec2 target) { return texture2D(next, target); } vec4 transition(vec2 goal) { vec4 lastColor = getLastColor(goal); vec4 nextColor = getNextColor(goal); vec2 lastRGB = (((lastColor.rg + lastColor.b) 0.5) 2.0 - 1.0); vec2 nextRGB = (((nextColor.rg + nextColor.b) 0.5) 2.0 - 1.0); vec2 mixed = mix(lastRGB, nextRGB, 0.5) strength; float remeaning = 1.0 - progress; return mix(getLastColor(goal + mixed progress), getNextColor(goal - mixed * remeaning), progress); } ← → Bild 1 von 99

← Alle News