|
| 1 | + |
| 2 | +#version 330 |
| 3 | + |
| 4 | +#if defined VERTEX_SHADER |
| 5 | + |
| 6 | +in vec3 in_position; |
| 7 | +in vec2 in_texcoord_0; |
| 8 | + |
| 9 | +uniform mat4 model; |
| 10 | +uniform mat4 projection; |
| 11 | + |
| 12 | +out vec2 frag_uv; |
| 13 | + |
| 14 | +void main() { |
| 15 | + gl_Position = projection * model * vec4(in_position, 1.0); |
| 16 | + frag_uv = in_texcoord_0; |
| 17 | +} |
| 18 | + |
| 19 | +#elif defined FRAGMENT_SHADER |
| 20 | + |
| 21 | +uniform vec3 iResolution; // viewport resolution (in pixels) |
| 22 | +uniform float iTime; // shader playback time (in seconds) |
| 23 | +uniform float iTimeDelta; // render time (in seconds) |
| 24 | +uniform int iFrame; // shader playback frame |
| 25 | +uniform float iChannelTime[4]; // channel playback time (in seconds) |
| 26 | +uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) |
| 27 | +uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click |
| 28 | +uniform sampler2D iChannel0; // input channel. XX = 2D/Cube |
| 29 | +uniform sampler2D iChannel1; // input channel. XX = 2D/Cube |
| 30 | +uniform sampler2D iChannel2; // input channel. XX = 2D/Cube |
| 31 | +uniform sampler2D iChannel3; // input channel. XX = 2D/Cube |
| 32 | +uniform vec4 iDate; // (year, month, day, time in seconds) |
| 33 | +uniform float iSampleRate; // sound sample rate (i.e., 44100) |
| 34 | + |
| 35 | + |
| 36 | +void mainImage( out vec4 fragColor, in vec2 fragCoord ) {} |
| 37 | + |
| 38 | + |
| 39 | +uniform int components; |
| 40 | +uniform vec4 color; |
| 41 | + |
| 42 | +in vec2 frag_uv; |
| 43 | + |
| 44 | +out vec4 fragColor; |
| 45 | + |
| 46 | + |
| 47 | +void main() { |
| 48 | + |
| 49 | + vec2 uv = frag_uv; |
| 50 | + |
| 51 | + uv *= iResolution.xy; |
| 52 | + |
| 53 | + fragColor = color; |
| 54 | + |
| 55 | + vec4 color0; |
| 56 | + |
| 57 | + mainImage(color0, uv); |
| 58 | + |
| 59 | + if (components == 4) { |
| 60 | + fragColor *= color0; |
| 61 | + } |
| 62 | + else if (components == 1) { |
| 63 | + fragColor.a *= color0.x; |
| 64 | + } |
| 65 | + else { |
| 66 | + fragColor.rgb *= color0.rgb; |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +#endif |
0 commit comments