Bagikan melalui


Efek tabel pencarian 3D

Tabel pencarian 3D adalah efek tujuan umum yang digunakan untuk merangkum efek pencitraan 1:1 dengan melakukan pra-komputasi bagaimana efek memetakan input ke output untuk subset semua nilai input.

Efek Tabel Pencarian 3D (LUT) memodifikasi gambar input dengan menggunakan nilai warna RGB gambar untuk mengindeks tekstur 3D, di mana tekstur berisi nilai output yang telah dikomputasi dari alur efek arbitrer.

LUT 3D harus dimuat ke dalam sumber daya tekstur GPU agar dapat dirender, dan ini bisa mahal tergantung pada ukuran tekstur dan kemampuan perangkat. Pengembang aplikasi dapat menentukan kapan harus membayar biaya ini menggunakan sumber daya ID2D1LookupTable3D D2D. ID2D1LookupTable3D memiliki atribut berikut:

  • Menyediakan representasi abstrak dari sumber daya GPU 3D LUT.
  • Bergantung pada kemampuan perangkat, tekstur 2D atau 3D akan dibuat dan diisi dengan data LUT yang disediakan.
  • Dapat diteruskan ke properti efek LUT 3D untuk penyajian.

CLSID untuk efek ini CLSID_D2D1LookupTable3D.

Contoh gambar

contoh output efek

Kode sampel

//
    // 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));

Properti efek

Properti untuk efek tabel pencarian 3D ditentukan oleh enumerasi D2D1_LOOKUPTABLE3D_PROP .

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung Windows 10 [aplikasi desktop | Aplikasi Bursa Windows]
Server minimum yang didukung Windows 10 [aplikasi desktop | Aplikasi Bursa Windows]
Header d2d1effects_2.h
Pustaka d2d1.lib, dxguid.lib