Pixel-Composer/build/Windows/0/cache/sh_zigzag.shader

93 lines
2.3 KiB
Text
Raw Normal View History

//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
//######################_==_YOYO_SHADER_MARKER_==_######################@~
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform int blend;
uniform float rotation;
uniform vec2 amount;
uniform int amountUseSurf;
uniform sampler2D amountSurf;
uniform vec2 angle;
uniform int angleUseSurf;
uniform sampler2D angleSurf;
uniform vec4 col1, col2;
void main() {
float amo = amount.x;
if(amountUseSurf == 1) {
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float ang = angle.x;
if(angleUseSurf == 1) {
vec4 _vMap = texture2D( angleSurf, v_vTexcoord );
ang = mix(angle.x, angle.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
ang = radians(ang);
vec2 ntx = v_vTexcoord * vec2(1., dimension.y / dimension.x);
vec2 pos = ntx - position;
float _cell = 1. / (amo * 2.);
pos.y -= _cell / 2.;
pos *= mat2(cos(ang), -sin(ang), sin(ang), cos(ang));
float _xind = floor(pos.x / _cell);
float _yind = floor(pos.y / _cell);
float _xcell = fract(pos.x * amo * 2.);
float _ycell = fract(pos.y * amo * 2.);
float _x = _xcell;
float _y = _ycell;
if(mod(_xind, 2.) == 1.)
_x = 1. - _xcell;
float _h = _x > _y? _y + (1. - _x) : _y - _x;
float _ychi = _x > _y ? _yind + 1. : _yind;
if(mod(_ychi, 2.) == 1.) _h = 1. - _h;
if(blend == 0) {
gl_FragColor = _h < 0.5? col1 : col2;
} else if(blend == 1) {
gl_FragColor = mix(col1, col2, _h);
} else if(blend == 2) {
float px = 1. / max(dimension.x, dimension.y);
_h = smoothstep(0.5 - px, 0.5 + px, _h);
gl_FragColor = mix(col1, col2, _h);
}
}