Пример #1
0
 public RenderTexture RenderDepthOfField(PostProcessParameters postProcessParams, RenderTexture source, RenderTexture dest, VirtualCamera virtualCamera)
 {
     this.CreateDX11Mat();
     virtualCamera.BindVirtualCameraTextures(this.m_DoFMat);
     if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
     {
         virtualCamera.BindVirtualCameraTextures(this.m_DoFMatDX11);
     }
     virtualCamera.BindVirtualCameraParams(this.m_DoFMat, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, (float)postProcessParams.halfWidth, postProcessParams.isFirstRender);
     if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
     {
         virtualCamera.BindVirtualCameraParams(this.m_DoFMatDX11, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, (float)postProcessParams.halfWidth, postProcessParams.isFirstRender);
     }
     RenderTexture depthCenterAverage = null;
     if (postProcessParams.DoFParams.depthFocusMode == DepthFocusMode.PointAverage)
     {
         depthCenterAverage = this.PrepatePointAverage(postProcessParams, dest);
     }
     RenderTexture renderTexture = this.CreateTiledData(postProcessParams.halfResDepth, postProcessParams.preCalcValues.tanHalfFoV, postProcessParams.cameraParams.fNumber, postProcessParams.DoFParams.focalDistance, postProcessParams.DoFParams.focalRange, postProcessParams.cameraParams.apertureDiameter, postProcessParams.cameraParams.focalLength, postProcessParams.DoFParams.maxCoCRadius, postProcessParams.cameraParams.nearPlane, postProcessParams.cameraParams.farPlane);
     RenderTexture renderTexture2 = this.TileNeighbourhoodDataGathering(renderTexture);
     RenderTexture renderTexture3 = this.PrefilterSource(postProcessParams.halfResSource);
     RenderTexture renderTexture4 = this.BlurTapPass(renderTexture3, renderTexture, renderTexture2, depthCenterAverage, postProcessParams.DoFParams.quality);
     if (postProcessParams.DoFParams.useMedianFilter)
     {
         renderTexture4 = this.MedianFilterPass(renderTexture4);
     }
     RenderTexture result = this.UpsampleDepthOfField(source, renderTexture4, renderTexture2);
     RenderTexture.ReleaseTemporary(renderTexture);
     RenderTexture.ReleaseTemporary(renderTexture2);
     RenderTexture.ReleaseTemporary(renderTexture3);
     RenderTexture.ReleaseTemporary(renderTexture4);
     return result;
 }
Пример #2
0
 private void PrepareExposure(CameraParameters cameraParams, VirtualCamera virtualCamera)
 {
     if (cameraParams.cameraMode == CameraMode.Off)
     {
         m_combinationMat.SetFloat("_ManualExposure", 1.0f);
     }
     else if (cameraParams.cameraMode != CameraMode.Manual)
     {
         virtualCamera.BindVirtualCameraTextures(m_combinationMat);
     }
     else
     {
         m_combinationMat.SetFloat("_ManualExposure", virtualCamera.CalculateManualExposure(cameraParams));
     }
 }
Пример #3
0
 private void OnEnable()
 {
     this.m_camera            = base.GetComponent <Camera>();
     this.m_bloomClass        = new Bloom();
     this.m_combinationPass   = new CombinationPass();
     this.m_downsampling      = new Downsampling();
     this.m_virtualCamera     = new VirtualCamera();
     this.m_depthOfFieldClass = new DepthOfField();
     this.m_scionDebug        = new ScionDebug();
     this.m_colorGrading      = new ColorGrading();
     this.m_isFirstRender     = true;
     this.postProcessParams.Fill(this);
     if (!this.PlatformCompatibility())
     {
         base.enabled = false;
     }
 }
