diff options
Diffstat (limited to 'samples/post-processing/shaders')
-rw-r--r-- | samples/post-processing/shaders/curling.jsl | 13 | ||||
-rw-r--r-- | samples/post-processing/shaders/noise.jsl | 21 | ||||
-rw-r--r-- | samples/post-processing/shaders/pixel.jsl | 30 | ||||
-rw-r--r-- | samples/post-processing/shaders/radial.jsl | 17 | ||||
-rw-r--r-- | samples/post-processing/shaders/rgb-split.jsl | 24 | ||||
-rw-r--r-- | samples/post-processing/shaders/sobel.jsl | 30 |
6 files changed, 135 insertions, 0 deletions
diff --git a/samples/post-processing/shaders/curling.jsl b/samples/post-processing/shaders/curling.jsl new file mode 100644 index 0000000..dc217a7 --- /dev/null +++ b/samples/post-processing/shaders/curling.jsl @@ -0,0 +1,13 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER +Color frag(Color col, Texture tex, Vertex v) +{ + v.uv.x += sin(v.uv.y * 4 * 2 * 3.14 + jin_Time.x) / (10 + sin(jin_Time.x) * 10); + return texel(tex, v.uv); +} +#END_FRAGMENT_SHADER
\ No newline at end of file diff --git a/samples/post-processing/shaders/noise.jsl b/samples/post-processing/shaders/noise.jsl new file mode 100644 index 0000000..a2ba383 --- /dev/null +++ b/samples/post-processing/shaders/noise.jsl @@ -0,0 +1,21 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER + +float random(vec2 n, float offset ){ + return .5 - fract(sin(dot(n.xy + vec2(offset, 0.), vec2(12.9898, 78.233)))* 43758.5453); +} + +Color frag(Color col, Texture texture, Vertex v) +{ + float amount = 0.1; + float speed = 0.5; + vec4 color = texture2D(texture, v.uv.xy); + color += vec4(vec3(amount * random(v.uv.xy, .00001 * speed * jin_Time.x)), 1.); + return color; +} +#END_FRAGMENT_SHADER
\ No newline at end of file diff --git a/samples/post-processing/shaders/pixel.jsl b/samples/post-processing/shaders/pixel.jsl new file mode 100644 index 0000000..0242b7e --- /dev/null +++ b/samples/post-processing/shaders/pixel.jsl @@ -0,0 +1,30 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER +Color frag(Color col, Texture tex, Vertex v) +{ + // config + float pixel_w = 1 + sin(jin_Time.x / 3)*20.0; + float pixel_h = 1 + sin(jin_Time.x / 3)*20.0; + + vec2 uv = v.uv; + vec3 tc = vec3(1.0, 0.0, 0.0); + //if(uv.x < abs(sin(jin_Time.x))) + if(uv.x < 1) + { + float dx = pixel_w*(1.0/jin_RenderTargetSize.x); + float dy = pixel_h*(1.0/jin_RenderTargetSize.y); + vec2 coord = vec2(dx*floor(uv.x/dx),dy*floor(uv.y/dy)); + tc = texel(tex, coord).rgb; + } + else + { + tc = texel(tex, uv).rgb; + } + return vec4(tc, 1.0); +} +#END_FRAGMENT_SHADER
\ No newline at end of file diff --git a/samples/post-processing/shaders/radial.jsl b/samples/post-processing/shaders/radial.jsl new file mode 100644 index 0000000..50a86d1 --- /dev/null +++ b/samples/post-processing/shaders/radial.jsl @@ -0,0 +1,17 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER +Color frag(Color col, Texture texture, Vertex v) +{ + float of = abs(sin(jin_Time.x / 5)); + vec3 p = vec3(v.xy/jin_RenderTargetSize, 0) - of; + vec3 o = texture2D(texture,of+(p.xy*=.992)).rbb; + for (float i=0.;i<100.;i++) + p.z += pow(max(0.,of-length(texture2D(texture,of+(p.xy*=.992)).rg)),2.)*exp(-i*.08); + return vec4(o*o+p.z,1); +} +#END_FRAGMENT_SHADER
\ No newline at end of file diff --git a/samples/post-processing/shaders/rgb-split.jsl b/samples/post-processing/shaders/rgb-split.jsl new file mode 100644 index 0000000..fcfb9f2 --- /dev/null +++ b/samples/post-processing/shaders/rgb-split.jsl @@ -0,0 +1,24 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + //v.xy += vec2(50 * sin(jin_Time.x * 2), 50 * cos(jin_Time.x * 2)); + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER +Color frag(Color col, Texture tex, Vertex v) +{ + float t = jin_Time.x; + float a = abs(sin(t)) * 3.14; + vec2 p = vec2(0.5*cos(a) + 0.5, 0.5*sin(a) + 0.5); + vec2 dir = v.uv - p; + float d = .7 * length(dir); + normalize(dir); + vec2 value = d * dir * 200 * abs(sin(t * 3)); + + vec4 c1 = texel(tex, v.uv - value / jin_RenderTargetSize.x); + vec4 c2 = texel(tex, v.uv); + vec4 c3 = texel(tex, v.uv + value / jin_RenderTargetSize.y); + return vec4(c1.r, c2.g, c3.b, c1.a + c2.a + c3.b); +} +#END_FRAGMENT_SHADER
\ No newline at end of file diff --git a/samples/post-processing/shaders/sobel.jsl b/samples/post-processing/shaders/sobel.jsl new file mode 100644 index 0000000..7700dee --- /dev/null +++ b/samples/post-processing/shaders/sobel.jsl @@ -0,0 +1,30 @@ +#VERTEX_SHADER +Vertex vert(Vertex v) +{ + return v; +} +#END_VERTEX_SHADER +#FRAGMENT_SHADER +Color frag(Color col, Texture texture, Vertex v) +{ + float x = 1.0 / jin_RenderTargetSize.x; + float y = 1.0 / jin_RenderTargetSize.y; + vec4 horizEdge = vec4( 0.0 ); + horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y - y ) ) * 1.0; + horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y ) ) * 2.0; + horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y + y ) ) * 1.0; + horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y - y ) ) * 1.0; + horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y ) ) * 2.0; + horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y + y ) ) * 1.0; + vec4 vertEdge = vec4( 0.0 ); + vertEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y - y ) ) * 1.0; + vertEdge -= texture2D( texture, vec2( v.uv.x , v.uv.y - y ) ) * 2.0; + vertEdge -= texture2D( texture, vec2( v.uv.x + x, v.uv.y - y ) ) * 1.0; + vertEdge += texture2D( texture, vec2( v.uv.x - x, v.uv.y + y ) ) * 1.0; + vertEdge += texture2D( texture, vec2( v.uv.x , v.uv.y + y ) ) * 2.0; + vertEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y + y ) ) * 1.0; + vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); + + return vec4(edge, texture2D(texture, v.uv.xy).a); +} +#END_FRAGMENT_SHADER
\ No newline at end of file |