diff options
author | chai <chaifix@163.com> | 2018-12-30 12:40:20 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-30 12:40:20 +0800 |
commit | 2a867a0434f9c0f5c23da5249e5149623cac909c (patch) | |
tree | 3999807a4ea481201211e151ca2fb24008020e9d | |
parent | 48173231d90de6bfc193260eab6369f7c88ca742 (diff) |
*添加sample
-rw-r--r-- | samples/post-processing/0.png (renamed from bin/game/0.png) | bin | 563072 -> 563072 bytes | |||
-rw-r--r-- | samples/post-processing/1.png (renamed from bin/game/1.png) | bin | 73228 -> 73228 bytes | |||
-rw-r--r-- | samples/post-processing/SDL.jpg (renamed from bin/game/SDL.jpg) | bin | 6481 -> 6481 bytes | |||
-rw-r--r-- | samples/post-processing/anim.png (renamed from bin/game/anim.png) | bin | 44218 -> 44218 bytes | |||
-rw-r--r-- | samples/post-processing/anim2.png (renamed from bin/game/anim2.png) | bin | 648800 -> 648800 bytes | |||
-rw-r--r-- | samples/post-processing/config.lua (renamed from bin/game/config.lua) | 0 | ||||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_0.png (renamed from bin/game/dust/s_dust_A_0.png) | bin | 82 -> 82 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_1.png (renamed from bin/game/dust/s_dust_A_1.png) | bin | 93 -> 93 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_10.png (renamed from bin/game/dust/s_dust_A_10.png) | bin | 84 -> 84 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_2.png (renamed from bin/game/dust/s_dust_A_2.png) | bin | 94 -> 94 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_3.png (renamed from bin/game/dust/s_dust_A_3.png) | bin | 95 -> 95 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_4.png (renamed from bin/game/dust/s_dust_A_4.png) | bin | 76 -> 76 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_5.png (renamed from bin/game/dust/s_dust_A_5.png) | bin | 88 -> 88 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_6.png (renamed from bin/game/dust/s_dust_A_6.png) | bin | 87 -> 87 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_7.png (renamed from bin/game/dust/s_dust_A_7.png) | bin | 84 -> 84 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_8.png (renamed from bin/game/dust/s_dust_A_8.png) | bin | 86 -> 86 bytes | |||
-rw-r--r-- | samples/post-processing/dust/s_dust_A_9.png (renamed from bin/game/dust/s_dust_A_9.png) | bin | 83 -> 83 bytes | |||
-rw-r--r-- | samples/post-processing/forest.ogg (renamed from bin/game/forest.ogg) | bin | 789109 -> 789109 bytes | |||
-rw-r--r-- | samples/post-processing/icon.ico (renamed from bin/game/icon.ico) | bin | 85182 -> 85182 bytes | |||
-rw-r--r-- | samples/post-processing/main.lua (renamed from bin/game/main.lua) | 153 | ||||
-rw-r--r-- | samples/post-processing/particle.png (renamed from bin/game/particle.png) | bin | 1821 -> 1821 bytes | |||
-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 | ||||
-rw-r--r-- | samples/post-processing/splash.png (renamed from bin/game/splash.png) | bin | 392 -> 392 bytes |
28 files changed, 141 insertions, 147 deletions
diff --git a/bin/game/0.png b/samples/post-processing/0.png Binary files differindex fa62576..fa62576 100644 --- a/bin/game/0.png +++ b/samples/post-processing/0.png diff --git a/bin/game/1.png b/samples/post-processing/1.png Binary files differindex 7e3fe49..7e3fe49 100644 --- a/bin/game/1.png +++ b/samples/post-processing/1.png diff --git a/bin/game/SDL.jpg b/samples/post-processing/SDL.jpg Binary files differindex dcd530a..dcd530a 100644 --- a/bin/game/SDL.jpg +++ b/samples/post-processing/SDL.jpg diff --git a/bin/game/anim.png b/samples/post-processing/anim.png Binary files differindex ef0bc81..ef0bc81 100644 --- a/bin/game/anim.png +++ b/samples/post-processing/anim.png diff --git a/bin/game/anim2.png b/samples/post-processing/anim2.png Binary files differindex 63c1f63..63c1f63 100644 --- a/bin/game/anim2.png +++ b/samples/post-processing/anim2.png diff --git a/bin/game/config.lua b/samples/post-processing/config.lua index 095ee28..095ee28 100644 --- a/bin/game/config.lua +++ b/samples/post-processing/config.lua diff --git a/bin/game/dust/s_dust_A_0.png b/samples/post-processing/dust/s_dust_A_0.png Binary files differindex 79efc70..79efc70 100644 --- a/bin/game/dust/s_dust_A_0.png +++ b/samples/post-processing/dust/s_dust_A_0.png diff --git a/bin/game/dust/s_dust_A_1.png b/samples/post-processing/dust/s_dust_A_1.png Binary files differindex acc2100..acc2100 100644 --- a/bin/game/dust/s_dust_A_1.png +++ b/samples/post-processing/dust/s_dust_A_1.png diff --git a/bin/game/dust/s_dust_A_10.png b/samples/post-processing/dust/s_dust_A_10.png Binary files differindex e422644..e422644 100644 --- a/bin/game/dust/s_dust_A_10.png +++ b/samples/post-processing/dust/s_dust_A_10.png diff --git a/bin/game/dust/s_dust_A_2.png b/samples/post-processing/dust/s_dust_A_2.png Binary files differindex 1ef2056..1ef2056 100644 --- a/bin/game/dust/s_dust_A_2.png +++ b/samples/post-processing/dust/s_dust_A_2.png diff --git a/bin/game/dust/s_dust_A_3.png b/samples/post-processing/dust/s_dust_A_3.png Binary files differindex ca2260a..ca2260a 100644 --- a/bin/game/dust/s_dust_A_3.png +++ b/samples/post-processing/dust/s_dust_A_3.png diff --git a/bin/game/dust/s_dust_A_4.png b/samples/post-processing/dust/s_dust_A_4.png Binary files differindex 1f67b79..1f67b79 100644 --- a/bin/game/dust/s_dust_A_4.png +++ b/samples/post-processing/dust/s_dust_A_4.png diff --git a/bin/game/dust/s_dust_A_5.png b/samples/post-processing/dust/s_dust_A_5.png Binary files differindex 3969a04..3969a04 100644 --- a/bin/game/dust/s_dust_A_5.png +++ b/samples/post-processing/dust/s_dust_A_5.png diff --git a/bin/game/dust/s_dust_A_6.png b/samples/post-processing/dust/s_dust_A_6.png Binary files differindex d2d6df0..d2d6df0 100644 --- a/bin/game/dust/s_dust_A_6.png +++ b/samples/post-processing/dust/s_dust_A_6.png diff --git a/bin/game/dust/s_dust_A_7.png b/samples/post-processing/dust/s_dust_A_7.png Binary files differindex 02ba310..02ba310 100644 --- a/bin/game/dust/s_dust_A_7.png +++ b/samples/post-processing/dust/s_dust_A_7.png diff --git a/bin/game/dust/s_dust_A_8.png b/samples/post-processing/dust/s_dust_A_8.png Binary files differindex 700052c..700052c 100644 --- a/bin/game/dust/s_dust_A_8.png +++ b/samples/post-processing/dust/s_dust_A_8.png diff --git a/bin/game/dust/s_dust_A_9.png b/samples/post-processing/dust/s_dust_A_9.png Binary files differindex 8de4fcf..8de4fcf 100644 --- a/bin/game/dust/s_dust_A_9.png +++ b/samples/post-processing/dust/s_dust_A_9.png diff --git a/bin/game/forest.ogg b/samples/post-processing/forest.ogg Binary files differindex d3059e1..d3059e1 100644 --- a/bin/game/forest.ogg +++ b/samples/post-processing/forest.ogg diff --git a/bin/game/icon.ico b/samples/post-processing/icon.ico Binary files differindex 3043332..3043332 100644 --- a/bin/game/icon.ico +++ b/samples/post-processing/icon.ico diff --git a/bin/game/main.lua b/samples/post-processing/main.lua index ff8670d..6aaeb6e 100644 --- a/bin/game/main.lua +++ b/samples/post-processing/main.lua @@ -115,158 +115,17 @@ function jin.core.onLoad() #END_FRAGMENT_SHADER ]] - pp = jin.graphics.newShader[[ - #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 - ]] + pp = jin.graphics.newShaderf("./shaders/curling.jsl") - pixel = jin.graphics.newShader[[ - #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 - ]] + pixel = jin.graphics.newShaderf("./shaders/pixel.jsl") - rgbsplit = jin.graphics.newShader[[ - #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 - ]] + rgbsplit = jin.graphics.newShaderf("./shaders/rgb-split.jsl") - sobel = jin.graphics.newShader[[ - #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 - ]] + sobel = jin.graphics.newShaderf("./shaders/sobel.jsl") - noise = jin.graphics.newShader[[ - #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); - } + noise = jin.graphics.newShaderf("./shaders/noise.jsl") - 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 - ]] - - radial = jin.graphics.newShader[[ - #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 - ]] + radial = jin.graphics.newShaderf("./shaders/radial.jsl") jin.log.info("test") diff --git a/bin/game/particle.png b/samples/post-processing/particle.png Binary files differindex 632fcc1..632fcc1 100644 --- a/bin/game/particle.png +++ b/samples/post-processing/particle.png 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 diff --git a/bin/game/splash.png b/samples/post-processing/splash.png Binary files differindex b0c4256..b0c4256 100644 --- a/bin/game/splash.png +++ b/samples/post-processing/splash.png |