/// <summary>
		/// Creates and initializes a new lens tilt depth-of-field effect.
		/// </summary>
		/// <param name="source">The source image to be blurred.</param>
		/// <param name="focusBand">The band that represents the focus area in the image. Pixels within this band won't be blurred. 
		/// Areas outside of the area will be progressively more blurred as the distance from the focus band increases..</param>
		/// <param name="blurStrengthAtEdge1">Strength of the blur on the Edge1 side of the focus band.</param>
		/// <param name="blurStrengthAtEdge2">Strength of the blur on the Edge2 side of the focus band.</param>
		public LensTiltDepthOfFieldEffect(IImageProvider source, FocusBand focusBand, double strengthAtEdge1, double strengthAtEdge2, DepthOfFieldQuality quality)
			: base(source, quality)
		{
			FocusBand = focusBand;
			StrengthAtEdge1 = strengthAtEdge1;
			StrengthAtEdge2 = strengthAtEdge2;
		}
		/// <summary>
		/// Creates and initializes a new focus object depth-of-field effect.
		/// </summary>
		/// <param name="source">The image source to apply the effect to</param>
		/// <param name="objectMaskSource">A grayscale mask that represents the object in the image that shall be kept in focus.</param>
		/// <param name="horizonPoint1">The first point defining the horizon line.</param>
		/// <param name="horizonPoint2">The second point defining the horizon line.</param>
		/// <param name="strengthBelowHorizon">The strength of the blur effect below the horizon line.</param>
		/// <param name="strengthAboveHorizon">The strength of the blur effect above the horizon line.</param>
		public FocusObjectDepthOfFieldEffect(IImageProvider source, IImageProvider objectMaskSource, Point horizonPoint1, Point horizonPoint2, double strengthBelowHorizon, double strengthAboveHorizon, DepthOfFieldQuality quality)
			: base(source, quality)
		{
			ObjectMaskSource = objectMaskSource;
			HorizonPoint1 = horizonPoint1;
			HorizonPoint2 = horizonPoint2;
			StrengthBelowHorizon = strengthBelowHorizon;
			StrengthAboveHorizon = strengthAboveHorizon;
		}
Beispiel #3
0
        private static async Task RenderEffect(FocusBand focusBand, DepthOfFieldQuality quality, [CallerMemberName] string testName = "")
        {
            using (var source = await KnownImages.Nurse.GetImageSourceAsync())
                using (var effect = new LensTiltDepthOfFieldEffect(source, focusBand, 1.0, 1.0, quality))
                    using (var renderer = new JpegRenderer(effect))
                    {
                        var buffer = await renderer.RenderAsync();

                        await FileUtilities.SaveToPicturesLibraryAsync(buffer, "LensTiltDepthOfFieldEffectTest_" + testName + ".jpg");
                    }
        }
Beispiel #4
0
 private RenderTexture BlurTapPass(RenderTexture halfResSource, RenderTexture tiledData, RenderTexture neighbourhoodData, RenderTexture depthCenterAverage, DepthOfFieldQuality qualityLevel)
 {
     Material material = (qualityLevel != DepthOfFieldQuality.Normal) ? this.m_DoFMatDX11 : this.m_DoFMat;
     material.SetTexture("_TiledData", tiledData);
     material.SetTexture("_TiledNeighbourhoodData", neighbourhoodData);
     material.SetTexture("_HalfResSourceTexture", halfResSource);
     if (depthCenterAverage != null)
     {
         material.SetTexture("_AvgCenterDepth", depthCenterAverage);
     }
     halfResSource.filterMode = FilterMode.Point;
     RenderTexture temporary = RenderTexture.GetTemporary(halfResSource.width, halfResSource.height, 0, halfResSource.format);
     temporary.filterMode = FilterMode.Point;
     temporary.wrapMode = TextureWrapMode.Clamp;
     if (qualityLevel == DepthOfFieldQuality.Normal)
     {
         ScionGraphics.Blit(temporary, this.m_DoFMat, 5);
     }
     else if (qualityLevel == DepthOfFieldQuality.High_DX11)
     {
         ScionGraphics.Blit(temporary, this.m_DoFMatDX11, 0);
     }
     return temporary;
 }
