diff options
author | Pasi Keränen <pasi.keranen@qt.io> | 2019-06-06 16:22:02 +0300 |
---|---|---|
committer | Pasi Keränen <pasi.keranen@qt.io> | 2019-06-07 13:52:44 +0300 |
commit | b4954701093739e7a4e54a0669f306922d0d4605 (patch) | |
tree | 73d71319a921234f6b507c9098fdc842f7fe06dc /Studio/Content/Effect Library/Stylize - Scatter.effect | |
parent | 8548a5f5579e3eee7e5ae6b1f6901dcc8bfee19e (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/Stylize - Scatter.effect')
-rw-r--r-- | Studio/Content/Effect Library/Stylize - Scatter.effect | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Studio/Content/Effect Library/Stylize - Scatter.effect b/Studio/Content/Effect Library/Stylize - Scatter.effect new file mode 100644 index 0000000..7bd30b5 --- /dev/null +++ b/Studio/Content/Effect Library/Stylize - Scatter.effect @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<Effect> + <MetaData> + <!--Scatters the pixels in a layer, creating a blurry or smeared appearance. Without changing the color of each individual pixel, the Scatter effect redistributes the pixels randomly, but in the same general area as their original positions.--> + <Property name="NoiseSamp" formalName="Noise" filter="linear" clamp="repeat" type="Texture" default="./maps/effects/brushnoise.png" hidden="True"/> + <Property name="Amount" formalName="Scatter Amount" min="0" max="127" default="20.0" description="Determines how much to scatter."/> + <Property name="dir" formalName="Grain" list="Both:Horizontal:Vertical" default="Both" description="The direction in which to scatter the\npixels, horizontally or vertically.\nSelect Both to scatter pixels in all directions."/> + <Property name="isRand" formalName="Randomize Every Frame" type="Boolean" default="False" description="Specifies whether scattering changes at\neach frame. To animate scattering without\nkeyframes, select the Randomize Every Frame\noption."/> + </MetaData> + <Shaders> + <Shader> + <FragmentShader> +uniform float AppFrame; // frame number since app starts +void frag (void) +{ + float size = 15.0; + float amount = Amount / 127.0 * 0.4; + + vec2 uv = TexCoord * size; + if (isRand) + uv = fract(uv + 0.031 * AppFrame); + + uv = texture2D_NoiseSamp(fract(uv)).xy - 0.5; + + if (dir == 0) { // both directions + uv *= (vec2(1.5, 0.15) * amount); + + } else if (dir == 1) { // x direction + uv *= (vec2(1.3, 0.0) * amount); + + } else { // y direction + uv *= (vec2(0.0, 0.29) * amount); + } + + uv += TexCoord; + + // shift half of a pixel size of the source to avoid the artifact on upper right borders. + // FBO size is bigger than the sprite, so clamping to [0, 1] will introduce artifacts + // (when OpenGL glTexParameter is set to linear). Lets not rely on OpenGL to clamp. we + // do it here. + vec2 halfPixelSize = 0.5 / Texture0Info.xy; + colorOutput(texture2D_0(clamp(uv, halfPixelSize, 1.0-halfPixelSize))); +} + </FragmentShader> + </Shader> + </Shaders> +</Effect> |