Created
January 15, 2020 07:41
-
-
Save Eiyeron/25f360af54d20151a4c30a2e3c424651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 150 | |
// Using Kodelife for the realtime preview/test environment but it should work fine on any shader that | |
// - offers the output's resolution | |
// - a time clock in seconds | |
// - an UV mapped on screenspace from [0,0] to [1,1] | |
uniform float time; | |
uniform vec2 resolution; | |
uniform sampler2D texture0; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData; | |
out vec4 fragColor; | |
void main(void) | |
{ | |
float ratio = resolution.x / resolution.y; | |
vec2 squaredUV = inData.v_texcoord / vec2(ratio, 1); | |
float z = (gl_FragCoord.y / resolution.y); | |
if(z > 0.5) | |
{ | |
fragColor.rgb = vec3(0.1,0.2,0.4)/2; | |
return; | |
} | |
z *= 2; | |
z = pow(z, 2); | |
z = 1-cos(z*3.141592653/2); | |
float xScale = 1; | |
float yScale = 1; | |
float xCenter = 0.6; | |
float yCenter = 0; | |
vec2 postOffset = vec2(0, z+time); | |
float angle = 0; | |
mat3 minusTranslation = mat3(1,0,-xCenter, | |
0,1,-yCenter, | |
0,0,1); | |
mat3 translation = mat3(1,0,xCenter, | |
0,1,yCenter, | |
0,0,1); | |
mat3 scale = mat3(xScale, 0, 0, | |
0, yScale, 0, | |
0, 0, 1); | |
mat3 rotation = mat3(cos(angle), sin(angle), 0, | |
-sin(angle), cos(angle), 0, | |
0, 0, 1); | |
mat3 transform = mat3(1,0,0, | |
0,1,0, | |
0,0,1); | |
mat3 postTranslation = mat3(1,0,postOffset.x, | |
0,1,postOffset.y, | |
0,0,1); | |
transform *= minusTranslation; | |
transform *= rotation; | |
transform *= scale; | |
transform *= translation; | |
transform *= postTranslation; | |
vec3 mapped = vec3(squaredUV, 1) * transform; | |
vec2 uv = vec2(mapped); | |
vec4 mapFragment = texture(texture0, uv) + pow(z,4) * 0.6; | |
fragColor = mapFragment; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment