Exemple #1
0
        internal void UpdateShaderVariables()
        {
            if (this.Profile == null)
            {
                return;
            }
            if (this._DisplacementMaterial.IsNullReference(this))
            {
                return;
            }
            float num = (float)this._PixelsPerUnit / 32f;

            RipplesShader.SetPropagation(this.Profile.Propagation * num, this._RipplesMaterial);
            RipplesShader.SetStaticDepth(DefaultTextures.Get(Color.clear), this._RipplesMaterial);
            RipplesShader.SetDamping(this.Profile.Damping / 32f, this._RipplesMaterial);
            RipplesShader.SetGain(this.Profile.Gain, this._RipplesMaterial);
            RipplesShader.SetHeightGain(this.Profile.HeightGain, this._RipplesMaterial);
            RipplesShader.SetHeightOffset(this.Profile.HeightOffset, this._RipplesMaterial);
            float[] array = UltimateWater.Utils.Math.GaussianTerms(this.Profile.Sigma);
            GaussianShader.Term0 = array[0];
            GaussianShader.Term1 = array[1];
            GaussianShader.Term2 = array[2];
            this._DisplacementMaterial.SetFloat("_Amplitude", this.Profile.Amplitude * 0.05f);
            this._DisplacementMaterial.SetFloat("_Spread", this.Profile.Spread);
            this._DisplacementMaterial.SetFloat("_Multiplier", this.Profile.Multiplier);
            this._DisplacementMaterial.SetFloat("_Fadeout", (!this._Fade) ? 0f : 1f);
            this._DisplacementMaterial.SetFloat("_FadePower", this._FadePower);
        }
Exemple #2
0
        private static void DrawDiffuseRenderers(DynamicWaterCameraData overlays)
        {
            List <ILocalDiffuseRenderer> localDiffuse = DynamicWater._Renderers.LocalDiffuse;

            for (int i = localDiffuse.Count - 1; i >= 0; i--)
            {
                localDiffuse[i].Enable();
            }
            Shader.SetGlobalTexture("_CameraDepthTexture", DefaultTextures.Get(Color.white));
            Camera cameraComponent = overlays.Camera.CameraComponent;

            GL.PushMatrix();
            GL.modelview = cameraComponent.worldToCameraMatrix;
            GL.LoadProjectionMatrix(cameraComponent.projectionMatrix);
            DynamicWater._RenderDiffuseBuffer.Clear();
            DynamicWater._RenderDiffuseBuffer.SetRenderTarget(overlays.DiffuseMap);
            for (int j = localDiffuse.Count - 1; j >= 0; j--)
            {
                localDiffuse[j].RenderLocalDiffuse(DynamicWater._RenderDiffuseBuffer, overlays);
            }
            Graphics.ExecuteCommandBuffer(DynamicWater._RenderDiffuseBuffer);
            GL.PopMatrix();
            for (int k = localDiffuse.Count - 1; k >= 0; k--)
            {
                localDiffuse[k].Disable();
            }
        }
Exemple #3
0
 public void UpdateMask(RenderTexture mask)
 {
     if (this.Preview)
     {
         Graphics.Blit(DefaultTextures.Get(Color.white), mask);
     }
     this._Material.SetTexture("_Mask", mask);
 }
Exemple #4
0
 private void AdditiveMask(WaterCamera waterCamera, bool hasAdditiveVolumes)
 {
     if (hasAdditiveVolumes)
     {
         this.RenderAdditivePass(waterCamera);
     }
     else
     {
         Shader.SetGlobalTexture(this._AdditiveMaskId, DefaultTextures.Get(Color.clear));
     }
 }
Exemple #5
0
 private void SubtractiveMask(WaterCamera waterCamera, bool hasSubtractiveVolumes, bool hasFlatMasks)
 {
     if (hasSubtractiveVolumes || hasFlatMasks)
     {
         this.RenderSubtractivePass(waterCamera, hasSubtractiveVolumes, hasFlatMasks);
     }
     else
     {
         Shader.SetGlobalTexture(this._SubtractiveMaskId, DefaultTextures.Get(Color.clear));
     }
 }