Пример #4
0
        protected void OnEnable()
        {
            m_camera            = GetComponent <Camera>();
            m_cameraTransform   = m_camera.transform;
            m_bloomClass        = new Bloom();
            m_combinationPass   = new CombinationPass();
            m_downsampling      = new Downsampling();
            m_virtualCamera     = new VirtualCamera();
            m_depthOfFieldClass = new DepthOfField();
            m_scionDebug        = new ScionDebug();
            m_isFirstRender     = true;

            if (PlatformCompatibility() == false)
            {
                this.enabled = false;
            }

            InitializePostProcessParams();
        }
Пример #5
0
        public void Combine(RenderTexture source, RenderTexture dest, PostProcessParameters postProcessParams, VirtualCamera virtualCamera)
        {
            if (postProcessParams.bloom == true) PrepareBloomSampling(postProcessParams.bloomTexture, postProcessParams.glareParams);
            if (postProcessParams.lensDirt == true) PrepareLensDirtSampling(postProcessParams.lensDirtTexture, postProcessParams.lensDirtParams, postProcessParams.glareParams);
            if (postProcessParams.lensFlare == true) PrepareLensFlareSampling(postProcessParams.lensFlareParams, postProcessParams.lensFlareTexture, postProcessParams.cameraTransform);
            PrepareExposure(postProcessParams.cameraParams, virtualCamera);
            PrepareColorGrading(postProcessParams.colorGradingParams);
            UploadVariables(postProcessParams);

            //The reasoning behind the passIndex stuff is keyword avoidance
            int passIndex = 0;
            if (postProcessParams.tonemapping == false) 	passIndex += 4;
            if (postProcessParams.bloom == false)  			passIndex += 2;
            if (postProcessParams.lensDirt == false || postProcessParams.lensDirtTexture == null) passIndex += 1;

            source.filterMode = FilterMode.Bilinear;
            source.wrapMode = TextureWrapMode.Clamp;
            Graphics.Blit(source, dest, m_combinationMat, passIndex);

            //Graphics.Blit(postProcessParams.blurTexture, dest);
            //Graphics.Blit(postProcessParams.halfResSource, dest);
            //Graphics.Blit(source, dest);
        }
Пример #6
0
        public void Combine(RenderTexture source, RenderTexture dest, PostProcessParameters postProcessParams, VirtualCamera virtualCamera)
        {
            if (postProcessParams.bloom == true)
            {
                PrepareBloomSampling(postProcessParams.bloomTexture, postProcessParams.glareParams);
            }
            if (postProcessParams.lensDirt == true)
            {
                PrepareLensDirtSampling(postProcessParams.lensDirtTexture, postProcessParams.lensDirtParams, postProcessParams.glareParams);
            }
            if (postProcessParams.lensFlare == true)
            {
                PrepareLensFlareSampling(postProcessParams.lensFlareParams, postProcessParams.lensFlareTexture, postProcessParams.cameraTransform);
            }
            PrepareExposure(postProcessParams.cameraParams, virtualCamera);
            PrepareColorGrading(postProcessParams.colorGradingParams);
            UploadVariables(postProcessParams);

            //The reasoning behind the passIndex stuff is keyword avoidance
            int passIndex = 0;

            if (postProcessParams.tonemapping == false)
            {
                passIndex += 4;
            }
            if (postProcessParams.bloom == false)
            {
                passIndex += 2;
            }
            if (postProcessParams.lensDirt == false || postProcessParams.lensDirtTexture == null)
            {
                passIndex += 1;
            }

            source.filterMode = FilterMode.Bilinear;
            source.wrapMode   = TextureWrapMode.Clamp;
            Graphics.Blit(source, dest, m_combinationMat, passIndex);

            //Graphics.Blit(postProcessParams.blurTexture, dest);
            //Graphics.Blit(postProcessParams.halfResSource, dest);
            //Graphics.Blit(source, dest);
        }
Пример #7
0
 private void PrepareExposure(CameraParameters cameraParams, VirtualCamera virtualCamera)
 {
     if (cameraParams.cameraMode == CameraMode.Off)
     {
         m_combinationMat.SetFloat("_ManualExposure", 1.0f);
     }
     else if (cameraParams.cameraMode != CameraMode.Manual)
     {
         virtualCamera.BindVirtualCameraTextures(m_combinationMat);
     }
     else
     {
         m_combinationMat.SetFloat("_ManualExposure", virtualCamera.CalculateManualExposure(cameraParams));
     }
 }
