コード例 #1
0
    // 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;
        }
    }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
ファイル: CustomScene.cs プロジェクト: WurstModders/WurstMod
        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
        }
コード例 #4
0
ファイル: LSky.cs プロジェクト: Vytek/LSky-v2
        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;
                }
            }
        }
コード例 #5
0
 void DisableEmission()
 {
     for (int i = 0; i < EmissiveObjects.Length; i++)
     {
         EmissiveObjects[i].material.SetColor("_EmissionColor", Color.black);
         DynamicGI.SetEmissive(EmissiveObjects[i], Color.black * 0);
     }
 }
コード例 #6
0
 public void StartGame()
 {
     RenderSettings.skybox.SetColor("_Tint", Color.gray);
     DynamicGI.UpdateEnvironment();
     AudioManager.instance.PlayOnce(0);
     AudioManager.instance.BattleBGM();
     lm.StartWaves();
 }
コード例 #7
0
ファイル: Slot.cs プロジェクト: DeadPoolP/trouble-ahead
 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);
 }
コード例 #8
0
 private void UpdateEnvironment(Environment environment)
 {
     RenderSettings.skybox = environment.skybox;
     mainLight.color       = environment.lightColor;
     mainLight.intensity   = environment.intensity;
     DynamicGI.UpdateEnvironment();
     _reflectionProbe.RenderProbe();
 }
コード例 #9
0
ファイル: DayCycle.cs プロジェクト: OdemTut/sands
 IEnumerator updateGI()
 {
     while (needUpdateGI)
     {
         DynamicGI.UpdateEnvironment();
         yield return(new WaitForSecondsRealtime(0.2f));
     }
 }
コード例 #10
0
 IEnumerator updateLightning()
 {
     while (t < 1f)
     {
         DynamicGI.UpdateEnvironment();
         yield return(new WaitForSeconds(.25f));
     }
 }
コード例 #11
0
    /*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();
    }
コード例 #12
0
 /// <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();
 }
コード例 #13
0
        public void Awake()
        {
            // Apply provided settings to the entire scene
            RenderSettings.ambientIntensity = ambientIntensity;
            RenderSettings.skybox           = GetComponent <Skybox>().material;

            DynamicGI.UpdateEnvironment();
        }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
ファイル: GameControl.cs プロジェクト: SuperAppps/WebGL-Demo
 public void SwitchFog(bool selected)
 {
     RenderSettings.fog        = selected;
     RenderSettings.fogDensity = 0.18f;
     RenderSettings.fogMode    = FogMode.Exponential;
     RenderSettings.fogColor   = Color.gray;         // 0x858585FF;
     DynamicGI.UpdateEnvironment();
 }
コード例 #16
0
 public void ObjectChangeRight()
 {
     if (sceneNumber != scenes.Length - 1)
     {
         sceneNumber += 1;
         DynamicGI.UpdateEnvironment();
     }
 }
コード例 #17
0
    public void TurnLightsOff()
    {
        RenderSettings.ambientMode      = UnityEngine.Rendering.AmbientMode.Skybox;
        RenderSettings.ambientIntensity = 0.1f;
        DynamicGI.UpdateEnvironment();

        testLight.enabled = false;
    }
コード例 #18
0
    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);
    }
コード例 #19
0
    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);
    }
コード例 #20
0
    public void TurnLightsOn()
    {
        RenderSettings.ambientMode      = UnityEngine.Rendering.AmbientMode.Skybox;
        RenderSettings.ambientIntensity = 1f;
        DynamicGI.UpdateEnvironment();

        light.enabled = true;
    }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
ファイル: ZEDRenderingPlane.cs プロジェクト: zaherj/zed-unity
    private void SetUpGI()
    {
        RenderSettings.skybox = null;
        Color c;

        ColorUtility.TryParseHtmlString("#999999", out c);
        RenderSettings.ambientLight = c;
        DynamicGI.UpdateEnvironment();
    }
コード例 #23
0
 IEnumerator UpdateLighting()
 {
     while (environmentLightingEnabled)
     {
         RenderSettings.ambientIntensity = lightingIntensity;
         DynamicGI.UpdateEnvironment();
         yield return(new WaitForSeconds(1f / lightingRefreshRate));
     }
 }
コード例 #24
0
    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);
    }
コード例 #25
0
 // 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();
     }
 }
コード例 #26
0
    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);
    }
コード例 #27
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(0, 30, 100, 50), "Change skybox"))
     {
         currentSkybox         = (currentSkybox + 1) % skyboxes.Length;
         RenderSettings.skybox = skyboxes[currentSkybox];
         DynamicGI.UpdateEnvironment();
     }
 }
コード例 #28
0
 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);
     }
 }
コード例 #29
0
ファイル: LightingFix.cs プロジェクト: highDraze/WorldsEdge
 void OnLevelWasLoaded(int level)
 {
 #if UNITY_EDITOR
     if (UnityEditor.Lightmapping.giWorkflowMode == UnityEditor.Lightmapping.GIWorkflowMode.Iterative)
     {
         DynamicGI.UpdateEnvironment();
     }
 #endif
 }
コード例 #30
0
 // 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);
     }
 }