summaryrefslogtreecommitdiffstats
path: root/Studio/Content/Effect Library/Distortion Ripple.effect
diff options
context:
space:
mode:
authorPasi Keränen <pasi.keranen@qt.io>2019-06-06 16:22:02 +0300
committerPasi Keränen <pasi.keranen@qt.io>2019-06-07 13:52:44 +0300
commitb4954701093739e7a4e54a0669f306922d0d4605 (patch)
tree73d71319a921234f6b507c9098fdc842f7fe06dc /Studio/Content/Effect Library/Distortion Ripple.effect
parent8548a5f5579e3eee7e5ae6b1f6901dcc8bfee19e (diff)
Long live the slayer!
Initial commit of OpenGL Runtime to repository. Based on SHA1 61823aaccc6510699a54b34a2fe3f7523dab3b4e of qt3dstudio repository. Task-number: QT3DS-3600 Change-Id: Iaeb80237399f0e5656a19ebec9d1ab3a681d8832 Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
Diffstat (limited to 'Studio/Content/Effect Library/Distortion Ripple.effect')
-rw-r--r--Studio/Content/Effect Library/Distortion Ripple.effect50
1 files changed, 50 insertions, 0 deletions
diff --git a/Studio/Content/Effect Library/Distortion Ripple.effect b/Studio/Content/Effect Library/Distortion Ripple.effect
new file mode 100644
index 0000000..0929be1
--- /dev/null
+++ b/Studio/Content/Effect Library/Distortion Ripple.effect
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Effect>
+ <MetaData>
+ <!--Distorts the image in a ripple way.-->
+ <Property name="radius" formalName="Radius" min="0" max="100" default="100.0" description="Adjusts the spread between ripples."/>
+ <Property name="center" formalName="Center" type="Float2" default="0.5 0.5" description="Adjusts the focus point of the distortion."/>
+ <Property name="ripples" formalName="Wave Width" min="2" max="100" default="95.0" description="Adjusts the number of ripples."/>
+ <Property name="height" formalName="Wave Height" min="0" max="100" default="25.0" description="Adjusts the distortion amount."/>
+ <Property name="phase" formalName="Ripple Phase" default="0.0" description="The offset of each wave. Animate this\nproperty to see the waves move."/>
+ </MetaData>
+ <Shaders>
+ <Shared>
+varying vec2 center_vec;
+float PI2 = radians(360.0);
+ </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) * 100.0 / radius;;
+
+ vec2 texc;
+ if(dist_to_center > 1.0) {
+ texc = TexCoord;
+ } else {
+ float r = PI2 * (1.0 - dist_to_center);
+ float distortion = sin(r * (100.0-ripples) + radians(phase));
+ texc = TexCoord - ( TexCoord - center ) * distortion * height / 800.0;
+ }
+
+ 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>