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); }
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(); } }
public void UpdateMask(RenderTexture mask) { if (this.Preview) { Graphics.Blit(DefaultTextures.Get(Color.white), mask); } this._Material.SetTexture("_Mask", mask); }
private void AdditiveMask(WaterCamera waterCamera, bool hasAdditiveVolumes) { if (hasAdditiveVolumes) { this.RenderAdditivePass(waterCamera); } else { Shader.SetGlobalTexture(this._AdditiveMaskId, DefaultTextures.Get(Color.clear)); } }
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)); } }
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); }
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(); }