Beispiel #5
0
 protected DepthOfFieldEffect(IImageProvider source, DepthOfFieldQuality quality)
     : base(source)
 {
     LensBlurEffect = new LensBlurEffect(source);
     Quality        = quality;
 }
		/// <summary>
		/// Creates and initializes a new elliptic focus depth-of-field effect.
		/// </summary>
		/// <param name="source">The source image to be blurred.</param>
		/// <param name="ellipse">The desired focus area within the image.</param>
		/// <param name="strength">The strength of the blur effect.</param>
		/// <param name="quality">The quality of the effect.</param>
		public EllipticFocusDepthOfFieldEffect(IImageProvider source, FocusEllipse focusArea, double strength, DepthOfFieldQuality quality)
			: base(source, quality)
		{
			FocusArea = focusArea;
			Strength = strength;
		}
		protected DepthOfFieldEffect(IImageProvider source, DepthOfFieldQuality quality)
			: base(source)
		{
			LensBlurEffect = new LensBlurEffect(source);
			Quality = quality;
		}
Beispiel #8
0
        private RenderTexture BlurTapPass(RenderTexture halfResSource, RenderTexture tiledData, RenderTexture neighbourhoodData, RenderTexture depthCenterAverage, DepthOfFieldQuality qualityLevel)
        {
            Material material = (qualityLevel != DepthOfFieldQuality.Normal) ? this.m_DoFMatDX11 : this.m_DoFMat;

            material.SetTexture("_TiledData", tiledData);
            material.SetTexture("_TiledNeighbourhoodData", neighbourhoodData);
            material.SetTexture("_HalfResSourceTexture", halfResSource);
            if (depthCenterAverage != null)
            {
                material.SetTexture("_AvgCenterDepth", depthCenterAverage);
            }
            halfResSource.filterMode = FilterMode.Point;
            RenderTexture temporary = RenderTexture.GetTemporary(halfResSource.width, halfResSource.height, 0, halfResSource.format);

            temporary.filterMode = FilterMode.Point;
            temporary.wrapMode   = TextureWrapMode.Clamp;
            if (qualityLevel == DepthOfFieldQuality.Normal)
            {
                ScionGraphics.Blit(temporary, this.m_DoFMat, 5);
            }
            else if (qualityLevel == DepthOfFieldQuality.High_DX11)
            {
                ScionGraphics.Blit(temporary, this.m_DoFMatDX11, 0);
            }
            return(temporary);
        }
 /// <summary>
 /// Creates and initializes a new elliptic focus depth-of-field effect.
 /// </summary>
 /// <param name="source">The source image to be blurred.</param>
 /// <param name="ellipse">The desired focus area within the image.</param>
 /// <param name="strength">The strength of the blur effect.</param>
 /// <param name="quality">The quality of the effect.</param>
 public EllipticFocusDepthOfFieldEffect(IImageProvider source, FocusEllipse focusArea, double strength, DepthOfFieldQuality quality)
     : base(source, quality)
 {
     FocusArea = focusArea;
     Strength  = strength;
 }
Beispiel #10
0
 /// <summary>
 /// Creates and initializes a new lens tilt depth-of-field effect.
 /// </summary>
 /// <param name="source">The source image to be blurred.</param>
 /// <param name="focusBand">The band that represents the focus area in the image. Pixels within this band won't be blurred.
 /// Areas outside of the area will be progressively more blurred as the distance from the focus band increases..</param>
 /// <param name="blurStrengthAtEdge1">Strength of the blur on the Edge1 side of the focus band.</param>
 /// <param name="blurStrengthAtEdge2">Strength of the blur on the Edge2 side of the focus band.</param>
 public LensTiltDepthOfFieldEffect(IImageProvider source, FocusBand focusBand, double strengthAtEdge1, double strengthAtEdge2, DepthOfFieldQuality quality)
     : base(source, quality)
 {
     FocusBand       = focusBand;
     StrengthAtEdge1 = strengthAtEdge1;
     StrengthAtEdge2 = strengthAtEdge2;
 }
