private void CreateResources() { _mainCamera = GetComponent <Camera>(); _preComposeMaterial = HelperExtensions.CreateMaterialFromShader("Sleek Render/Post Process/PreCompose"); _composeMaterial = HelperExtensions.CreateMaterialFromShader("Sleek Render/Post Process/Compose"); _currentCameraPixelWidth = Mathf.RoundToInt(_mainCamera.pixelWidth); _currentCameraPixelHeight = Mathf.RoundToInt(_mainCamera.pixelHeight); // Point for future main render target size changing int width = _currentCameraPixelWidth; int height = _currentCameraPixelHeight; // Capping max base texture height in pixels // We usually don't need extra pixels for precompose and blur passes var maxHeight = Mathf.Min(height, 720); var ratio = (float)maxHeight / height; int precomposeWidth = Mathf.RoundToInt((width * ratio) / 5f); int precomposeHeight = Mathf.RoundToInt((height * ratio) / 5f); _preComposeTexture = HelperExtensions.CreateTransientRenderTexture("Pre Compose", precomposeWidth, precomposeHeight); _composeMaterial.SetTexture(Uniforms._PreComposeTex, _preComposeTexture); _composeMaterial.SetVector(Uniforms._LuminanceConst, new Vector4(0.2126f, 0.7152f, 0.0722f, 0f)); _isColorizeAlreadyEnabled = false; _isBloomAlreadyEnabled = false; _isVignetteAlreadyEnabled = false; _isContrastAndBrightnessAlreadyEnabled = false; _passRenderer = _passRenderer ?? new PassRenderer(); if (_bloomRenderer != null) { _bloomRenderer.ReleaseResources(); } _bloomRenderer = new DualFilterBloomRenderer(_passRenderer); _bloomRenderer.CreateResources(settings, _mainCamera); }
public DualFilterBloomRenderer(PassRenderer renderer) { _renderer = renderer; }