Пример #8
0
		public RenderTexture RenderDepthOfField(PostProcessParameters postProcessParams, RenderTexture source, RenderTexture downsampledClrDepth, 
		                                        VirtualCamera virtualCamera, RenderTexture exclusionMask)
		{
			if (ShaderSettings.ExposureSettings.IsActive("SC_EXPOSURE_AUTO") == true)
			{
				virtualCamera.BindVirtualCameraTextures(m_DoFMat);
			}

			virtualCamera.BindVirtualCameraParams(m_DoFMat, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, postProcessParams.halfWidth, postProcessParams.isFirstRender);	

			RenderTexture depthCenterAverage = null;
			if (postProcessParams.DoFParams.depthFocusMode == DepthFocusMode.PointAverage)
			{
				depthCenterAverage = PrepatePointAverage(postProcessParams, downsampledClrDepth);
				//ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(depthCenterAverage, false, false, false);
			}	

			RenderTexture tiledData = CreateTiledData(downsampledClrDepth, 
			                                          postProcessParams.preCalcValues.tanHalfFoV,
			                                          postProcessParams.cameraParams.fNumber,
			                                          postProcessParams.DoFParams.focalDistance,
			                                          postProcessParams.DoFParams.focalRange,
			                                          postProcessParams.cameraParams.apertureDiameter,
			                                          postProcessParams.cameraParams.focalLength,
			                                          postProcessParams.DoFParams.maxCoCRadius,
			                                          postProcessParams.cameraParams.nearPlane,
			                                          postProcessParams.cameraParams.farPlane);
			
			//ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(exclusionMask, false, false, false);

			RenderTexture neighbourhoodData 	= TileNeighbourhoodDataGathering(tiledData);
			RenderTexture prefilteredSource 	= PrefilterSource(downsampledClrDepth);		
			RenderTexture.ReleaseTemporary(downsampledClrDepth);
			
			RenderTexture presortTexture		= Presort(prefilteredSource, neighbourhoodData);

			if (postProcessParams.DoFParams.useTemporal == true) UploadTemporalReprojectionVariables(postProcessParams);

			RenderTexture tapsTexture;
			RenderTexture alphaTexture;
			BlurTapPass(prefilteredSource, tiledData, neighbourhoodData, exclusionMask, depthCenterAverage, presortTexture,
			            postProcessParams.DoFParams.quality, out tapsTexture, out alphaTexture);

			const bool temporalAlpha = false;
			
			//Only do temporal super sampling in editor if its playing
			#if UNITY_EDITOR
				if (UnityEditor.EditorApplication.isPlaying == true && 
				    postProcessParams.DoFParams.useTemporal == true && 
				    previousTapsTexture != null) 
				{
					if (temporalAlpha == true) TemporalPass(ref tapsTexture, ref alphaTexture, previousTapsTexture, previousAlphaTexture);
					else TemporalPass(ref tapsTexture, previousTapsTexture);
				}
			#else
			if (postProcessParams.DoFParams.useTemporal == true && previousTapsTexture != null) 
			{
				if (temporalAlpha == true) TemporalPass(ref tapsTexture, ref alphaTexture, previousTapsTexture, previousAlphaTexture);
				else TemporalPass(ref tapsTexture, previousTapsTexture);
			}
			#endif

			//alphaTexture = BilateralAlphaFilter(alphaTexture, tapsTexture);
			//alphaTexture = MedianFilterPass(alphaTexture);
			
			if (postProcessParams.DoFParams.useMedianFilter == true) tapsTexture = MedianFilterPass(tapsTexture);
			
			if (postProcessParams.DoFParams.visualizeFocalDistance == true) VisualizeFocalDistance(tapsTexture);
			
			//ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(presort, true, false, false);
			//ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(alphaTexture, false, false, false);
			//ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(previousTapsTexture, false, false, false);

			RenderTexture compositedDoF = UpsampleDepthOfField(source, tapsTexture, alphaTexture, neighbourhoodData, exclusionMask);
			RenderTexture.ReleaseTemporary(tiledData);
			RenderTexture.ReleaseTemporary(neighbourhoodData);
			RenderTexture.ReleaseTemporary(prefilteredSource);
			RenderTexture.ReleaseTemporary(presortTexture);

			if (copiedDepthBuffer != null) 		{ RenderTexture.ReleaseTemporary(copiedDepthBuffer); copiedDepthBuffer = null; }			
			if (previousTapsTexture != null) 	{ RenderTexture.ReleaseTemporary(previousTapsTexture); previousTapsTexture = null; }
			if (previousAlphaTexture != null) 	{ RenderTexture.ReleaseTemporary(previousAlphaTexture); previousAlphaTexture = null; }

			if (postProcessParams.DoFParams.useTemporal == true) 
			{
				previousTapsTexture = tapsTexture;
				previousAlphaTexture = alphaTexture;
			}
			else 
			{
				RenderTexture.ReleaseTemporary(tapsTexture);
				RenderTexture.ReleaseTemporary(alphaTexture);
			}

			return compositedDoF;
		}