Beispiel #11
0
        private RenderTexture BlurTapPass(RenderTexture halfResSource, RenderTexture tiledData, RenderTexture neighbourhoodData,
                                          RenderTexture exclusionMask, RenderTexture depthCenterAverage, DepthOfFieldQuality qualityLevel)
        {
            Material dofMat = qualityLevel == DepthOfFieldQuality.Normal ? m_DoFMat : m_DoFMatDX11;

            dofMat.SetTexture("_TiledData", tiledData);
            dofMat.SetTexture("_TiledNeighbourhoodData", neighbourhoodData);
            dofMat.SetTexture("_HalfResSourceTexture", halfResSource);             //Actually the prefiltered half res
            if (exclusionMask != null)
            {
                dofMat.SetTexture("_ExclusionMask", exclusionMask);
            }
            if (depthCenterAverage != null)
            {
                dofMat.SetTexture("_AvgCenterDepth", depthCenterAverage);
            }
            halfResSource.filterMode = FilterMode.Point;

            RenderTexture blurTexture = RenderTexture.GetTemporary(halfResSource.width, halfResSource.height, 0, halfResSource.format);

            blurTexture.filterMode = FilterMode.Point;
            blurTexture.wrapMode   = TextureWrapMode.Clamp;

            if (qualityLevel == DepthOfFieldQuality.Normal)
            {
                ScionGraphics.Blit(blurTexture, m_DoFMat, 5);
            }
            else if (qualityLevel == DepthOfFieldQuality.High_DX11)
            {
                ScionGraphics.Blit(blurTexture, m_DoFMatDX11, 0);
            }

            return(blurTexture);
        }
 /// <summary>
 /// Creates and initializes a new focus object depth-of-field effect.
 /// </summary>
 /// <param name="source">The image source to apply the effect to</param>
 /// <param name="objectMaskSource">A grayscale mask that represents the object in the image that shall be kept in focus.</param>
 /// <param name="horizonPoint1">The first point defining the horizon line.</param>
 /// <param name="horizonPoint2">The second point defining the horizon line.</param>
 /// <param name="strengthBelowHorizon">The strength of the blur effect below the horizon line.</param>
 /// <param name="strengthAboveHorizon">The strength of the blur effect above the horizon line.</param>
 public FocusObjectDepthOfFieldEffect(IImageProvider source, IImageProvider objectMaskSource, Point horizonPoint1, Point horizonPoint2, double strengthBelowHorizon, double strengthAboveHorizon, DepthOfFieldQuality quality)
     : base(source, quality)
 {
     ObjectMaskSource     = objectMaskSource;
     HorizonPoint1        = horizonPoint1;
     HorizonPoint2        = horizonPoint2;
     StrengthBelowHorizon = strengthBelowHorizon;
     StrengthAboveHorizon = strengthAboveHorizon;
 }
        private static async Task RenderEffect(FocusBand focusBand, DepthOfFieldQuality quality, [CallerMemberName] string testName = "")
        {
			using (var source = KnownImages.Nurse.ImageSource)
            using (var effect = new LensTiltDepthOfFieldEffect(source, focusBand, 1.0, 1.0, quality))
            using (var renderer = new JpegRenderer(effect))
            {
                var buffer = await renderer.RenderAsync();

				ImageResults.Instance.SaveToPicturesLibrary(buffer, "LensTiltDepthOfFieldEffectTest_" + testName + ".jpg");
            }
        }