File: wave.frag

package info (click to toggle)
olive-editor 20181223-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,844 kB
  • sloc: cpp: 20,147; xml: 315; ansic: 16; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#version 110

uniform float frequency;
uniform float intensity;
uniform float evolution;
uniform bool vertical;

uniform sampler2D myTexture;
varying vec2 vTexCoord;

void main(void) {
	float x = vTexCoord.x;
	float y = vTexCoord.y;

	if (vertical) {
		x -= sin((vTexCoord.y-(evolution*0.01))*frequency)*intensity*0.01;
	} else {
		y -= sin((vTexCoord.x-(evolution*0.01))*frequency)*intensity*0.01;
	}

	if (y < 0.0 || y > 1.0 || x < 0.0 || x > 1.0) {
		discard;
	} else {
		vec4 textureColor = texture2D(myTexture, vec2(x, y));
		gl_FragColor = vec4(
			textureColor.r,
			textureColor.g,
			textureColor.b,
			textureColor.a
		);
	}	
}