Пример #9
0
 private void OnEnable()
 {
     this.m_camera = base.GetComponent<Camera>();
     this.m_bloomClass = new Bloom();
     this.m_combinationPass = new CombinationPass();
     this.m_downsampling = new Downsampling();
     this.m_virtualCamera = new VirtualCamera();
     this.m_depthOfFieldClass = new DepthOfField();
     this.m_scionDebug = new ScionDebug();
     this.m_colorGrading = new ColorGrading();
     this.m_isFirstRender = true;
     this.postProcessParams.Fill(this);
     if (!this.PlatformCompatibility())
     {
         base.enabled = false;
     }
 }
Пример #10
0
        public RenderTexture RenderDepthOfField(PostProcessParameters postProcessParams, RenderTexture source, RenderTexture downsampledClrDepth,
                                                VirtualCamera virtualCamera, RenderTexture exclusionMask)
        {
            if (ShaderSettings.ExposureSettings.IsActive("SC_EXPOSURE_AUTO") == true)
            {
                virtualCamera.BindVirtualCameraTextures(m_DoFMat);
            }

            virtualCamera.BindVirtualCameraParams(m_DoFMat, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, postProcessParams.halfWidth, postProcessParams.isFirstRender);

            RenderTexture depthCenterAverage = null;

            if (postProcessParams.DoFParams.depthFocusMode == DepthFocusMode.PointAverage)
            {
                depthCenterAverage = PrepatePointAverage(postProcessParams, downsampledClrDepth);
                //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(depthCenterAverage, false, false, false);
            }

            RenderTexture tiledData = CreateTiledData(downsampledClrDepth,
                                                      postProcessParams.preCalcValues.tanHalfFoV,
                                                      postProcessParams.cameraParams.fNumber,
                                                      postProcessParams.DoFParams.focalDistance,
                                                      postProcessParams.DoFParams.focalRange,
                                                      postProcessParams.cameraParams.apertureDiameter,
                                                      postProcessParams.cameraParams.focalLength,
                                                      postProcessParams.DoFParams.maxCoCRadius,
                                                      postProcessParams.cameraParams.nearPlane,
                                                      postProcessParams.cameraParams.farPlane);

            //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(exclusionMask, false, false, false);

            RenderTexture neighbourhoodData = TileNeighbourhoodDataGathering(tiledData);
            RenderTexture prefilteredSource = PrefilterSource(downsampledClrDepth);

            RenderTexture.ReleaseTemporary(downsampledClrDepth);

            RenderTexture presortTexture = Presort(prefilteredSource, neighbourhoodData);

            if (postProcessParams.DoFParams.useTemporal == true)
            {
                UploadTemporalReprojectionVariables(postProcessParams);
            }

            RenderTexture tapsTexture;
            RenderTexture alphaTexture;

            BlurTapPass(prefilteredSource, tiledData, neighbourhoodData, exclusionMask, depthCenterAverage, presortTexture,
                        postProcessParams.DoFParams.quality, out tapsTexture, out alphaTexture);

            const bool temporalAlpha = false;

            //Only do temporal super sampling in editor if its playing
                        #if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying == true &&
                postProcessParams.DoFParams.useTemporal == true &&
                previousTapsTexture != null)
            {
                if (temporalAlpha == true)
                {
                    TemporalPass(ref tapsTexture, ref alphaTexture, previousTapsTexture, previousAlphaTexture);
                }
                else
                {
                    TemporalPass(ref tapsTexture, previousTapsTexture);
                }
            }
                        #else
            if (postProcessParams.DoFParams.useTemporal == true && previousTapsTexture != null)
            {
                if (temporalAlpha == true)
                {
                    TemporalPass(ref tapsTexture, ref alphaTexture, previousTapsTexture, previousAlphaTexture);
                }
                else
                {
                    TemporalPass(ref tapsTexture, previousTapsTexture);
                }
            }
                        #endif

            //alphaTexture = BilateralAlphaFilter(alphaTexture, tapsTexture);
            //alphaTexture = MedianFilterPass(alphaTexture);

            if (postProcessParams.DoFParams.useMedianFilter == true)
            {
                tapsTexture = MedianFilterPass(tapsTexture);
            }

            if (postProcessParams.DoFParams.visualizeFocalDistance == true)
            {
                VisualizeFocalDistance(tapsTexture);
            }

            //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(presort, true, false, false);
            //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(alphaTexture, false, false, false);
            //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(previousTapsTexture, false, false, false);

            RenderTexture compositedDoF = UpsampleDepthOfField(source, tapsTexture, alphaTexture, neighbourhoodData, exclusionMask);
            RenderTexture.ReleaseTemporary(tiledData);
            RenderTexture.ReleaseTemporary(neighbourhoodData);
            RenderTexture.ReleaseTemporary(prefilteredSource);
            RenderTexture.ReleaseTemporary(presortTexture);

            if (copiedDepthBuffer != null)
            {
                RenderTexture.ReleaseTemporary(copiedDepthBuffer); copiedDepthBuffer = null;
            }
            if (previousTapsTexture != null)
            {
                RenderTexture.ReleaseTemporary(previousTapsTexture); previousTapsTexture = null;
            }
            if (previousAlphaTexture != null)
            {
                RenderTexture.ReleaseTemporary(previousAlphaTexture); previousAlphaTexture = null;
            }

            if (postProcessParams.DoFParams.useTemporal == true)
            {
                previousTapsTexture  = tapsTexture;
                previousAlphaTexture = alphaTexture;
            }
            else
            {
                RenderTexture.ReleaseTemporary(tapsTexture);
                RenderTexture.ReleaseTemporary(alphaTexture);
            }

            return(compositedDoF);
        }
