Shaders: Add uniforms to AGS-001
Jeffrey Pfau jeffrey@endrift.com
Sun, 08 Nov 2015 17:10:10 -0800
2 files changed,
32 insertions(+),
6 deletions(-)
M
res/shaders/ags001.shader/ags001-light.fs
→
res/shaders/ags001.shader/ags001-light.fs
@@ -1,14 +1,27 @@
varying vec2 texCoord; uniform sampler2D tex; +uniform float reflectionBrightness; +uniform vec2 reflectionDistance; +uniform float lightBrightness; + +const float speed = 2.0; +const float decay = 2.0; +const float coeff = 2.5; void main() { + float sp = pow(speed, lightBrightness); + float dc = pow(decay, -lightBrightness); + float s = (sp - dc) / (sp + dc); + vec2 radius = (texCoord.st - vec2(0.5, 0.5)) * vec2(coeff * s); + radius = pow(radius, vec2(4.0)); + vec3 bleed = vec3(0.12, 0.14, 0.19); + bleed += (dot(radius, radius) + vec3(0.02, 0.03, 0.05)) * vec3(0.14, 0.18, 0.2); + vec4 color = texture2D(tex, texCoord); - vec4 reflection = texture2D(tex, texCoord - vec2(0, 0.025)); - vec3 bleed = vec3(0.12, 0.14, 0.19); - vec2 radius = (texCoord.st - vec2(0.5, 0.5)) * vec2(1.6, 1.6); - bleed += (dot(pow(radius, vec2(4.0)), pow(radius, vec2(4.0))) + vec3(0.02, 0.03, 0.05)) * vec3(0.14, 0.18, 0.2); - color.rgb += bleed; - color.rgb += reflection.rgb * 0.07; + color.rgb += pow(bleed, pow(vec3(lightBrightness), vec3(-0.5))); + + vec4 reflection = texture2D(tex, texCoord - reflectionDistance); + color.rgb += reflection.rgb * reflectionBrightness; color.a = 1.0; gl_FragColor = color; }
M
res/shaders/ags001.shader/manifest.ini
→
res/shaders/ags001.shader/manifest.ini
@@ -14,3 +14,16 @@ [pass.1]
fragmentShader=ags001-light.fs width=960 height=640 + +[uniform.lightBrightness] +type=float +default=1 + +[uniform.reflectionBrightness] +type=float +default=0.07 + +[uniform.reflectionDistance] +type=float2 +default[0]=0 +default[1]=0.025