public override void ProcessFrame(Playable handle, FrameData info, object playerData) { var count = handle.GetInputCount(); var cineLight = lightTargetGO.GetComponent <CineLight>(); GameObject attachmentTransform = playerData as GameObject; if (attachmentTransform != null) { attachmentPosition = attachmentTransform.transform.position; cineLight.SetAttachmentTransform(attachmentTransform, true); lightTargetGO.transform.position = attachmentPosition; } light = cineLight.GetComponentInChildren <Light>(); globalUseShadowCaster = false; List <float> inputWeights = new List <float>(); CineLightParameters fromCineLightParameters = new CineLightParameters(); LightParameters fromLightParameters = new LightParameters(); ShadowCasterParameters fromShadowCasterParameters = new ShadowCasterParameters(); float fadeWeight = new float(); CineLightParameters toCineLightParameters = new CineLightParameters(); LightParameters toLightParameters = new LightParameters(); ShadowCasterParameters toShadowCasterParameters = new ShadowCasterParameters(); float crossFadeWeight = new float(); //Short loop, feed data for most cases for (var i = 0; i < count; i++) { var inputHandle = handle.GetInput(i); var weight = handle.GetInputWeight(i); if (inputHandle.IsValid() && inputHandle.GetPlayState() == PlayState.Playing && weight > 0) { var data = ((ScriptPlayable <CineLightClipPlayable>)inputHandle).GetBehaviour(); if (data != null) { if (weight > 0) { inputWeights.Add(weight); if (inputWeights.Count == 1) { fromCineLightParameters = CineLightParameters.DeepCopy(data.cinelightParameters); fromLightParameters = LightParameters.DeepCopy(data.lightParameters); fromShadowCasterParameters = ShadowCasterParameters.DeepCopy(data.shadowCasterParameters); fadeWeight = weight; } if (inputWeights.Count == 2) { toCineLightParameters = CineLightParameters.DeepCopy(data.cinelightParameters); toLightParameters = LightParameters.DeepCopy(data.lightParameters); toShadowCasterParameters = ShadowCasterParameters.DeepCopy(data.shadowCasterParameters); crossFadeWeight = weight; } if (data.shadowCasterParameters.useShadowCaster == true) { globalUseShadowCaster = true; } } if (inputWeights.Count > 2) { break; } } } } if (inputWeights.Count == 1) { isFading = true; isCrossFading = false; } else if (inputWeights.Count == 2) { isFading = false; isCrossFading = true; } else { isFading = false; isCrossFading = false; } if (isFading == true) { DoSingleClip(fromCineLightParameters, fromLightParameters, fromShadowCasterParameters, fadeWeight); } if (isCrossFading == true) { DoCrossFadeSettings(fromCineLightParameters, fromLightParameters, fromShadowCasterParameters, toCineLightParameters, toLightParameters, toShadowCasterParameters, crossFadeWeight, cineLight); } if (isFading == false && isCrossFading == false) { DoLongLoop(cineLight, handle, count); } mixedLightParameters.fadeDistance = 99999; mixedLightParameters.shadowFadeDistance = 99999; mixedLightParameters.mode = LightmapPresetBakeType.Realtime; LightingUtilities.ApplyLightParameters(light, mixedLightParameters); CineLightUtilities.ApplyCineLightParameters(cineLight, mixedCineLightParameters); if (globalUseShadowCaster && cineLight.shadowCasterGO == null) { cineLight.useShadowCaster = true; cineLight.ApplyShadowCaster(); } if (cineLight.shadowCasterGO != null) { cineLight.shadowCasterGO.GetComponent <MeshRenderer>().enabled = mixedShadowCasterParameters.useShadowCaster; cineLight.shadowCasterGO.transform.localScale = new Vector3(mixedShadowCasterParameters.shadowCasterSize.x, mixedShadowCasterParameters.shadowCasterSize.y, 1); cineLight.shadowCasterGO.transform.localPosition = new Vector3(mixedShadowCasterParameters.shadowCasterOffset.x, mixedShadowCasterParameters.shadowCasterOffset.y, -mixedShadowCasterParameters.shadowCasterDistance); } lightTargetGO.SetActive(mixedLightParameters.intensity == 0 ? false : true); }
public void SetLightSettings() { LightingUtilities.ApplyLightParameters(directionalLight, modifiedLightParameters); }
public void SetLightSettings() { LightingUtilities.ApplyLightParameters(directionalLight, sunlightParameters.lightParameters); }