// TODO: Add API docs public static void ConfigureFilmGrain(PostProcessData data, FilmGrain settings, int cameraPixelWidth, int cameraPixelHeight, Material material) { var texture = settings.texture.value; if (settings.type.value != FilmGrainLookup.Custom) { texture = data.textures.filmGrainTex[(int)settings.type.value]; } #if LWRP_DEBUG_STATIC_POSTFX float offsetX = 0f; float offsetY = 0f; #else float offsetX = Random.value; float offsetY = Random.value; #endif var tilingParams = texture == null ? Vector4.zero : new Vector4(cameraPixelWidth / (float)texture.width, cameraPixelHeight / (float)texture.height, offsetX, offsetY); material.SetTexture(ShaderConstants._Grain_Texture, texture); material.SetVector(ShaderConstants._Grain_Params, new Vector2(settings.intensity.value * 4f, settings.response.value)); material.SetVector(ShaderConstants._Grain_TilingParams, tilingParams); }
protected override void Awake() { if (!postProcessingProfile.TryGet <FilmGrain>(out fg)) //Try to get the setting override { fg = postProcessingProfile.Add <FilmGrain>(true); //Create one if it can't be found } base.Awake(); }
// Start is called before the first frame update void Awake() { _volume = FindObjectOfType <Volume>(); _chromatic = (ChromaticAberration)_volume.profile.components.Find(x => x.name == "ChromaticAberration(Clone)"); _colorAdjustments = (ColorAdjustments)_volume.profile.components.Find(x => x.name == "ColorAdjustments(Clone)"); _grain = (FilmGrain)_volume.profile.components.Find(x => x.name == "FilmGrain(Clone)"); shakeList = new List <float>(); Debug.Log("Set CamEffect"); instance = this; _cam = GetComponent <CinemachineVirtualCamera>(); _noise = _cam.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>(); }
protected override void Start() { if (_playerLight) { _playerLight.intensity = (100 - GetInsanityPercentage()); } if (HealthBar != null) { HealthBar.SetMaxValue(MaxHealth); } CurrentHealth = 0; GlobalState.state.AudioManager.PlayerInsanityAudio(0); GlobalState.state.AudioManager.PlayerInsanityAudioUpdate(0); if (vol != null) { ChromaticAberration chroTmp; Vignette vigTmp; FilmGrain filTmp; if (vol.profile.TryGet <ChromaticAberration>(out chroTmp)) { _chromaticAberration = chroTmp; } if (vol.profile.TryGet <Vignette>(out vigTmp)) { _vignette = vigTmp; } if (vol.profile.TryGet <FilmGrain>(out filTmp)) { _filmGrain = filTmp; } } if (!HealthBar) { //throw new System.Exception("Healthbar prefab missing!"); } }
public static void ConfigureFilmGrain(PostProcessData data, FilmGrain settings, Camera camera, Material material) { ConfigureFilmGrain(data, settings, camera.pixelWidth, camera.pixelHeight, material); }
IEnumerator Transition(Vector3 startPos, Vector3 finalPos, Camera startCam, Camera endCam, VolumeProfile startProfile, VolumeProfile endProfile, Players endPlayer) { transitionVolume.enabled = true; // Switch to more efficient method later Bloom[] bloom = new Bloom[3]; ChromaticAberration[] chromaticAberration = new ChromaticAberration[3]; LensDistortion[] lensDistortion = new LensDistortion[3]; FilmGrain[] filmGrain = new FilmGrain[3]; ShadowsMidtonesHighlights[] shadowsMidtonesHighlights = new ShadowsMidtonesHighlights[3]; PaniniProjection[] paniniProjection = new PaniniProjection[3]; WhiteBalance[] whiteBalance = new WhiteBalance[3]; DepthOfField[] depthOfField = new DepthOfField[3]; Vignette[] vignette = new Vignette[3]; transitionVolume.profile.components.Clear(); foreach (VolumeComponent c in transitionStartProfile.components.AsReadOnly()) { transitionVolume.profile.components.Add(c); } transitionVolume.profile.TryGet(out bloom[0]); transitionVolume.profile.TryGet(out chromaticAberration[0]); transitionVolume.profile.TryGet(out lensDistortion[0]); transitionVolume.profile.TryGet(out filmGrain[0]); transitionVolume.profile.TryGet(out shadowsMidtonesHighlights[0]); transitionVolume.profile.TryGet(out paniniProjection[0]); transitionVolume.profile.TryGet(out whiteBalance[0]); transitionVolume.profile.TryGet(out depthOfField[0]); transitionVolume.profile.TryGet(out vignette[0]); startProfile.TryGet(out bloom[1]); startProfile.TryGet(out chromaticAberration[1]); startProfile.TryGet(out lensDistortion[1]); startProfile.TryGet(out filmGrain[1]); startProfile.TryGet(out shadowsMidtonesHighlights[1]); startProfile.TryGet(out paniniProjection[1]); startProfile.TryGet(out whiteBalance[1]); startProfile.TryGet(out depthOfField[1]); startProfile.TryGet(out vignette[1]); endProfile.TryGet(out bloom[2]); endProfile.TryGet(out chromaticAberration[2]); endProfile.TryGet(out lensDistortion[2]); endProfile.TryGet(out filmGrain[2]); endProfile.TryGet(out shadowsMidtonesHighlights[2]); endProfile.TryGet(out paniniProjection[2]); endProfile.TryGet(out whiteBalance[2]); endProfile.TryGet(out depthOfField[2]); endProfile.TryGet(out vignette[2]); for (float i = 0; i < Mathf.PI; i += weightTransferIncrement) { float weight = Mathf.Cos(i + Mathf.PI) / 2 + 0.5f; transitionVolume.weight = Blend(0, 1, weight); yield return(new WaitForEndOfFrame()); } for (float i = 0; i < Mathf.PI; i += increment) { float weight = Mathf.Cos(i + Mathf.PI) / 2 + 0.5f; transitionTransform.position = new Vector3(Blend(startPos.x, finalPos.x, weight), Blend(startPos.y, finalPos.y, weight), Blend(startPos.z, finalPos.z, weight)); transitionCamera.transform.rotation = Quaternion.Lerp(startCam.transform.rotation, endCam.transform.rotation, i / Mathf.PI); transitionCamera.fieldOfView = Blend(startCam.fieldOfView, endCam.fieldOfView, weight); // Bloom bloom[0].threshold.value = Blend(bloom[1].threshold.value, bloom[2].threshold.value, weight); bloom[0].intensity.value = Blend(bloom[1].intensity.value, bloom[2].intensity.value, weight); bloom[0].tint.value = Color.Lerp(bloom[1].tint.value, bloom[2].tint.value, weight / Mathf.PI); // Chromatic Aberration chromaticAberration[0].intensity.value = Blend(chromaticAberration[1].intensity.value, chromaticAberration[2].intensity.value, weight); // Lens Distortion lensDistortion[0].intensity.value = Blend(lensDistortion[1].intensity.value, lensDistortion[2].intensity.value, weight); // Film Grain filmGrain[0].intensity.value = Blend(filmGrain[1].intensity.value, filmGrain[2].intensity.value, weight); filmGrain[0].response.value = Blend(filmGrain[1].response.value, filmGrain[2].response.value, weight); // Shadows Midtones and Highlights shadowsMidtonesHighlights[0].shadows.value = Vector4.Lerp(shadowsMidtonesHighlights[1].shadows.value, shadowsMidtonesHighlights[2].shadows.value, weight / Mathf.PI); shadowsMidtonesHighlights[0].midtones.value = Vector4.Lerp(shadowsMidtonesHighlights[1].midtones.value, shadowsMidtonesHighlights[2].midtones.value, weight / Mathf.PI); shadowsMidtonesHighlights[0].highlights.value = Vector4.Lerp(shadowsMidtonesHighlights[1].highlights.value, shadowsMidtonesHighlights[2].highlights.value, weight / Mathf.PI); shadowsMidtonesHighlights[0].shadowsStart.value = Blend(shadowsMidtonesHighlights[1].shadowsStart.value, shadowsMidtonesHighlights[2].shadowsStart.value, weight); shadowsMidtonesHighlights[0].shadowsEnd.value = Blend(shadowsMidtonesHighlights[1].shadowsEnd.value, shadowsMidtonesHighlights[2].shadowsEnd.value, weight); // Panini Projection paniniProjection[0].distance.value = Blend(paniniProjection[1].distance.value, paniniProjection[2].distance.value, weight); paniniProjection[0].cropToFit.value = Blend(paniniProjection[1].cropToFit.value, paniniProjection[2].cropToFit.value, weight); // White Balance whiteBalance[0].temperature.value = Blend(whiteBalance[1].temperature.value, whiteBalance[2].temperature.value, weight); whiteBalance[0].tint.value = Blend(whiteBalance[1].tint.value, whiteBalance[2].tint.value, weight); // Depth of Field depthOfField[0].mode.value = depthOfField[2].mode.value; depthOfField[0].gaussianStart.value = Blend(depthOfField[1].gaussianStart.value, depthOfField[2].gaussianStart.value, weight); depthOfField[0].gaussianEnd.value = Blend(depthOfField[1].gaussianEnd.value, depthOfField[2].gaussianEnd.value, weight); depthOfField[0].focusDistance.value = Blend(depthOfField[1].focusDistance.value, depthOfField[2].focusDistance.value, weight); depthOfField[0].focalLength.value = Blend(depthOfField[1].focalLength.value, depthOfField[2].focalLength.value, weight); depthOfField[0].aperture.value = Blend(depthOfField[1].aperture.value, depthOfField[2].aperture.value, weight); depthOfField[0].bladeCount.value = (int)Blend(depthOfField[1].bladeCount.value, depthOfField[2].bladeCount.value, weight); depthOfField[0].bladeCurvature.value = Blend(depthOfField[1].bladeCurvature.value, depthOfField[2].bladeCurvature.value, weight); depthOfField[0].bladeRotation.value = Blend(depthOfField[1].bladeRotation.value, depthOfField[2].bladeRotation.value, weight); // Vignette vignette[0].color.value = Color.Lerp(vignette[1].color.value, vignette[2].color.value, Mathf.PI / weight); vignette[0].intensity.value = Blend(vignette[1].intensity.value, vignette[2].intensity.value, weight); vignette[0].smoothness.value = Blend(vignette[1].smoothness.value, vignette[2].smoothness.value, weight); yield return(new WaitForEndOfFrame()); } for (float i = 0; i < Mathf.PI; i += weightTransferIncrement) { float weight = Mathf.Cos(i + Mathf.PI) / 2 + 0.5f; transitionVolume.weight = Blend(1, 0, weight); yield return(new WaitForEndOfFrame()); } EndTransition(); yield break; }
public override void Initialise() { base.Initialise(); if (GraphicsDevice != null) { // Render Targets m_ShadowDepthTarget = new RenderTarget2D(GraphicsDevice, m_ShadowMapSize, m_ShadowMapSize, false, SurfaceFormat.HalfVector2, DepthFormat.Depth24); // Shadow multiplier value ShadowMult = 0.5f; // Custom light blending state m_LightAddBlendState = new BlendState() { AlphaSourceBlend = Blend.One, ColorSourceBlend = Blend.One, AlphaDestinationBlend = Blend.One, ColorDestinationBlend = Blend.One, }; // Create these post processors up front m_DepthOfFieldPostProcessor = new DepthOfField(GraphicsDevice); m_BloomPostProcessor = new Bloom(GraphicsDevice); m_FilmGrainProcessor = new FilmGrain(GraphicsDevice); } //create render queues for (int index = 0; index < (int)ERenderQueue.Count; index++) { m_VisibleMeshes[index] = new List<AbstractMesh>(); m_VisibleShadowedMeshes[index] = new List<AbstractMesh>(); } }
public static void ConfigureFilmGrain(PostProcessData data, FilmGrain settings, Camera camera, Material material) { // TODO: we need to deprecate camera reference and only use CameraData. ConfigureFilmGrain(data, settings, camera.pixelWidth, camera.pixelHeight, material); }