private void RenderObstacles() { ConfigLightCamera(true); Color oldColor = lightCamera.backgroundColor; CameraClearFlags 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); Color 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); }