summaryrefslogtreecommitdiffstats
path: root/Studio/Content/Effect Library/ChromaticAberration.effect
diff options
context:
space:
mode:
Diffstat (limited to 'Studio/Content/Effect Library/ChromaticAberration.effect')
-rw-r--r--Studio/Content/Effect Library/ChromaticAberration.effect56
1 files changed, 56 insertions, 0 deletions
diff --git a/Studio/Content/Effect Library/ChromaticAberration.effect b/Studio/Content/Effect Library/ChromaticAberration.effect
new file mode 100644
index 0000000..6b553e7
--- /dev/null
+++ b/Studio/Content/Effect Library/ChromaticAberration.effect
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Effect>
+ <MetaData>
+ <Property name="Dispersion" formalName="Aberration Amount" description="Amount of Chromatic Aberration" default="0"/>
+ <Property name="FocusDepth" formalName="Focus Depth" description="Dispersion will scale in relation\nto distance from this depth" default="0"/>
+ <Property name="MaskSampler" formalName="Effect Mask" description="Grayscale texture to control where and how\nstrong on screen the aberration effect occurs" type="Texture" filter="linear" clamp="clamp" default="./maps/effects/white.png" />
+ <Property name="DepthDebug" formalName="Debug Dispersion Amount" type="Boolean" description="Allows you to see effect of controls.\nBlack objects will disperse less and\nwhite will disperse more" default="False"/>
+ <Property name="DepthSampler" type="Texture" filter="nearest" clamp="clamp"/>
+ <Property name="SourceSampler" type="Texture" filter="linear" clamp="clamp"/>
+ </MetaData>
+ <Shaders>
+ <Shader Name="DISPERSE">
+ <FragmentShader>
+#include "depthpass.glsllib"
+
+uniform vec2 CameraClipRange;
+
+void frag()
+{
+ vec4 depthSample = texture(DepthSampler, TexCoord);
+ float depthVal = getDepthValue( depthSample, CameraClipRange );
+ float rawDepth = depthValueToLinearDistance( depthVal, CameraClipRange );
+
+ float depthScale = abs(CameraClipRange.y - CameraClipRange.x);
+ float depthDisp = abs(rawDepth - FocusDepth) / depthScale;
+ float finalDisperse = Dispersion * depthDisp;
+ float effectAmt = texture(MaskSampler, TexCoord).x;
+
+ if ( DepthDebug )
+ {
+ gl_FragColor.rgb = vec3( depthDisp * effectAmt );
+ return;
+ }
+
+ gl_FragColor = texture(SourceSampler, TexCoord);
+
+ ivec2 texSize = textureSize( SourceSampler, 0 );
+ vec2 dispDir = normalize( TexCoord.xy - vec2(0.5) );
+ dispDir /= 2.0 * vec2( texSize );
+ vec3 mixColor;
+ mixColor = gl_FragColor.rgb;
+ mixColor.r = texture(SourceSampler, TexCoord+dispDir*finalDisperse).r;
+ mixColor.b = texture(SourceSampler, TexCoord-dispDir*finalDisperse).b;
+
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, mixColor, effectAmt );
+}
+ </FragmentShader>
+ </Shader>
+ </Shaders>
+ <Passes>
+ <Pass shader="DISPERSE">
+ <BufferInput value="[source]" param="SourceSampler" />
+ <DepthInput param="DepthSampler"/>
+ </Pass>
+ </Passes>
+</Effect>