Exemple #6
0
 internal override void Disable()
 {
     if (this._ScatteringTex != null)
     {
         this._ScatteringTex.Destroy();
         this._ScatteringTex = null;
     }
     if (this._Water != null)
     {
         Texture2D texture2D = DefaultTextures.Get(Color.white);
         if (texture2D != null)
         {
             this._Water.Renderer.PropertyBlock.SetTexture("_SubsurfaceScattering", texture2D);
         }
     }
 }
 private void PrepareShadows(Camera cameraComponent)
 {
     if (this._CopyShadowmap == null)
     {
         this._CopyShadowmap = new CommandBuffer
         {
             name = "[UWS] LightWaterEffects._CopyShadowmap"
         };
     }
     Shader.SetGlobalTexture(LightWaterEffects._ShadowmapId, DefaultTextures.Get(Color.white));
     this._CopyShadowmap.Clear();
     this._CopyShadowmap.GetTemporaryRT(LightWaterEffects._ShadowmapId, cameraComponent.pixelWidth, cameraComponent.pixelHeight, 32, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
     this._CopyShadowmap.Blit(BuiltinRenderTextureType.CurrentActive, LightWaterEffects._ShadowmapId);
     this._CopyShadowmap.ReleaseTemporaryRT(LightWaterEffects._ShadowmapId);
     this._LocalLight.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, this._CopyShadowmap);
     this._LocalLight.AddCommandBuffer(LightEvent.AfterScreenspaceMask, this._CopyShadowmap);
 }
Exemple #8
0
        private static DefaultTextures GetDefaultTextures(IGraphicsService graphicsService)
        {
            if (graphicsService == null)
            {
                throw new ArgumentNullException("graphicsService");
            }

            const string key = "__DefaultTextures";
            object       defaultTextures;

            if (!graphicsService.Data.TryGetValue(key, out defaultTextures) || !(defaultTextures is DefaultTextures))
            {
                defaultTextures           = new DefaultTextures();
                graphicsService.Data[key] = defaultTextures;
            }

            return((DefaultTextures)defaultTextures);
        }
Exemple #9
0
        private static void DrawDisplacementMaskRenderers(DynamicWaterCameraData overlays)
        {
            Shader.SetGlobalTexture("_CameraDepthTexture", DefaultTextures.Get(Color.white));
            Camera cameraComponent = overlays.Camera.CameraComponent;

            GL.PushMatrix();
            GL.modelview = cameraComponent.worldToCameraMatrix;
            GL.LoadProjectionMatrix(cameraComponent.projectionMatrix);
            DynamicWater._RenderDisplacementMaskBuffer.Clear();
            DynamicWater._RenderDisplacementMaskBuffer.SetRenderTarget(overlays.DisplacementsMask);
            List <ILocalDisplacementMaskRenderer> localDisplacementMask = DynamicWater._Renderers.LocalDisplacementMask;

            for (int i = localDisplacementMask.Count - 1; i >= 0; i--)
            {
                localDisplacementMask[i].RenderLocalMask(DynamicWater._RenderDisplacementMaskBuffer, overlays);
            }
            Graphics.ExecuteCommandBuffer(DynamicWater._RenderDisplacementMaskBuffer);
            GL.PopMatrix();
        }
Exemple #10
0
 protected override void ExtensionGUI()
 {
     EditorGUI.BeginChangeCheck();
     TexLod          = EditorGUILayout.Toggle("Lod采样", TexLod);
     DecodeHDR       = EditorGUILayout.Toggle("解码HDR贴图", DecodeHDR);
     UseReflectProbe = EditorGUILayout.Toggle("使用反射探针", UseReflectProbe);
     if (!UseReflectProbe)
     {
         EditorGUILayout.BeginHorizontal();
         {
             GUILayout.Label("默认值");
             DefaultTextures.OnGui(EditorStyles.miniButton);
         }
         EditorGUILayout.EndHorizontal();
     }
     if (EditorGUI.EndChangeCheck())
     {
         SetReflectProbe();
         SetDefaultValue();
         SetLod();
     }
 }
Exemple #11
0
        private static DefaultTextures GetDefaultTextures(IGraphicsService graphicsService)
        {
            if (graphicsService == null)
            throw new ArgumentNullException("graphicsService");

              const string key = "__DefaultTextures";
              object defaultTextures;
              if (!graphicsService.Data.TryGetValue(key, out defaultTextures) || !(defaultTextures is DefaultTextures))
              {
            defaultTextures = new DefaultTextures();
            graphicsService.Data[key] = defaultTextures;
              }

              return (DefaultTextures)defaultTextures;
        }