다음을 통해 공유


3D 조회 테이블 효과

3D 조회 테이블은 효과가 모든 입력 값의 하위 집합에 대한 출력에 입력을 매핑하는 방법을 미리 계산하여 1:1 이미징 효과를 캡슐화하는 데 사용되는 범용 효과입니다.

3D LUT(Lookup Table) 효과는 이미지의 RGB 색 값을 사용하여 입력 이미지를 수정하여 3D 텍스처를 인덱싱합니다. 여기서 텍스처에는 임의 효과 파이프라인의 미리 계산된 출력 값이 포함됩니다.

렌더링하려면 3D LUT를 GPU 텍스처 리소스에 로드해야 하며 텍스처 크기와 디바이스 기능에 따라 비용이 많이 들 수 있습니다. 애플리케이션 개발자는 ID2D1LookupTable3D D2D 리소스를 사용하여 이 비용을 지불할 시기를 지정할 수 있습니다. ID2D1LookupTable3D 에는 다음과 같은 특성이 있습니다.

  • 3D LUT의 GPU 리소스에 대한 추상화된 표현을 제공합니다.
  • 디바이스 기능에 따라 2D 또는 3D 텍스처가 만들어지고 제공된 LUT 데이터로 채워집니다.
  • 렌더링을 위해 3D LUT 효과의 속성에 전달할 수 있습니다.

이 효과에 대한 CLSID는 CLSID_D2D1LookupTable3D.

예제 이미지

효과 출력의 예

예제 코드

//
    // 1. Generate the lookup table data and create an ID2D1LookupTable3D.
    //
 
    // Create a 16x16x16 LUT of arbitrary data type T.
    UINT extents[] = { 16, 16, 16 };
    UINT cElements = extents[0] * extents[1] * extents[2] * 4;
    UINT cbElements = cElements * formatSize;
 
    // Compute the step size in each direction to vary the RGB 
    // channels uniformly over the range [0, 1]
    float steps[] = 
    { 
        1.0f / static_cast<float>(extents[0] - 1),
        1.0f / static_cast<float>(extents[1] - 1),
        1.0f / static_cast<float>(extents[2] - 1),
    };
 
    CArray<BYTE> lutData;
    IFR(lutData.Resize(cbElements));
 
    T* pData = reinterpret_cast<T *>(lutData.GetData());
    T oneValue = ConvertValue<T>(1.0f);
    
    // Generate the LUT by applying an imaging pipeline to RGB values.
    for (UINT iR = 0; iR < extents[2]; iR++)
    {
        for (UINT iG = 0; iG < extents[1]; iG++)
        {
            for (UINT iB = 0; iB < extents[0]; iB++)
            {
                T outputColor[3];
                ApplyPipeline(iR * steps[2], iG * steps[1], iB * steps[0], &outputColor);
 
                pData[0] = outColor[0];
                pData[1] = outColor[1];
                pData[2] = outColor[2];
 
                // Set opaque alpha in the output
                pData[3] = oneValue;
 
                // Advance the pointer
                pData += sizeof(T) * 4;
            }
        }
    }
    
    // Compute the strides of the LUT data.
    UINT strides[2];
    IFR(UIntMult(sizeof(T) * 4, extents[0], &strides[0]));
    IFR(UIntMult(strides[0], extents[1], &strides[1]));
    
    D2D1_BUFFER_PRECISION precision = GetBufferPrecision<T>();
 
    // Create an ID2D1LookupTable3D from the LUT data.
    CComPtr<ID2D1LookupTable3D> sp3dLut;
    IFR(_spEffectContext1->CreateLookupTable3D(
        precision,
        extents,
        lutData.GetData(),
        lutData.GetCount(),
        strides,
        &sp3dLut
        )); 
 
    //
    // 2. To apply the lookup table to an input image, create a LookupTable3D effect
    //    and pass the ID2D1LookupTable3D to the effect as a property.
    //
 
    // Create a 3D LUT effect to render our LUT.
    CComPtr<ID2D1Effect> sp3dLutEffect;
    IFR(pEffectContext->CreateEffect(CLSID_D2D1LookupTable3D, &sp3dLutEffect)); 
 
    // Set the LUT as a property on the effect.
    IFR(sp3dLutEffect->SetValue(D2D1_LOOKUPTABLE3D_PROP_LUT, _spLut));

효과 속성

3D 조회 테이블 효과의 속성은 D2D1_LOOKUPTABLE3D_PROP 열거형으로 정의됩니다.

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 10 [데스크톱 앱 | Windows 스토어 앱]
지원되는 최소 서버 Windows 10 [데스크톱 앱 | Windows 스토어 앱]
헤더 d2d1effects_2.h
라이브러리 d2d1.lib, dxguid.lib