summaryrefslogtreecommitdiffstats
path: root/Studio/Content/Effect Library/Distortion Sphere.effect
diff options
context:
space:
mode:
Diffstat (limited to 'Studio/Content/Effect Library/Distortion Sphere.effect')
-rw-r--r--Studio/Content/Effect Library/Distortion Sphere.effect46
1 files changed, 46 insertions, 0 deletions
diff --git a/Studio/Content/Effect Library/Distortion Sphere.effect b/Studio/Content/Effect Library/Distortion Sphere.effect
new file mode 100644
index 0000000..3ed1e70
--- /dev/null
+++ b/Studio/Content/Effect Library/Distortion Sphere.effect
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Effect>
+ <MetaData>
+ <!--Distorts the image in a spherical way.-->
+ <Property name="radius" formalName="Radius" min="0" max="1" default=".3" description="Adjusts the distorted area."/>
+ <Property name="height" formalName="Height" min="-1" max="1" default=".3" description="Adjusts the distortion amount."/>
+ <Property name="center" formalName="Center" type="Float2" default="0.5 0.5" description="Adjusts the focus point of the distortion."/>
+ </MetaData>
+ <Shaders>
+ <Shared>
+varying vec2 center_vec;
+ </Shared>
+ <Shader>
+ <VertexShader>
+void vert ()
+{
+ center_vec = TexCoord - center;
+ //Multiply by x/y ratio so we see a sphere on the screen
+ //instead of an ellipse.
+ center_vec.y *= Texture0Info.y / Texture0Info.x;
+}
+ </VertexShader>
+ <FragmentShader>
+<![CDATA[
+void frag()
+{
+ float dist_to_center = length(center_vec) / radius;;
+
+ vec2 texc;
+ if(dist_to_center > 1.0) {
+ texc = TexCoord;
+ } else {
+ float distortion = 1.0 - dist_to_center * dist_to_center;
+ texc = TexCoord - (TexCoord - center) * distortion * height;
+ }
+
+ if ( texc.x < 0.0 || texc.x > 1.0 || texc.y < 0.0 || texc.y > 1.0 )
+ gl_FragColor = vec4(0.0);
+ else
+ colorOutput(texture2D_0(texc));
+}
+]]>
+ </FragmentShader>
+ </Shader>
+ </Shaders>
+</Effect> \ No newline at end of file