diff options
Diffstat (limited to 'Studio/Content/Effect Library/Depth Of Field HQ Blur.effect')
-rw-r--r-- | Studio/Content/Effect Library/Depth Of Field HQ Blur.effect | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Studio/Content/Effect Library/Depth Of Field HQ Blur.effect b/Studio/Content/Effect Library/Depth Of Field HQ Blur.effect new file mode 100644 index 0000000..6649bf7 --- /dev/null +++ b/Studio/Content/Effect Library/Depth Of Field HQ Blur.effect @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<Effect> + <MetaData> + <Property name="FocusDistance" formalName="Focus Distance" description="Objects exactly distance +- "In Focus Width"\nfrom the camera will be in focus" default="600"/> + <Property name="FocusWidth" formalName="Depth of Field" description="Objects within this range of Focus\nDistance will be in focus" default="20"/> + <Property name="DepthDebug" formalName="Debug Focus Rendering" type="Boolean" description="Allows you to see exactly how the Focus\nvariables work. Black objects are in\nfocus, white are blurred" default="False"/> + <Property name="DepthSampler" type="Texture" filter="nearest" clamp="clamp"/> + <Property name="SourceSampler" type="Texture" filter="linear" clamp="clamp"/> + </MetaData> + <Shaders> + <Shared> +#include "blur.glsllib" +const float BlurAmount = 4.0; + </Shared> + <Shader name="DOWNSAMPLE"> + <VertexShader> +void vert() +{ + SetupBoxBlurCoords(vec2(Texture0Info.xy)); +} + </VertexShader> + <FragmentShader> +void frag() // Simple averaging box blur. +{ + gl_FragColor = BoxDepthBlur(DepthSampler, Texture0, Texture0Info.z, FocusDistance, FocusWidth, FocusWidth); +} + </FragmentShader> + </Shader> + <Shader name="BLUR"> + <VertexShader> + +void vert() +{ + SetupPoissonBlurCoords( BlurAmount, DestSize.xy ); +} + + </VertexShader> + <FragmentShader> + +void frag() // Mix the input blur and the depth texture with the sprite +{ + float centerMultiplier = GetDepthMultiplier( TexCoord, DepthSampler, FocusDistance, FocusWidth, FocusWidth ); + if ( DepthDebug ) + { + gl_FragColor = vec4( centerMultiplier,centerMultiplier,centerMultiplier, 1.0 ); + } + else + { + vec4 blurColor = PoissonDepthBlur(Texture0, Texture0Info.z, DepthSampler, FocusDistance, FocusWidth, FocusWidth ); + gl_FragColor = mix( texture2D_SourceSampler(TexCoord), blurColor, centerMultiplier ); + } +} + </FragmentShader> + </Shader> + </Shaders> + <Passes> + <Buffer name="downsample_buffer" type="ubyte" format="rgba" filter="linear" wrap="clamp" size=".5" lifetime="frame"/> + <Pass shader="DOWNSAMPLE" input="[source]" output="downsample_buffer"> + <DepthInput param="DepthSampler"/> + </Pass> + <Pass shader="BLUR" input="downsample_buffer"> + <BufferInput value="[source]" param="SourceSampler" /> + <DepthInput param="DepthSampler"/> + </Pass> + </Passes> +</Effect> + |