Пример #11
0
        public RenderTexture RenderDepthOfField(PostProcessParameters postProcessParams, RenderTexture source, RenderTexture dest, VirtualCamera virtualCamera)
        {
            this.CreateDX11Mat();
            virtualCamera.BindVirtualCameraTextures(this.m_DoFMat);
            if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
            {
                virtualCamera.BindVirtualCameraTextures(this.m_DoFMatDX11);
            }
            virtualCamera.BindVirtualCameraParams(this.m_DoFMat, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, (float)postProcessParams.halfWidth, postProcessParams.isFirstRender);
            if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
            {
                virtualCamera.BindVirtualCameraParams(this.m_DoFMatDX11, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, (float)postProcessParams.halfWidth, postProcessParams.isFirstRender);
            }
            RenderTexture depthCenterAverage = null;

            if (postProcessParams.DoFParams.depthFocusMode == DepthFocusMode.PointAverage)
            {
                depthCenterAverage = this.PrepatePointAverage(postProcessParams, dest);
            }
            RenderTexture renderTexture  = this.CreateTiledData(postProcessParams.halfResDepth, postProcessParams.preCalcValues.tanHalfFoV, postProcessParams.cameraParams.fNumber, postProcessParams.DoFParams.focalDistance, postProcessParams.DoFParams.focalRange, postProcessParams.cameraParams.apertureDiameter, postProcessParams.cameraParams.focalLength, postProcessParams.DoFParams.maxCoCRadius, postProcessParams.cameraParams.nearPlane, postProcessParams.cameraParams.farPlane);
            RenderTexture renderTexture2 = this.TileNeighbourhoodDataGathering(renderTexture);
            RenderTexture renderTexture3 = this.PrefilterSource(postProcessParams.halfResSource);
            RenderTexture renderTexture4 = this.BlurTapPass(renderTexture3, renderTexture, renderTexture2, depthCenterAverage, postProcessParams.DoFParams.quality);

            if (postProcessParams.DoFParams.useMedianFilter)
            {
                renderTexture4 = this.MedianFilterPass(renderTexture4);
            }
            RenderTexture result = this.UpsampleDepthOfField(source, renderTexture4, renderTexture2);

            RenderTexture.ReleaseTemporary(renderTexture);
            RenderTexture.ReleaseTemporary(renderTexture2);
            RenderTexture.ReleaseTemporary(renderTexture3);
            RenderTexture.ReleaseTemporary(renderTexture4);
            return(result);
        }
