public static void SetFilter(BlurFilterFormat format, bool xAxis, SinglePassTextureFilter target, bool supportsFiltering, float bellExponent) { lock (weights) { int kernel = GenerateFilter(format, supportsFiltering, bellExponent); Vector2 axis = new Vector2(xAxis ? 1 : 0, xAxis ? 0 : 1); for (int i = 0; i < 16; i++) { offsetsV[i] = axis * offset[i]; } target.SetFilter(offsetsV, weights, kernel); } }
/// <summary> /// Blur the source horizontally to the <paramref name="intermediate"/> target, then blur vertically to <paramref name="target"/>. /// </summary> /// <param name="source"></param> /// <param name="filterFormat">format of the blur filter</param> /// <param name="intermediate">draw target to use as a temporary, intermediate target for blurring</param> /// <param name="target"></param> /// <param name="bellCurveExponent"> /// <para>A scale value to infulence the bell curve used to generate the filter kernel.</para> /// <para>A value of 1.0 generates a standard blur filter kernels. Larger values will produce a tighter curve, and less blur.</para> /// <para>Smaller values will produce a wider curve, and a larger blur - but may produce a visible edge as the curve more rapidly ends.</para> /// </param> public BlurFilter(BlurFilterFormat filterFormat, float bellCurveExponent, DrawTargetTexture2D source, DrawTargetTexture2D intermediate, DrawTargetTexture2D target) { if (target == null || source == null) { throw new ArgumentNullException(); } if (intermediate != null && source.SurfaceFormat != intermediate.SurfaceFormat) { throw new ArgumentException("source.SurfaceFormat != intermediate.SurfaceFormat"); } if (intermediate != null && target.SurfaceFormat != intermediate.SurfaceFormat) { throw new ArgumentException("target.SurfaceFormat != intermediate.SurfaceFormat"); } this.source = source; #if XBOX360 //if the surface will fit into EDRAM then the intermediate can be skipped if (source.Width * source.Height * DrawTarget.FormatSize(source.SurfaceFormat) < 1000 * 1000 * 10) //approx { this.filterV = new SinglePassTextureFilter(source, target); this.filterH = new SinglePassTextureFilter(target, target); } else { this.filterV = new SinglePassTextureFilter(source, intermediate); this.filterH = new SinglePassTextureFilter(intermediate, source); } #else this.filterV = new SinglePassTextureFilter(source, intermediate); this.filterH = new SinglePassTextureFilter(intermediate, target); #endif SetFilterFormat(filterFormat, bellCurveExponent); }
/// <summary> /// Blur the source horizontally to the <paramref name="intermediate"/> target, then blur vertically to <paramref name="target"/>. /// </summary> /// <param name="source"></param> /// <param name="filterFormat">format of the blur filter</param> /// <param name="intermediate">draw target to use as a temporary, intermediate target for blurring</param> /// <param name="target"></param> /// <param name="bellCurveExponent"> /// <para>A scale value to infulence the bell curve used to generate the filter kernel.</para> /// <para>A value of 1.0 generates a standard blur filter kernels. Larger values will produce a tighter curve, and less blur.</para> /// <para>Smaller values will produce a wider curve, and a larger blur - but may produce a visible edge as the curve more rapidly ends.</para> /// </param> public BlurFilter(BlurFilterFormat filterFormat, float bellCurveExponent, DrawTargetTexture2D source, DrawTargetTexture2D intermediate, DrawTargetTexture2D target) { if (target == null || source == null) throw new ArgumentNullException(); if (intermediate != null && source.SurfaceFormat != intermediate.SurfaceFormat) throw new ArgumentException("source.SurfaceFormat != intermediate.SurfaceFormat"); if (intermediate != null && target.SurfaceFormat != intermediate.SurfaceFormat) throw new ArgumentException("target.SurfaceFormat != intermediate.SurfaceFormat"); this.source = source; this.filterV = new SinglePassTextureFilter(source, intermediate); this.filterH = new SinglePassTextureFilter(intermediate, target); SetFilterFormat(filterFormat, bellCurveExponent); }
public static void SetFilter(BlurFilterFormat format, bool xAxis, SinglePassTextureFilter target, bool supportsFiltering, float bellExponent) { lock (weights) { int kernel = GenerateFilter(format, supportsFiltering, bellExponent); Vector2 axis = new Vector2(xAxis ? 1 : 0, xAxis ? 0 : 1); for (int i = 0; i < 16; i++) offsetsV[i] = axis * offset[i]; target.SetFilter(offsetsV, weights, kernel); } }