You are on page 1of 3

DYZ#1 shader code

DYZ#1 shader code


thank you for watching this page :)
i separate shader to 2 shader because i don't how to combine them...

Create

globalvar white_r, white_g, white_b, black_r, black_g, black_b; white_r = 114


white_g = 127 white_b = 129 black_r = 20 black_g = 33 black_b = 35 view_w = 360
view_h = 194 application_surface_draw_enable( false ) display_set_gui_maximize()
display_w = display_get_width() display_h = display_get_height() surface_resize(
application_surface, view_w, view_h ) mag = floor( display_h / view_h / 1.1 )
surf = surface_create( display_w, display_h ) surf2 = surface_create( display_w,
display_h )
Plain Text

Draw GUI

if not surface_exists( surf ) { surf = surface_create( display_w, display_h ) }


if not surface_exists( surf2 ) { surf2 = surface_create( display_w, display_h ) }
surface_set_target( surf ) draw_clear( make_color_rgb( white_r, white_g, white_b
) ) draw_surface_stretched( application_surface, display_w / 2 - view_w * mag /
2, display_h / 2 - view_h * mag / 2, view_w * mag, view_h * mag )
surface_reset_target() shader_set( sh_shader ) shader_set_uniform_f(
shader_get_uniform( sh_shader, "time" ), current_time ) shader_set_uniform_f(
shader_get_uniform( sh_shader, "rep1" ), 255, 255, 255 ) shader_set_uniform_f(
shader_get_uniform( sh_shader, "new1" ), white_r, white_g, white_b )
shader_set_uniform_f( shader_get_uniform( sh_shader, "rep2" ), 0, 0, 0 )
shader_set_uniform_f( shader_get_uniform( sh_shader, "new2" ), black_r, black_g,
black_b ) surface_set_target( surf2 ) draw_surface( surf, 0, 0 )
surface_reset_target() shader_reset() shader_set( sh_blur ) shader_set_uniform_f(
shader_get_uniform( sh_blur, "size" ), display_w, display_h, 1 ) draw_surface(
surf2, 0, 0 ) shader_reset()
Plain Text

sh_shader
_

varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform float time; uniform
vec3 rep1; uniform vec3 rep2; uniform vec3 new1; uniform vec3 new2; float
rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
} vec3 screen(vec3 a, vec3 b, float w) { return mix(a, vec3(1.0) - (vec3(1.0) -
a) * (vec3(1.0) - b), w); } void main() { vec2 uv = v_vTexcoord; highp float
magnitude = 0.001; vec2 offsetUV = uv; offsetUV.x = uv.x +
rand(vec2(time*0.03,uv.y*0.42)) * 0.001; offsetUV.x += sin(rand(vec2(time*0.2,
uv.y)))*magnitude; vec4 offsetColor = vec4(vec3(texture2D(gm_BaseTexture,
offsetUV)), 1); //---------------------------------------------------------------
--------- vec3 new = vec3( offsetColor.r * 255.0, offsetColor.g * 255.0,
offsetColor.b * 255.0 ); if (new == rep1) {new = new1;} if (new == rep2) {new =
new2;} vec4 swapedColor = vec4( new.r / 255.0, new.g / 255.0, new.b / 255.0, 1 );
//------------------------------------------------------------------------ float
flicker = 20.0; float freq = sin(pow(mod(time, flicker)+flicker, 1.9));
gl_FragColor = vec4(1.0,1.0,1.0,1.0); gl_FragColor *= vec4(rand(uv+mod(time,
freq)), rand(uv+mod(time+.1, freq)), rand(uv), 1.0); gl_FragColor.rgb = screen(
swapedColor.rgb, gl_FragColor.rgb, 0.2 ); }
Plain Text

sh_blur

varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform vec3 size; const int
Quality = 10; const int Directions = 16; const float Pi = 6.28318530718; void
main() { vec2 radius = size.z / size.xy; vec2 p = ( gl_FragCoord.xy * 2.0 -
size.xy ) / min( size.x, size.y ); float l = 2.0; vec4 Color = texture2D(
gm_BaseTexture, v_vTexcoord ); for( float d = 0.0; d < Pi; d += Pi / float(
Directions ) ) { for( float i = 1.0 / float( Quality ); i <= 1.0; i += 1.0 /
float( Quality ) ) { Color += texture2D( gm_BaseTexture, v_vTexcoord + vec2( cos(
d ), sin( d ) ) * radius * i * l ); } } Color /= float( Quality ) * float(
Directions ) + 1.0; gl_FragColor = Color * v_vColour; }
Plain Text

You might also like