Пример #12
0
        public void Combine(RenderTexture source, RenderTexture dest, PostProcessParameters postProcessParams, VirtualCamera virtualCamera)
        {
            if (postProcessParams.bloom)
            {
                this.PrepareBloomSampling(postProcessParams.bloomTexture, postProcessParams.bloomParams);
            }
            if (postProcessParams.lensDirt)
            {
                this.PrepareLensDirtSampling(postProcessParams.lensDirtTexture, postProcessParams.lensDirtParams);
            }
            this.PrepareExposure(postProcessParams.cameraParams, virtualCamera);
            this.PrepareColorGrading(postProcessParams.colorGradingParams);
            this.UploadVariables(postProcessParams.commonPostProcess);
            int num = 0;

            if (!postProcessParams.tonemapping)
            {
                num += 3;
            }
            if (!postProcessParams.bloom)
            {
                num += 2;
            }
            else if (!postProcessParams.lensDirt)
            {
                num++;
            }
            source.filterMode = FilterMode.Bilinear;
            source.wrapMode   = TextureWrapMode.Clamp;
            Graphics.Blit(source, dest, this.m_combinationMat, num);
        }
Пример #13
0
        public RenderTexture RenderDepthOfField(PostProcessParameters postProcessParams, RenderTexture source, VirtualCamera virtualCamera, RenderTexture exclusionMask)
        {
            CreateDX11Mat();

            if (ShaderSettings.ExposureSettings.IsActive("SC_EXPOSURE_AUTO") == true)
            {
                virtualCamera.BindVirtualCameraTextures(m_DoFMat);
                if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
                {
                    virtualCamera.BindVirtualCameraTextures(m_DoFMatDX11);
                }
            }

            virtualCamera.BindVirtualCameraParams(m_DoFMat, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, postProcessParams.halfWidth, postProcessParams.isFirstRender);
            if (postProcessParams.DoFParams.quality == DepthOfFieldQuality.High_DX11)
            {
                virtualCamera.BindVirtualCameraParams(m_DoFMatDX11, postProcessParams.cameraParams, postProcessParams.DoFParams.focalDistance, postProcessParams.halfWidth, postProcessParams.isFirstRender);
            }

            RenderTexture depthCenterAverage = null;

            if (postProcessParams.DoFParams.depthFocusMode == DepthFocusMode.PointAverage)
            {
                depthCenterAverage = PrepatePointAverage(postProcessParams);
                //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(depthCenterAverage, false, false, false);
            }

            RenderTexture tiledData = CreateTiledData(postProcessParams.halfResDepth,
                                                      postProcessParams.preCalcValues.tanHalfFoV,
                                                      postProcessParams.cameraParams.fNumber,
                                                      postProcessParams.DoFParams.focalDistance,
                                                      postProcessParams.DoFParams.focalRange,
                                                      postProcessParams.cameraParams.apertureDiameter,
                                                      postProcessParams.cameraParams.focalLength,
                                                      postProcessParams.DoFParams.maxCoCRadius,
                                                      postProcessParams.cameraParams.nearPlane,
                                                      postProcessParams.cameraParams.farPlane);

            //ScionPostProcess.ActiveDebug.RegisterTextureForVisualization(exclusionMask, false, false, false);
            RenderTexture neighbourhoodData   = TileNeighbourhoodDataGathering(tiledData);
            RenderTexture prefilteredSource   = PrefilterSource(postProcessParams.halfResSource);
            RenderTexture depthOfFieldTexture = BlurTapPass(prefilteredSource, tiledData, neighbourhoodData, exclusionMask, depthCenterAverage, postProcessParams.DoFParams.quality);

            if (postProcessParams.DoFParams.useMedianFilter == true)
            {
                depthOfFieldTexture = MedianFilterPass(depthOfFieldTexture);
            }

            RenderTexture compositedDoF = UpsampleDepthOfField(source, depthOfFieldTexture, neighbourhoodData, exclusionMask);

            RenderTexture.ReleaseTemporary(tiledData);
            RenderTexture.ReleaseTemporary(neighbourhoodData);
            RenderTexture.ReleaseTemporary(prefilteredSource);
            RenderTexture.ReleaseTemporary(depthOfFieldTexture);

            return(compositedDoF);
        }
