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(); } }
private static void NotifyObservers(List <IObserver <CameraTaskEvent> > observers, CameraTaskEvent eventValue) { foreach (var observer in observers) { try { observer.OnNext(eventValue); } catch (Exception ex) { observer.OnError(ex); } } }