{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} 커스텀 패스 유틸리티 API 사용자 매뉴얼 | High Definition RP | 10.5.0
docs.unity3d.com
"{0}"의 검색 결과

    목차 표시/숨기기

    커스텀 패스 유틸리티 API 사용자 매뉴얼

    블러

    가우시안 블러

    가우시안 블러 함수를 사용하여 임의 반지름과 품질(샘플의 개수)로 이미지를 흐리게 할 수 있습니다. 성능상의 이유로 패스를 다운샘플링한 후 블러 커널을 실행할 수 있습니다. 이는 블러 효과의 리소스 소모량을 감소시킬 뿐 아니라 품질도 저하됩니다.

    다음은 카메라 컬러 버퍼를 흐리게 하는 커스텀 패스 예시입니다.

    using UnityEngine;
    using UnityEngine.Rendering.HighDefinition;
    using UnityEngine.Rendering;
    using UnityEngine.Experimental.Rendering;
    
    class GaussianBlur : CustomPass
    {
        RTHandle    halfResTarget;
    
        protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
        {
            halfResTarget = RTHandles.Alloc(
                // Note the * 0.5f here. This allocates a half-resolution target, which saves a lot of memory.
                Vector2.one * 0.5f, TextureXR.slices, dimension: TextureXR.dimension,
                // Since alpha is unnecessary for Gaussian blur, this effect uses an HDR texture format with no alpha channel.
                colorFormat: GraphicsFormat.B10G11R11_UFloatPack32,
                // When creating textures, be sure to name them as it is useful for debugging.
                useDynamicScale: true, name: "Half Res Custom Pass"
            );
        }
    
        protected override void Execute(CustomPassContext ctx)
        {
            // Specifies the radius for the blur in pixels. This example uses an 8 pixel radius.
            float radius = 8.0f;
            // Specifies the precision of the blur. This also affects the resource intensity of the blue. A value of 9 is good for real-time applications.
            int sampleCount = 9;
    
            // In cases where you have multiple cameras with different resolutions, this makes the blur coherent across these cameras.
            radius *= ctx.cameraColorBuffer.rtHandleProperties.rtHandleScale.x;
    
            // The actual Gaussian blur call. It specifies the current camera's color buffer as the source and destination.
            // This uses the half-resolution target as a temporary render target between the blur passes.
            // Note that the Gaussian blur function clears the content of the half-resolution buffer when it finishes.
            CustomPassUtils.GaussianBlur(
                ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, halfResTarget,
                sampleCount, radius, downSample: true
            );
        }
    
        // Releases the GPU memory allocated for the half-resolution target. This is important otherwise the memory will leak.
        protected override void Cleanup() => halfResTarget.Release();   
    }
    

    이 예시는 먼저 다운샘플링한 패스를 처리하므로 절반 해상도 타겟인 halfResTarget을 사용합니다. 또는 HDRP에서 제공하는 커스텀 패스 버퍼를 사용할 수도 있습니다. 이 버퍼가 절반 해상도 버퍼는 아니지만 알고리즘이 텍스처의 절반만 사용합니다.

    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)