|
pipelines: |
|
- name: basic |
|
buffers: |
|
- name: offscreen |
|
layers: |
|
- name: clamp |
|
targets: |
|
- name: stage |
|
- name: offscreen |
|
uniforms: |
|
- name: uMin |
|
type: float |
|
value: 0.5 |
|
- name: uMax |
|
type: float |
|
value: 0.9 |
|
- name: blurX |
|
- name: blurY |
|
- name: blurX |
|
- name: blurY |
|
- name: madd |
|
- name: exposure |
|
uniforms: |
|
- name: uTarget |
|
type: float |
|
value: 0.5 |
|
- name: sepia |
|
- name: vignette |
|
- name: color-curve |
|
uniforms: |
|
- name: anchor1 |
|
type: vec2 |
|
value: [1.0, 0.0] |
|
- name: anchor2 |
|
type: vec2 |
|
value: [0.0, 1.0] |
|
- name: distort |
|
- name: recombine |
|
mipmaps: true |
|
screen: |
|
x: 1024 |
|
y: 768 |
|
effects: |
|
- name: invert |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec4 texel = texture2D(foo, uv); |
|
vec4 invert = vec4(1.0) - texel; |
|
|
|
gl_FragColor = mix(invert, texel, step(uv.y, 0.6)); |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: monochrome |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
vec4 texel = texture2D(foo, uv); |
|
|
|
float lum = (texel.x * 0.3) + (texel.y * 0.6) + (texel.z * 0.1); |
|
vec4 lumtex = vec4(lum, lum, lum, 1.0); |
|
|
|
gl_FragColor = mix(texel, lumtex, step(0.3, uv.y)); |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: blurX |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 pixel = vec2(1.0) / vec2(1024.0, 768.0); |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec4 texN3 = texture2D(foo, vec2(uv.x - (pixel.x * 3.0), uv.y)) * 0.125; |
|
vec4 texN2 = texture2D(foo, vec2(uv.x - (pixel.x * 2.0), uv.y)) * 0.25; |
|
vec4 texN1 = texture2D(foo, vec2(uv.x - (pixel.x * 1.0), uv.y)) * 0.5; |
|
vec4 tex00 = texture2D(foo, uv); |
|
vec4 texP1 = texture2D(foo, vec2(uv.x + (pixel.x * 1.0), uv.y)) * 0.5; |
|
vec4 texP2 = texture2D(foo, vec2(uv.x + (pixel.x * 2.0), uv.y)) * 0.25; |
|
vec4 texP3 = texture2D(foo, vec2(uv.x + (pixel.x * 3.0), uv.y)) * 0.125; |
|
|
|
gl_FragColor = (texN3 + texN2 + texN1 + tex00 + texP1 + texP2 + texP3) / 2.75; |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: blurY |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 pixel = vec2(1.0) / vec2(1024.0, 768.0); |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec4 texN3 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 3.0))) * 0.125; |
|
vec4 texN2 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 2.0))) * 0.25; |
|
vec4 texN1 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 1.0))) * 0.5; |
|
vec4 tex00 = texture2D(foo, uv); |
|
vec4 texP1 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 1.0))) * 0.5; |
|
vec4 texP2 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 2.0))) * 0.25; |
|
vec4 texP3 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 3.0))) * 0.125; |
|
|
|
gl_FragColor = (texN3 + texN2 + texN1 + tex00 + texP1 + texP2 + texP3) / 2.75; |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: exposure |
|
samplers: |
|
- name: foo |
|
source: stage |
|
- name: bar |
|
source: scene |
|
fragment: | |
|
#version 300 es |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
uniform sampler2D bar; |
|
uniform vec2 uResolution; |
|
uniform float uTime; |
|
uniform float uLum; |
|
uniform float uTarget; |
|
|
|
in vec2 outTexCoord; |
|
in vec4 outTint; |
|
out vec4 outColor; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
vec2 luv = outTexCoord.xy; |
|
luv.y = 1.0 - luv.y; |
|
|
|
vec4 global_lum = textureLod(bar, luv, 7.0); |
|
vec4 local_lum = textureLod(bar, luv, 3.0); |
|
|
|
vec4 texel = texture(foo, uv); |
|
|
|
outColor = mix((local_lum - global_lum) + texel, texel, step(uTarget, uv.x)); |
|
outColor.w = 1.0f; |
|
} |
|
vertex: | |
|
#version 300 es |
|
precision mediump float; |
|
|
|
uniform mat4 uProjectionMatrix; |
|
uniform mat4 uViewMatrix; |
|
uniform mat4 uModelMatrix; |
|
|
|
in vec2 inPosition; |
|
in vec2 inTexCoord; |
|
in float inTintEffect; |
|
in vec4 inTint; |
|
|
|
out vec2 outTexCoord; |
|
out float outTintEffect; |
|
out vec4 outTint; |
|
|
|
void main () |
|
{ |
|
gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0); |
|
|
|
outTexCoord = inTexCoord; |
|
outTint = inTint; |
|
outTintEffect = inTintEffect; |
|
} |
|
- name: clamp |
|
samplers: |
|
- name: stage |
|
source: stage |
|
fragment: | |
|
precision mediump float; |
|
|
|
uniform float uMin; |
|
uniform float uMax; |
|
uniform sampler2D stage; |
|
|
|
varying vec2 outTexCoord; |
|
|
|
void main() { |
|
float range = uMax - uMin; |
|
vec4 base = vec4(uMin); |
|
vec4 texel = texture2D(stage, outTexCoord); |
|
|
|
gl_FragColor = (clamp(texel, base, vec4(uMax)) - base) / range; |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: madd |
|
samplers: |
|
- name: stage |
|
source: stage |
|
- name: scene |
|
source: scene |
|
fragment: | |
|
precision mediump float; |
|
|
|
uniform sampler2D scene; |
|
uniform sampler2D stage; |
|
|
|
varying vec2 outTexCoord; |
|
|
|
void main() { |
|
vec2 uv = outTexCoord.xy; |
|
uv.y = 1.0 - uv.y; |
|
|
|
vec4 texel = texture2D(stage, outTexCoord) + texture2D(scene, uv); |
|
|
|
gl_FragColor = texel; |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: sepia |
|
samplers: |
|
- name: stage |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
vec4 texel = texture2D(foo, uv); |
|
vec4 faded = texel; |
|
|
|
/* kernel from https://gist.github.com/rasteron/2019a4890e0d6311297f */ |
|
faded.x = dot(texel.xyz, vec3(0.393, 0.769, 0.189)); |
|
faded.y = dot(texel.xyz, vec3(0.349, 0.686, 0.168)); |
|
faded.z = dot(texel.xyz, vec3(0.272, 0.534, 0.131)); |
|
|
|
gl_FragColor.xyz = mix(texel.xyz, faded.xyz, step(0.5, uv.x)); |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: vignette |
|
samplers: |
|
- name: stage |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D stage; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
vec4 texel = texture2D(stage, uv); |
|
|
|
float lum = (texel.x * 0.3) + (texel.y * 0.6) + (texel.z * 0.1); |
|
float dist = pow(uv.x - 0.5, 2.0) + pow(uv.y - 0.5, 2.0); |
|
dist = 1.0 - clamp(dist, 0.0, 1.0); |
|
|
|
gl_FragColor.xyz = mix(texel.xyz, vec3(lum), 1.0 - pow(dist, 9.0)); /* desat */ |
|
gl_FragColor.xyz = gl_FragColor.xyz * vec3(pow(dist, 3.0)); /* darken */ |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: distort |
|
samplers: |
|
- name: stage |
|
source: stage |
|
- name: normal |
|
source: glass-normal |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D stage; |
|
uniform sampler2D normal; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 pixel = vec2(1.0 / 1024.0, 1.0 / 768.0); |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec2 normal = texture2D(normal, uv).xy; |
|
normal = normalize(normal * 2.0 - 1.0); |
|
|
|
vec2 offset = normal * pixel * 8.0; |
|
vec4 texel = texture2D(stage, uv + offset); |
|
vec4 original = texture2D(stage, uv); |
|
|
|
gl_FragColor.xyz = (original.xyz + mix(texel.xyz, original.xyz, step(0.5, uv.x))) / 2.0; |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: color-curve |
|
samplers: |
|
- name: stage |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
const vec3 lumF = vec3(0.2125, 0.7145, 0.0721); |
|
const vec2 anchor0 = vec2(0.0, 0.0); |
|
const vec2 anchor3 = vec2(1.0, 1.0); |
|
|
|
uniform vec2 anchor1; |
|
uniform vec2 anchor2; |
|
|
|
uniform sampler2D stage; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 uv = outTexCoord.xy; |
|
vec4 texel = texture2D(stage, uv); |
|
|
|
float lum = dot(texel.xyz, lumF); |
|
vec2 curve = /* 4-point bezier */ |
|
(pow(1.0 - lum, 3.0) * anchor0) + |
|
(pow(1.0 - lum, 2.0) * anchor1 * 3.0 * lum) + |
|
((1.0 - lum) * anchor2 * 3.0 * pow(lum, 2.0)) + |
|
(pow(lum, 3.0) * anchor3); |
|
|
|
float dist = 0.5 + pow(curve.y - lum, 0.5); |
|
|
|
gl_FragColor.xyz = texel.xyz * dist; |
|
/* gl_FragColor.xyz = vec3(dist); */ |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: gaussianX |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 pixel = vec2(1.0) / vec2(1024.0, 768.0); |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec4 texN3 = texture2D(foo, vec2(uv.x - (pixel.x * 3.0), uv.y)) * 0.00038771; |
|
vec4 texN2 = texture2D(foo, vec2(uv.x - (pixel.x * 2.0), uv.y)) * 0.01330373; |
|
vec4 texN1 = texture2D(foo, vec2(uv.x - (pixel.x * 1.0), uv.y)) * 0.11098164; |
|
vec4 tex00 = texture2D(foo, uv) * 0.22508352; |
|
vec4 texP1 = texture2D(foo, vec2(uv.x + (pixel.x * 1.0), uv.y)) * 0.11098164; |
|
vec4 texP2 = texture2D(foo, vec2(uv.x + (pixel.x * 2.0), uv.y)) * 0.01330373; |
|
vec4 texP3 = texture2D(foo, vec2(uv.x + (pixel.x * 3.0), uv.y)) * 0.00038771; |
|
|
|
gl_FragColor = (texN3 + texN2 + texN1 + tex00 + texP1 + texP2 + texP3); |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: gaussianY |
|
samplers: |
|
- name: foo |
|
source: stage |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D foo; |
|
|
|
varying vec2 outTexCoord; |
|
varying vec4 outTint; |
|
|
|
void main() |
|
{ |
|
vec2 pixel = vec2(1.0) / vec2(1024.0, 768.0); |
|
vec2 uv = outTexCoord.xy; |
|
|
|
vec4 texN3 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 3.0))) * 0.00038771; |
|
vec4 texN2 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 2.0))) * 0.01330373; |
|
vec4 texN1 = texture2D(foo, vec2(uv.x, uv.y - (pixel.y * 1.0))) * 0.11098164; |
|
vec4 tex00 = texture2D(foo, uv) * 0.22508352; |
|
vec4 texP1 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 1.0))) * 0.11098164; |
|
vec4 texP2 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 2.0))) * 0.01330373; |
|
vec4 texP3 = texture2D(foo, vec2(uv.x, uv.y + (pixel.y * 3.0))) * 0.00038771; |
|
|
|
gl_FragColor = (texN3 + texN2 + texN1 + tex00 + texP1 + texP2 + texP3); |
|
gl_FragColor.w = 1.0; |
|
} |
|
- name: recombine |
|
samplers: |
|
- name: stage |
|
source: stage |
|
- name: offscreen |
|
source: offscreen |
|
fragment: |
|
precision mediump float; |
|
|
|
uniform sampler2D stage; |
|
uniform sampler2D offscreen; |
|
|
|
varying vec2 outTexCoord; |
|
|
|
void main() { |
|
vec2 uv = outTexCoord.xy; |
|
uv.y = 1.0 - uv.y; |
|
|
|
vec4 texel = texture2D(stage, outTexCoord); |
|
vec4 glow = texture2D(offscreen, uv); |
|
|
|
gl_FragColor.xyz = texel.xyz + glow.xyz; |
|
gl_FragColor.w = 1.0; |
|
} |