Exemplo n.º 1
0
    void Awake()
    {
        noise = Camera.main.GetComponent <UnityStandardAssets.ImageEffects.NoiseAndGrain>();

        press = false;
        t     = 0.0f;
    }
Exemplo n.º 2
0
 private void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     if (!this.CheckResources() || null == this.noiseTexture)
     {
         Graphics.Blit(source, destination);
         if (null == this.noiseTexture)
         {
             Debug.LogWarning("Noise & Grain effect failing as noise texture is not assigned. please assign.", base.transform);
         }
     }
     else
     {
         this.softness = Mathf.Clamp(this.softness, 0f, 0.99f);
         if (this.dx11Grain && this.supportDX11)
         {
             this.dx11NoiseMaterial.SetFloat("_DX11NoiseTime", (float)Time.frameCount);
             this.dx11NoiseMaterial.SetTexture("_NoiseTex", this.noiseTexture);
             this.dx11NoiseMaterial.SetVector("_NoisePerChannel", (!this.monochrome) ? this.intensities : Vector3.one);
             this.dx11NoiseMaterial.SetVector("_MidGrey", new Vector3(this.midGrey, 1f / (1f - this.midGrey), -1f / this.midGrey));
             this.dx11NoiseMaterial.SetVector("_NoiseAmount", new Vector3(this.generalIntensity, this.blackIntensity, this.whiteIntensity) * this.intensityMultiplier);
             if (this.softness > Mathf.Epsilon)
             {
                 RenderTexture temporary = RenderTexture.GetTemporary((int)((float)source.width * (1f - this.softness)), (int)((float)source.height * (1f - this.softness)));
                 NoiseAndGrain.DrawNoiseQuadGrid(source, temporary, this.dx11NoiseMaterial, this.noiseTexture, (!this.monochrome) ? 2 : 3);
                 this.dx11NoiseMaterial.SetTexture("_NoiseTex", temporary);
                 Graphics.Blit(source, destination, this.dx11NoiseMaterial, 4);
                 RenderTexture.ReleaseTemporary(temporary);
             }
             else
             {
                 NoiseAndGrain.DrawNoiseQuadGrid(source, destination, this.dx11NoiseMaterial, this.noiseTexture, (!this.monochrome) ? 0 : 1);
             }
         }
         else
         {
             if (this.noiseTexture)
             {
                 this.noiseTexture.wrapMode   = TextureWrapMode.Repeat;
                 this.noiseTexture.filterMode = this.filterMode;
             }
             this.noiseMaterial.SetTexture("_NoiseTex", this.noiseTexture);
             this.noiseMaterial.SetVector("_NoisePerChannel", (!this.monochrome) ? this.intensities : Vector3.one);
             this.noiseMaterial.SetVector("_NoiseTilingPerChannel", (!this.monochrome) ? this.tiling : (Vector3.one * this.monochromeTiling));
             this.noiseMaterial.SetVector("_MidGrey", new Vector3(this.midGrey, 1f / (1f - this.midGrey), -1f / this.midGrey));
             this.noiseMaterial.SetVector("_NoiseAmount", new Vector3(this.generalIntensity, this.blackIntensity, this.whiteIntensity) * this.intensityMultiplier);
             if (this.softness > Mathf.Epsilon)
             {
                 RenderTexture temporary2 = RenderTexture.GetTemporary((int)((float)source.width * (1f - this.softness)), (int)((float)source.height * (1f - this.softness)));
                 NoiseAndGrain.DrawNoiseQuadGrid(source, temporary2, this.noiseMaterial, this.noiseTexture, 2);
                 this.noiseMaterial.SetTexture("_NoiseTex", temporary2);
                 Graphics.Blit(source, destination, this.noiseMaterial, 1);
                 RenderTexture.ReleaseTemporary(temporary2);
             }
             else
             {
                 NoiseAndGrain.DrawNoiseQuadGrid(source, destination, this.noiseMaterial, this.noiseTexture, 0);
             }
         }
     }
 }
Exemplo n.º 3
0
    public void Activate(bool state, bool forceTurnOffCamera = false)
    {
        isPlaying = state;
        // TEMP
        Transform childTransform = transform.FindChild("toungue");

        if (isPlaying == true || forceTurnOffCamera == true)
        {
            childTransform.gameObject.SetActive(true);
        }
        else
        {
            childTransform.gameObject.SetActive(false);
        }
        // TEMP
        if (forceTurnOffCamera == true)
        {
            camera.gameObject.SetActive(false);
        }
        else
        {
            if (GameState.Instance.isPIPEnabled)
            {
                camera.gameObject.SetActive(true);
                if (isPlaying == true) // PIP
                {
                    camera.depth = 1;
                    camera.rect  = new Rect(0.01f, 0.71f, 0.28f, 0.28f);
                    camera.transform.GetChild(0).gameObject.SetActive(false);
                    camera.GetComponent <AudioListener>().enabled = false;
                }
                else // 메인
                {
                    camera.depth = 0;
                    camera.rect  = new Rect(0, 0, 1, 1);
                    camera.transform.GetChild(0).gameObject.SetActive(true);
                    camera.GetComponent <AudioListener>().enabled = true;
                }
            }
            else
            {
                camera.gameObject.SetActive(!state);
            }
        }

        UnityStandardAssets.ImageEffects.NoiseAndGrain noise = camera.gameObject.GetComponent <UnityStandardAssets.ImageEffects.NoiseAndGrain> ();
        noise.intensityMultiplier = 0f;
    }
Exemplo n.º 4
0
    IEnumerator Coroutine_StartNoiseGrain(Camera cam)
    {
        Instruction_Switching.Instances [ballCursor].Show();
        UnityStandardAssets.ImageEffects.NoiseAndGrain noise = cam.gameObject.GetComponent <UnityStandardAssets.ImageEffects.NoiseAndGrain> ();

        float start     = noise.intensityMultiplier;
        float starttime = 0f;

        while (starttime < 1f)
        {
            starttime += Time.deltaTime;
            noise.intensityMultiplier = Mathf.Lerp(start, 7.5f, starttime);

            yield return(null);
        }
    }