private void OnEnable() { this.MyCamera = base.gameObject.GetComponent <Camera>(); this.frostEffect = base.GetComponent <Frost>(); this.ScionStuff = base.GetComponent <ScionPostProcess>(); this.bleedEffect = base.GetComponent <BleedBehavior>(); this.aa_FXAA = base.GetComponent <FXAA>(); this.aa_SMAA = base.GetComponent <SMAA>(); this.amplifyMotion = base.GetComponent <AmplifyMotionEffect>(); this.sessao = base.GetComponent <SESSAO>(); this.hbao = base.GetComponent <HBAO>(); this.waterViz = base.gameObject.GetComponent <WaterViz>(); this.waterBlur = base.gameObject.GetComponent <WaterBlurEffect>(); this.waterBlurCeto = base.gameObject.GetComponent <UnderWaterPostEffect>(); this.farShadowCascade = base.gameObject.GetComponent <FarShadowCascade>(); if (Sunshine.Instance) { this.SunshineOccluders = Sunshine.Instance.Occluders; } this.reflexionMode_complex = LayerMask.GetMask(new string[] { "Camera", "Ignore Raycast" }); this.reflexionMode_simple = LayerMask.GetMask(new string[] { "Camera" }); this.reflexionMode_off = 0; }
private void ReleaseSMAA() { if (smaa != null) { smaa.Destroy(); smaa = null; } }
private SMAA GetSMAA() { if (smaa == null) { smaa = new SMAA(); } return(smaa); }
private void LoadContent() { Bloom bloom = new Bloom(PostProcessor, Content); bloom.Radius = 1.5f; PostProcessor.Effects.Add(bloom); _fxaaPPE = new FXAA(PostProcessor, Content); PostProcessor.Effects.Add(_fxaaPPE); //Negative negative = new Negative(PostProcessor, Content); //PostProcessor.Effects.Add(negative); _smaaPPE = new SMAA(PostProcessor, Content); PostProcessor.Effects.Add(_smaaPPE); }
public SnapshotContext(Device device, Matrix view, Rect rect, double sampleRatio) { var viewPort = device.Viewport; var halfWidth = viewPort.Width / 2; var halfHeight = viewPort.Height / 2; var centerX = (float)(2 * (rect.Left + rect.Width / 2)) / (float)viewPort.Width - 1.0f; var centerY = (float)(2 * (rect.Top + rect.Height / 2)) / (float)viewPort.Height - 1.0f; this.Width = (int)(rect.Width * sampleRatio); this.Height = (int)(rect.Height * sampleRatio); this.LogInfo("hangar scene shot to picture ({0},{1}) ", this.Width, this.Height); var scale = Math.Min((float)viewPort.Height / (float)rect.Height, (float)viewPort.Width / (float)rect.Width); var proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)this.Width / (float)this.Height, 0.1f, 707.0f) * Matrix.Translation(-centerX, centerY, 0) * Matrix.Scaling(scale, scale, 1f); this.ViewProjection = Matrix.Multiply(view, proj); _normalMap = new Texture(device, this.Width, this.Height, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default); _positionMap = new Texture(device, this.Width, this.Height, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default); _colorMap = new Texture(device, this.Width, this.Height, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default); _finalColorMap = new Texture(device, this.Width, this.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); _dstMap = new Texture(device, this.Width, this.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); _normalSurface = _normalMap.GetSurfaceLevel(0); _positionSurface = _positionMap.GetSurfaceLevel(0); _colorSurface = _colorMap.GetSurfaceLevel(0); _finalColorSurface = _finalColorMap.GetSurfaceLevel(0); _dstSurface = _dstMap.GetSurfaceLevel(0); _quadRender = new QuadRender(device, this.Width, this.Height); _shootMap = new Texture(device, this.Width, this.Height, 1, Usage.None, Format.A8R8G8B8, Pool.SystemMemory); _shootMapSurface = _shootMap.GetSurfaceLevel(0); _depthStencil = Surface.CreateDepthStencil(device, this.Width, this.Height, Format.D24S8, MultisampleType.None, 0, true); device.DepthStencilSurface = _depthStencil; _smaa = new SMAA(device, 1, 1, SMAA.Preset.PRESET_ULTRA); _smaa.Reset(this.Width, this.Height, _quadRender); }
static void Postfix( CameraController __instance, // note: don't use `ref` for disabled objects TiltShiftEffect ___m_TiltShift, DepthOfField ___m_DepthOfField, FilmGrainEffect ___m_FilmGrain, SMAA ___m_SMAA, Camera ___m_camera, float ___m_DefaultMaxBlurSize ) { if (!Singleton <LoadingManager> .instance.m_loadingComplete) { return; } if (!InfoManager.instance || InfoManager.instance.CurrentMode != InfoManager.InfoMode.None) { return; } var cc = ToolsModifierControl.cameraController; if (cc == null) { return; } var light = App.Instance.MainLight; if (!light) { return; } float cameraTime = Mathf.Clamp((__instance.m_currentSize - __instance.m_minDistance) / __instance.m_MaxTiltShiftDistance, 0f, 1f); bool hasToolbar = true, alwaysFullRect = false; lock (App.Config.UILock) { hasToolbar = App.Config.UI.masterToolbarVisibility; alwaysFullRect = App.Config.UI.alwaysFullRect; } if (!alwaysFullRect && hasToolbar) { ___m_camera.rect = new Rect(0f, 0.105f, 1f, 0.895f); //Log.Debug($"has toolbar"); } else { // Vanilla & some external mod's "free camera" thingy ___m_camera.rect = new Rect(0f, 0f, 1f, 1f); //___m_camera.pixelRect = new Rect(0, 0, 2560, 1440); // Log.Debug($"no toolbar: {__instance.__instance.m_currentSize} {___m_camera.orthographic} {___m_camera.orthographicSize}"); } lock (App.Config.GraphicsLock) { var gr = App.Config.Graphics; light.shadows = LightShadows.Soft; if (gr.shadowStrength) { light.shadowStrength = gr.shadowStrength.Value; } if (gr.lightIntensity) { light.intensity = gr.lightIntensity.Value; } // NB: revert values set from external mods if (gr.dofEnabled || gr.tiltShiftEnabled) { ResetCameraDefaults(ref __instance); } if (___m_DepthOfField != null) { //___m_DepthOfField.enabled = gr.dofEnabled; // TODO ___m_DepthOfField.blurSampleCount = DepthOfField.BlurSampleCount.High; ___m_DepthOfField.highResolution = true; ___m_DepthOfField.visualizeFocus = gr.dofDebug; // near ___m_DepthOfField.nearBlur = gr.dofNearBlur; ___m_DepthOfField.foregroundOverlap = gr.dofFGOverlap; // focus to target object ___m_DepthOfField.focalTransform = null; ___m_DepthOfField.focalLength = (__instance.m_currentSize + __instance.m_FocalLength.Evaluate(cameraTime)) * gr.dofFocalDistance; ___m_DepthOfField.focalSize = __instance.m_FocalSize.Evaluate(cameraTime) * gr.dofFocalRange; ___m_DepthOfField.aperture = __instance.m_Aperture.Evaluate(cameraTime) * gr.dofAperture; ___m_DepthOfField.maxBlurSize = __instance.m_MaxBlurSize.Evaluate(cameraTime) * gr.dofMaxBlurSize; if (___m_DepthOfField.Dx11Support()) { ___m_DepthOfField.blurType = DepthOfField.BlurType.DX11; ___m_DepthOfField.dx11BokehScale = gr.dofBokehScale; ___m_DepthOfField.dx11BokehIntensity = gr.dofBokehIntensity; ___m_DepthOfField.dx11BokehThreshold = gr.dofBokehMinLuminanceThreshold; ___m_DepthOfField.dx11SpawnHeuristic = gr.dofBokehSpawnHeuristic; } else { ___m_DepthOfField.blurType = DepthOfField.BlurType.DiscBlur; } } if (___m_TiltShift != null) { //___m_TiltShift.enabled = true; ___m_TiltShift.m_Mode = gr.tiltShiftMode; ___m_TiltShift.m_MaxBlurSize = ___m_DefaultMaxBlurSize /* default 5? */ * gr.tiltShiftMaxBlurSize; ___m_TiltShift.m_BlurArea = Mathf.Lerp(__instance.m_MaxTiltShiftArea, __instance.m_MinTiltShiftArea, cameraTime) * gr.tiltShiftAreaSize; } if (___m_FilmGrain != null) { //___m_FilmGrain.enabled = true; ___m_FilmGrain.m_Scale = gr.filmGrainScale; ___m_FilmGrain.m_AmountScalar = gr.filmGrainAmountScalar; ___m_FilmGrain.m_Amount = gr.filmGrainAmountFactor; ___m_FilmGrain.m_MiddleRange = gr.filmGrainMiddleRange; } if (___m_SMAA != null) { // no "disabled" getter, so overwrite it here ___m_SMAA.enabled = gr.smaaEnabled; // only 1 pass is implemented? //___m_SMAA.Passes = gr.smaaPasses; ___m_SMAA.Passes = 1; } } }
private void UpdatePostProcess() { foreach (Camera cam in Camera.allCameras) { SMAA defAntiAlias = cam.GetComponent <SMAA>(); Bloom b = cam.GetComponent <Bloom>(); BloomAndFlares baf = cam.GetComponent <BloomAndFlares>(); ContrastEnhance ce = cam.GetComponent <ContrastEnhance>(); MotionBlur mb = cam.GetComponent <MotionBlur>(); WeaponDepthOfField wdof = cam.GetComponent <WeaponDepthOfField>(); SunShafts ss = cam.GetComponent <SunShafts>(); AmplifyOcclusionEffect ao = cam.GetComponent <AmplifyOcclusionEffect>(); ColorCorrection ccc = cam.GetComponent <ColorCorrection>(); if (defAntiAlias) { defAntiAlias.enabled = (antiAliasing == 1); } if (wdof) { wdof.enabled = (wDepthOfField == 1); } bool bloomBool = (bloom == 1); if (baf) { baf.enabled = bloomBool; } if (b) { b.enabled = bloomBool; } if (ss) { ss.enabled = (sunShafts == 1); } if (mb) { mb.enabled = (motionBlur == 1); } bool ssaoBool = (SSAO == 1); if (ao) { ao.enabled = ssaoBool; } bool ccBool = (colorCorrection == 1); if (ccc) { ccc.enabled = ccBool; } if (ce) { ce.enabled = ccBool; } } lastPP = Time.unscaledTime; cameraCount = Camera.allCameras.Length; }