private void RenderObstacles() { ConfigLightCamera(true); var oldColor = LightCamera.backgroundColor; var oldClearFlag = LightCamera.clearFlags; LightCamera.enabled = false; LightCamera.targetTexture = _obstaclesUpsampledTexture; LightCamera.cullingMask = 1 << LightObstaclesLayer; LightCamera.backgroundColor = new Color(1, 1, 1, 0); //normal _obstaclesPostProcessor.DrawMesh(LightCamera, LightObstaclesAntialiasing ? 2 : 1); LightCamera.Render(); //replacement LightCamera.clearFlags = CameraClearFlags.Nothing; LightCamera.cullingMask = LightObstaclesReplacementShaderLayer; LightCamera.RenderWithShader(_lightBlockerReplacementShader, "RenderType"); LightCamera.targetTexture = null; LightCamera.cullingMask = 0; LightCamera.backgroundColor = oldColor; LightCamera.clearFlags = oldClearFlag; _obstaclesTexture.DiscardContents(); Graphics.Blit(_obstaclesUpsampledTexture, _obstaclesTexture); }
private void RenderObstacles() { ConfigLightCamera(true); var oldColor = LightCamera.backgroundColor; LightCamera.enabled = false; LightCamera.targetTexture = _obstaclesUpsampledTexture; LightCamera.cullingMask = 1 << LightObstaclesLayer; LightCamera.backgroundColor = new Color(1, 1, 1, 0); _obstaclesPostProcessor.DrawMesh(LightCamera, LightObstaclesAntialiasing ? 2 : 1); LightCamera.Render(); LightCamera.targetTexture = null; LightCamera.cullingMask = 0; LightCamera.backgroundColor = oldColor; _obstaclesTexture.DiscardContents(); Graphics.Blit(_obstaclesUpsampledTexture, _obstaclesTexture); }