Пример #14
0
        protected void OnEnable()
        {
            m_camera 				= GetComponent<Camera>();
            m_cameraTransform		= camera.transform;
            m_bloomClass			= new Bloom();
            m_lensFlareClass		= new ScionLensFlare();
            m_combinationPass 		= new CombinationPass();
            m_downsampling			= new Downsampling();
            m_virtualCamera 		= new VirtualCamera();
            m_depthOfFieldClass		= new DepthOfField();
            m_scionDebug			= new ScionDebug();
            m_isFirstRender			= true;

            if (PlatformCompatibility() == false) this.enabled = false;

            #if UNITY_EDITOR
            UnityEditor.Undo.undoRedoPerformed -= OnUndoCallback;
            UnityEditor.Undo.undoRedoPerformed += OnUndoCallback;
            #endif
        }
Пример #15
0
        public void Combine(RenderTexture source, RenderTexture dest, PostProcessParameters postProcessParams, VirtualCamera virtualCamera)
        {
            if (postProcessParams.bloom == true)
            {
                PrepareBloomSampling(postProcessParams.bloomTexture, postProcessParams.bloomParams);
            }
            if (postProcessParams.lensDirt == true)
            {
                PrepareLensDirtSampling(postProcessParams.lensDirtTexture, postProcessParams.lensDirtParams);
            }
            PrepareExposure(postProcessParams.cameraParams, virtualCamera);
            PrepareColorGrading(postProcessParams.colorGradingParams);
            UploadVariables(postProcessParams.commonPostProcess);

            int passIndex = 0;

            if (postProcessParams.tonemapping == false)
            {
                passIndex += 3;
            }
            if (postProcessParams.bloom == false)
            {
                passIndex += 2;
            }
            else if (postProcessParams.lensDirt == false)
            {
                passIndex += 1;
            }

            source.filterMode = FilterMode.Bilinear;
            source.wrapMode   = TextureWrapMode.Clamp;
            Graphics.Blit(source, dest, m_combinationMat, passIndex);

            //Graphics.Blit(postProcessParams.blurTexture, dest);
            //Graphics.Blit(postProcessParams.halfResSource, dest);
            //Graphics.Blit(source, dest);
        }