Created
April 3, 2021 00:46
-
-
Save bzgeb/7b1d7cec570b6c8f5a23153d5cbde576 to your computer and use it in GitHub Desktop.
HDRP Fullscreen Blit with Command Buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.Rendering.HighDefinition; | |
public class HdrpFullscreenBlit : MonoBehaviour | |
{ | |
public Texture Source; | |
void OnEnable() | |
{ | |
var cameraData = GetComponent<HDAdditionalCameraData>(); | |
cameraData.customRender += BlitPass; | |
} | |
void OnDisable() | |
{ | |
var cameraData = GetComponent<HDAdditionalCameraData>(); | |
cameraData.customRender -= BlitPass; | |
} | |
void BlitPass(ScriptableRenderContext context, HDCamera hdCamera) | |
{ | |
var cameraTarget = hdCamera.camera.targetTexture; | |
var command = CommandBufferPool.Get(); | |
command.Blit(Source, cameraTarget); | |
context.ExecuteCommandBuffer(command); | |
command.Release(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment