public DepthTextureMode Render(Camera camera, OceanCameraTask data, PreparedContent renderContents) { var quality = data.projectSetting.DepthEffect; if ((renderContents & PreparedContent.RefractionTexture) != 0) { switch (quality.RenderMode) { case DepthEffectRenderMode.Camera: return(RenderWhenOpaque(camera, data, quality, renderContents)); case DepthEffectRenderMode.Buffer: return(RenderWhenTransparent(camera, data)); default: Debug.LogError(new ArgumentOutOfRangeException(nameof(quality.RenderMode), quality.RenderMode, "Unkonw value"), camera); return(DepthTextureMode.None); } } else if ((renderContents & PreparedContent.RefractionDepthTexture) != 0) { switch (quality.RenderMode) { case DepthEffectRenderMode.Buffer: return(RenderDepthOnlyWhenTransparent(camera, data)); case DepthEffectRenderMode.Camera: return(RenderDepthOnlyWhenOpaque(camera, data, quality, renderContents)); default: Debug.LogError(new ArgumentOutOfRangeException(nameof(quality.RenderMode), quality.RenderMode, "Unkonw value"), camera); return(DepthTextureMode.None); } } return(DepthTextureMode.None); }
public void SetValueToShader(OceanCameraTask oceanCamera, PreparedContent preparedContent) { if ((preparedContent & PreparedContent.FoamArea1) != 0) { if (observers.Count == 0) { ResetShader(); return; } else if (observers.Count == 1) { SetValueToShader(observers[0]); } else { Vector3 cameraPos = oceanCamera.transform.position; IFoamArea min = observers[0]; float minDis = Vector3.Distance(cameraPos, min.Position); for (int i = 1; i < observers.Count; i++) { var current = observers[i]; var currentDis = Vector3.Distance(cameraPos, current.Position); if (currentDis < minDis) { min = current; minDis = currentDis; } } SetValueToShader(min); } } }
public PreparedContent GetRenderContents() { var modeOptions = this; PreparedContent renderContents = PreparedContent.SunLight; if (modeOptions.Clip != ClipMode.None) { renderContents |= PreparedContent.ClipTexture; } if (modeOptions.Refraction == RefractionMode.Simple) { renderContents |= PreparedContent.RefractionTexture | PreparedContent.RefractionDepthTexture; } else if (modeOptions.Refraction == RefractionMode.Full) { renderContents |= PreparedContent.RefractionTexture | PreparedContent.RefractionDepthTexture | PreparedContent.UnderOceanMarkTexture; } if (modeOptions.BackRefraction == BackRefractionMode.Simple) { renderContents |= PreparedContent.RefractionTexture | PreparedContent.RefractionDepthTexture; } else if (modeOptions.BackRefraction == BackRefractionMode.Full) { renderContents |= PreparedContent.RefractionTexture | PreparedContent.RefractionDepthTexture | PreparedContent.UnderOceanMarkTexture; } if (modeOptions.FoamShpere == FoamShpereMode.Shpere8) { renderContents |= PreparedContent.RefractionDepthTexture | PreparedContent.Foam8; } else if (modeOptions.FoamShpere == FoamShpereMode.Shpere16) { renderContents |= PreparedContent.RefractionDepthTexture | PreparedContent.Foam16; } else if (modeOptions.Foam != FoamMode.None) { renderContents |= PreparedContent.RefractionDepthTexture; } if (modeOptions.FoamArea == FoamAreaMode.Area1) { renderContents |= PreparedContent.FoamArea1; } if (modeOptions.Reflection != ReflectionMode.None) { renderContents |= PreparedContent.ReflectionTexture; } if (modeOptions.Ripple != RippleMode.None) { renderContents |= PreparedContent.Ripple; } return(renderContents); }
public override PreparedContent GetRenderContents(OceanCameraTask oceanCamera) { PreparedContent preparedContents = Data.GetRenderContents(lodLevel); return(preparedContents); }
public DepthTextureMode Render(Camera camera, OceanCameraTask oceanCamera, PreparedContent renderContents) { try { if (((renderContents & PreparedContent.UnderOceanMarkTexture) == 0) || (underOceanMarkDrawers.Count == 0 && underOceanMarkObservers.Count == 0)) { Shader.SetGlobalTexture(UnderOceanMarkTextureShaderID, BlackTexture.Value); Shader.SetGlobalTexture(UnderOceanMarkDepthTextureShaderID, BlackTexture.Value); return(DepthTextureMode.None); } CameraTaskEvent eventValue = new CameraTaskEvent(renderCamera, oceanCamera, oceanCamera.projectSetting.MarkLayer); NotifyObservers(underOceanMarkDrawers, eventValue); NotifyObservers(underOceanMarkObservers, eventValue); var textureSize = RenderHelper.GetTextureSize(camera, oceanCamera.projectSetting.UnderOceanMark.TextureScale); UnderOceanMarkTexture = RenderTexture.GetTemporary(textureSize.x, textureSize.y); UnderOceanMarkDepthTexture = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 24, RenderTextureFormat.Depth); RenderHelper.CopyCameraOptions(camera, renderCamera); renderCamera.cullingMask = oceanCamera.projectSetting.MarkCullingMask; renderCamera.transform.position = camera.transform.position; renderCamera.transform.rotation = camera.transform.rotation; renderCamera.SetTargetBuffers(UnderOceanMarkTexture.colorBuffer, UnderOceanMarkDepthTexture.depthBuffer); renderCamera.Render(); renderCamera.targetTexture = null; SetValuesToShader(); return(DepthTextureMode.None); } finally { underOceanMarkDrawers.Clear(); } }
public DepthTextureMode RenderDepthOnlyWhenOpaque(Camera camera, OceanCameraTask data, DepthEffecttProjectSettings setting, PreparedContent renderContents) { RemoveCommandBufferColor(camera); OceanIsOpaque(); InternalRenderDepthOnly(camera, data, setting, renderContents); SetValuesToShader(); return(DepthTextureMode.None); }
internal void InternalRenderColorAndDepth(Camera camera, OceanCameraTask oceanCamera, DepthEffecttProjectSettings setting, PreparedContent renderContents) { var textureSize = RenderHelper.GetTextureSize(camera, setting.TextureScale); var colorRenderTexture = RenderTexture.GetTemporary(textureSize.x, textureSize.y); var depthRenderTexture = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 24, RenderTextureFormat.Depth); renderCamera.clearFlags = CameraClearFlags.Skybox; renderCamera.renderingPath = setting.CameraRenderingPath; RenderHelper.CopyCameraOptions(camera, renderCamera); RenderHelper.SetLayerWithoutWater(renderCamera, setting.CullingMask & camera.cullingMask); RenderHelper.CopySkyBox(oceanCamera, skybox); renderCamera.transform.position = camera.transform.position; renderCamera.transform.rotation = camera.transform.rotation; using (new RenderHelper.PointLightsScope(setting.EnablePointLights)) { oceanCamera.TaskController.OnPreRefractionRender(oceanCamera); renderCamera.SetTargetBuffers(colorRenderTexture.colorBuffer, depthRenderTexture.depthBuffer); renderCamera.Render(); renderCamera.targetTexture = null; oceanCamera.TaskController.OnPostRefractionRender(oceanCamera); } RefractionTexture = colorRenderTexture; RefractionDepthTexture = depthRenderTexture; }
public void SetValueToShader(OceanCameraTask oceanCamera, FoamCameraData data, PreparedContent preparedContent) { if (ProjectSettings.Current.Foam.EnabledFoamShpereCulling) { if ((preparedContent & PreparedContent.Foam16) != 0) { SetValueToShader(oceanCamera, data, 16, 4); } else if ((preparedContent & PreparedContent.Foam8) != 0) { SetValueToShader(oceanCamera, data, 8, 2); } } }