// Update is called once per frame void Update() { if (foveInterface.Gazecast(instrument_face)) { light_material.EnableKeyword("_EMISSION"); if (light_attached) { light_material.SetColor("_EmissionColor", attachedLight.color); attachedLight.enabled = true; DynamicGI.SetEmissive(GetComponent <Renderer>(), attachedLight.color); } if (clip_attached && !clip_toggle) { attachedClip.Play(); clip_toggle = true; } if (audio_enabled && !audio_toggle) { if (instrument_face.gameObject.CompareTag("HH")) { GetComponent <ChuckSubInstance>().BroadcastEvent("HHImpact"); audio_toggle = true; } else if (instrument_face.gameObject.CompareTag("Th")) { GetComponent <ChuckSubInstance>().SetInt("Choice", 1); GetComponent <ChuckSubInstance>().BroadcastEvent("TImpact"); } else if (instrument_face.gameObject.CompareTag("Tm")) { GetComponent <ChuckSubInstance>().SetInt("Choice", 2); GetComponent <ChuckSubInstance>().BroadcastEvent("TImpact"); } else if (instrument_face.gameObject.CompareTag("Tl")) { GetComponent <ChuckSubInstance>().SetInt("Choice", 3); GetComponent <ChuckSubInstance>().BroadcastEvent("TImpact"); } audio_toggle = true; } } else { light_material.DisableKeyword("_EMISSION"); gameObject.GetComponent <Renderer>().material.color = Color.white; if (light_attached) { attachedLight.enabled = false; DynamicGI.SetEmissive(GetComponent <Renderer>(), Color.black); } clip_toggle = false; audio_toggle = false; } }
void Update() { actualRotate = degreesPerSecond * allSecondsInDay / (minutesPerCycle * 60); this.transform.Rotate(new Vector3(actualRotate, 0, 0) * Time.deltaTime); timeDay += Time.deltaTime / minutesPerCycle; if (timeDay >= fullCycle) { timeDay = 0; } if (timeDay > fullCycle / 2 && timeDay < fullCycle / 2 + 15) { if (sunLight.intensity > minIntensity) { sunLight.intensity -= speedIntensity * Time.deltaTime / minutesPerCycle; } if (RenderSettings.ambientIntensity > minAmbient) { RenderSettings.ambientIntensity -= speedIntensity * Time.deltaTime / minutesPerCycle; } mixSkyboxes += speedIntensity * Time.deltaTime / minutesPerCycle; RenderSettings.skybox.Lerp(RenderSettings.skybox, skyboxNight, mixSkyboxes); DynamicGI.UpdateEnvironment(); } else if (timeDay > fullCycle - 5 || timeDay < 15) { if (sunLight.intensity < maxIntensity) { sunLight.intensity += speedIntensity * Time.deltaTime / minutesPerCycle; } if (RenderSettings.ambientIntensity < maxAmbient) { RenderSettings.ambientIntensity += speedIntensity * Time.deltaTime / minutesPerCycle; } //stars.addAlpha() //TODO mixSkyboxes -= speedIntensity * Time.deltaTime / minutesPerCycle; RenderSettings.skybox.Lerp(RenderSettings.skybox, skyboxDay, Mathf.Abs(mixSkyboxes - 1)); DynamicGI.UpdateEnvironment(); } if (mixSkyboxes > 1f) { mixSkyboxes = 1f; } if (mixSkyboxes < 0f) { mixSkyboxes = 0f; } }
public override void InitializeComponent() { #if !UNITY_EDITOR // This component is responsible for resolving many of the global/builtin things about a level. // Skybox if (Skybox != null) { RenderSettings.skybox = Skybox; RenderSettings.skybox.RefreshShader(); DynamicGI.UpdateEnvironment(); } // Shaders foreach (MeshRenderer ii in GetComponentsInChildren <MeshRenderer>(true)) { foreach (Material jj in ii.materials) { jj.RefreshShader(); } } // Particle Shaders foreach (ParticleSystemRenderer ii in GetComponentsInChildren <ParticleSystemRenderer>(true)) { ii.materials.ForEach(x => x.RefreshShader()); } // Terrain foreach (Terrain ii in GetComponentsInChildren <Terrain>(true)) { ii.materialTemplate.RefreshShader(); ii.terrainData.treePrototypes.ForEach(x => x.prefab.layer = LayerMask.NameToLayer("Environment")); foreach (TreePrototype jj in ii.terrainData.treePrototypes) { jj.prefab.layer = LayerMask.NameToLayer("Environment"); MeshRenderer[] mrs = jj.prefab.GetComponentsInChildren <MeshRenderer>(); mrs.ForEach(x => x.material.RefreshShader()); } foreach (TreeInstance jj in ii.terrainData.treeInstances) { GameObject copiedTree = Instantiate(ii.terrainData.treePrototypes[jj.prototypeIndex].prefab, ii.transform); copiedTree.transform.localPosition = new Vector3(ii.terrainData.size.x * jj.position.x, ii.terrainData.size.y * jj.position.y, ii.terrainData.size.z * jj.position.z); copiedTree.transform.localScale = new Vector3(jj.widthScale, jj.heightScale, jj.widthScale); copiedTree.transform.localEulerAngles = new Vector3(0f, jj.rotation, 0f); } ii.terrainData.treeInstances = new TreeInstance[0]; } // Set the max range on the scene settings // TODO: There are probably a lot of settings we should carry over here. ObjectReferences.FVRSceneSettings.MaxProjectileRange = MaxProjectileRange; ObjectReferences.FVRSceneSettings.DefaultPlayerIFF = PlayerIFF; GM.CurrentPlayerBody.SetPlayerIFF(PlayerIFF); #endif }
void Lighting() { m_SunLightEnable = !CheckDirLightEnable(Mathf.Max(0.0f, Mathf.Min(1.0f, SunDirection.y + 0.30f)), m_SunLightThreshold); m_SunLight.color = sunLightColor.ColorValue; m_SunLight.intensity = sunLightIntensity.Value; m_SunLight.enabled = m_SunLightEnable; //--------------------------------------------------------------------------------------------------------------------------- m_MoonLight.color = moonLightColor.ColorValue; m_MoonLight.intensity = moonLightIntensity.Value * moonLightMultiplier.Value; m_MoonLight.enabled = !m_SunLight.enabled; //--------------------------------------------------------------------------------------------------------------------------- if (applySkybox) { RenderSettings.skybox = skyboxMaterial; } RenderSettings.ambientMode = m_AmbientMode; switch (m_AmbientMode) { case UnityEngine.Rendering.AmbientMode.Skybox: DynamicGI.UpdateEnvironment(); RenderSettings.ambientIntensity = ambientIntensity.Value; break; case UnityEngine.Rendering.AmbientMode.Trilight: RenderSettings.ambientSkyColor = ambientSkyColor.ColorValue; RenderSettings.ambientEquatorColor = ambientEquatorColor.ColorValue; break; case UnityEngine.Rendering.AmbientMode.Flat: RenderSettings.ambientSkyColor = ambientSkyColor.ColorValue; break; } RenderSettings.ambientGroundColor = ambientGroundColor.ColorValue; Shader.SetGlobalColor("LSky_GroundColor", ambientGroundColor.ColorValue); //--------------------------------------------------------------------------------------------------------------------------- RenderSettings.fog = m_EnableUnityFog; if (m_EnableUnityFog) { RenderSettings.fogMode = m_UnityFogMode; RenderSettings.fogColor = unityFogColor.ColorValue; if (m_UnityFogMode == FogMode.Linear) { RenderSettings.fogStartDistance = unityFogStartDistance.Value; RenderSettings.fogEndDistance = unityFogEndDistance.Value; } else { RenderSettings.fogDensity = unityFogDensity.Value; } } }
void DisableEmission() { for (int i = 0; i < EmissiveObjects.Length; i++) { EmissiveObjects[i].material.SetColor("_EmissionColor", Color.black); DynamicGI.SetEmissive(EmissiveObjects[i], Color.black * 0); } }
public void StartGame() { RenderSettings.skybox.SetColor("_Tint", Color.gray); DynamicGI.UpdateEnvironment(); AudioManager.instance.PlayOnce(0); AudioManager.instance.BattleBGM(); lm.StartWaves(); }
public void Capture(Player p) { meshRender.material = glowMaterials[p.id]; DynamicGI.SetEmissive(meshRender, glowMaterials[p.id].color); owner = p; PlayCaptureAnimation(p); p.gameObject.GetComponent <PlayerControl>().SetBoost(true); }
private void UpdateEnvironment(Environment environment) { RenderSettings.skybox = environment.skybox; mainLight.color = environment.lightColor; mainLight.intensity = environment.intensity; DynamicGI.UpdateEnvironment(); _reflectionProbe.RenderProbe(); }
IEnumerator updateGI() { while (needUpdateGI) { DynamicGI.UpdateEnvironment(); yield return(new WaitForSecondsRealtime(0.2f)); } }
IEnumerator updateLightning() { while (t < 1f) { DynamicGI.UpdateEnvironment(); yield return(new WaitForSeconds(.25f)); } }
/*private void CreateUIPopupList() * { * var ui = Instantiate< GameObject>(Resources.Load<GameObject>("UI/UIPopupList")); * var uiRTS = ui.transform as RectTransform; * uiRTS.SetParent(m_UICanvas.transform, false); * uiRTS.anchoredPosition = new Vector2(-200f, 0f); * }*/ private IEnumerator UpdateEnvironment() { yield return(new WaitForSeconds(1f)); DynamicGI.UpdateEnvironment(); mCameraAnim.PlayIntroAnim(); }
/// <summary>Event triggered when the skybox exposure Slider has changed.</summary> /// <param name="exposure">The new exposure value.</param> public void OnSkyboxExposureChanged(float exposure) { _skyboxMaterial.SetFloat("_Exposure", exposure); _skyboxRenderer.material = _skyboxMaterial; RenderSettings.skybox = _skyboxMaterial; DynamicGI.UpdateEnvironment(); _reflectionProbe.RenderProbe(); }
public void Awake() { // Apply provided settings to the entire scene RenderSettings.ambientIntensity = ambientIntensity; RenderSettings.skybox = GetComponent <Skybox>().material; DynamicGI.UpdateEnvironment(); }
void EnableEmission() { for (int i = 0; i < EmissiveObjects.Length; i++) { EmissiveObjects[i].material.SetColor("_EmissionColor", EmissColors[i]); DynamicGI.SetEmissive(EmissiveObjects[i], EmissColors[i] * 0.36f); } }
public void SwitchFog(bool selected) { RenderSettings.fog = selected; RenderSettings.fogDensity = 0.18f; RenderSettings.fogMode = FogMode.Exponential; RenderSettings.fogColor = Color.gray; // 0x858585FF; DynamicGI.UpdateEnvironment(); }
public void ObjectChangeRight() { if (sceneNumber != scenes.Length - 1) { sceneNumber += 1; DynamicGI.UpdateEnvironment(); } }
public void TurnLightsOff() { RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; RenderSettings.ambientIntensity = 0.1f; DynamicGI.UpdateEnvironment(); testLight.enabled = false; }
private void Update() { Color c = Color.Lerp(Color.white, Color.black, Mathf.Sin(Time.time * Mathf.PI) * 0.5f + 0.5f); emissiveMaterial.SetColor("_Emission", c); //emissiveRenderer.UpdateGIMaterials(); DynamicGI.SetEmissive(emissiveRenderer, c); }
public override void OnValueChanged(float value) { base.OnValueChanged(value); Color color = Color.LerpUnclamped(Color.black, emissionColor * emission, value); GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", color); DynamicGI.SetEmissive(GetComponent <MeshRenderer>(), color); }
public void TurnLightsOn() { RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; RenderSettings.ambientIntensity = 1f; DynamicGI.UpdateEnvironment(); light.enabled = true; }
public void UpdateEnvironment(HDCamera camera, Light sunLight, CommandBuffer cmd) { // WORKAROUND for building the player. // When building the player, for some reason we end up in a state where frameCount is not updated but all currently setup shader texture are reset to null // resulting in a rendering error (compute shader property not bound) that makes the player building fails... // So we just check if the texture is bound here so that we can setup a pink one to avoid the error without breaking half the world. if (Shader.GetGlobalTexture(HDShaderIDs._SkyTexture) == null) { cmd.SetGlobalTexture(HDShaderIDs._SkyTexture, CoreUtils.magentaCubeTexture); } // This is done here because we need to wait for one frame that the command buffer is executed before using the resulting textures. // Testing the current skybox material is because we have to make sure that additive scene loading or even some user script haven't altered it. if (m_NeedUpdateBakingSky || (RenderSettings.skybox != m_StandardSkyboxMaterial)) { // Here we update the global SkyMaterial so that it uses our baking sky cubemap. This way, next time the GI is baked, the right sky will be present. float intensity = m_BakingSky.IsValid() ? 1.0f : 0.0f; // Eliminate all diffuse if we don't have a skybox (meaning for now the background is black in HDRP) m_StandardSkyboxMaterial.SetTexture("_Tex", m_BakingSkyRenderingContext.cubemapRT); RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings RenderSettings.ambientIntensity = intensity; RenderSettings.ambientMode = AmbientMode.Skybox; // Force skybox for our HDRI RenderSettings.reflectionIntensity = intensity; RenderSettings.customReflection = null; // Strictly speaking, this should not be necessary, but it helps avoiding inconsistent behavior in the editor // where the GI system sometimes update the ambient probe and sometime does not... DynamicGI.UpdateEnvironment(); m_NeedUpdateBakingSky = false; } if (m_NeedUpdateRealtimeEnv) { // TODO: Here we need to do that in case we are using real time GI. Unfortunately we don't have a way to check that atm. // Moreover we still need Async readback from texture in command buffers first. //DynamicGI.SetEnvironmentData(); m_NeedUpdateRealtimeEnv = false; } // For the baking sky, we don't want to take the sun into account because we usually won't include it (this would cause double highlight in the reflection for example). // So we pass null so that's it doesn't affect the hash and the rendering. m_NeedUpdateBakingSky = m_BakingSkyRenderingContext.UpdateEnvironment(m_BakingSky, camera, null, m_UpdateRequired, cmd); SkyUpdateContext currentSky = m_LightingOverrideSky.IsValid() ? m_LightingOverrideSky : m_VisualSky; m_NeedUpdateRealtimeEnv = m_SkyRenderingContext.UpdateEnvironment(currentSky, camera, sunLight, m_UpdateRequired, cmd); m_UpdateRequired = false; SetGlobalSkyTexture(cmd); if (IsSkyValid()) { cmd.SetGlobalInt(HDShaderIDs._EnvLightSkyEnabled, 1); } else { cmd.SetGlobalInt(HDShaderIDs._EnvLightSkyEnabled, 0); } }
private void SetUpGI() { RenderSettings.skybox = null; Color c; ColorUtility.TryParseHtmlString("#999999", out c); RenderSettings.ambientLight = c; DynamicGI.UpdateEnvironment(); }
IEnumerator UpdateLighting() { while (environmentLightingEnabled) { RenderSettings.ambientIntensity = lightingIntensity; DynamicGI.UpdateEnvironment(); yield return(new WaitForSeconds(1f / lightingRefreshRate)); } }
public void UpdateGI(float timeLerp) { GetReferences(); Color color = this.Color.Evaluate(timeLerp); propertyBlock.SetColor("_EmissionColor", color * this.Multiply); renderer.SetPropertyBlock(this.propertyBlock); DynamicGI.SetEmissive(this.renderer, color * this.Multiply); }
// Update is called once per frame void Update() { if (colorIndex != _lastIndex || permanentUpdate) { _lastIndex = colorIndex; skybox.SetColor("_Tint", colors[Mathf.Clamp(colorIndex, 0, colors.Length - 1)]); DynamicGI.UpdateEnvironment(); } }
private void SetTurns() { turnsLeft -= 1; turns.text = turnsLeft.ToString(); Renderer r = connectedBattery.transform.GetChild(0).GetComponent <Renderer>(); r.material.SetColor("_EmissionColor", r.material.GetColor("_EmissionColor") * .85f); DynamicGI.SetEmissive(r, r.material.GetColor("_EmissionColor") * .85f); }
void OnGUI() { if (GUI.Button(new Rect(0, 30, 100, 50), "Change skybox")) { currentSkybox = (currentSkybox + 1) % skyboxes.Length; RenderSettings.skybox = skyboxes[currentSkybox]; DynamicGI.UpdateEnvironment(); } }
public void OnCollisionEnter(Collision collision) { if (collision.collider.GetComponent <Bullet>() != null) { lightRenderer.material.SetColor("_EmissionColor", new Color(0, lightIntensity, 0)); DynamicGI.UpdateMaterials(lightRenderer); Target.SendMessage(Event); } }
void OnLevelWasLoaded(int level) { #if UNITY_EDITOR if (UnityEditor.Lightmapping.giWorkflowMode == UnityEditor.Lightmapping.GIWorkflowMode.Iterative) { DynamicGI.UpdateEnvironment(); } #endif }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.L)) { Color final = Color.white * Mathf.LinearToGammaSpace(4); renderer.material.SetColor("_EmissionColor", final); DynamicGI.SetEmissive(renderer, final); } }