Condividi tramite


Effetto tabella di ricerca 3D

Una tabella di ricerca 3D è un effetto generico che viene usato per incapsulare qualsiasi effetto di creazione immagine 1:1 precalcando il modo in cui l'effetto esegue il mapping degli input agli output per un subset di tutti i valori di input.

L'effetto LUT (LUT) 3D Lookup Table modifica un'immagine di input usando il valore di colore RGB dell'immagine per indicizzare una trama 3D, in cui la trama contiene un valore di output precompiuto di una pipeline di effetti arbitrari.

Il valore LUT 3D deve essere caricato in una risorsa trama GPU per poter essere sottoposto a rendering e questo può essere costoso a seconda delle dimensioni della trama e delle funzionalità del dispositivo. Gli sviluppatori di applicazioni possono specificare quando pagare questo costo usando la risorsa ID2D1LookupTable3D D2D . ID2D1LookupTable3D ha gli attributi seguenti:

  • Fornisce una rappresentazione astratta della risorsa GPU di 3D LUT.
  • A seconda delle funzionalità del dispositivo, verrà creata una trama 2D o 3D e compilata con i dati LUT forniti.
  • Può essere passato alla proprietà dell'effetto LUT 3D per il rendering.

Il CLSID per questo effetto è CLSID_D2D1LookupTable3D.

Immagine di esempio

esempio di output dell'effetto

Codice di esempio

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

Proprietà dell'effetto

Le proprietà per l'effetto tabella di ricerca 3D sono definite dall'enumerazione D2D1_LOOKUPTABLE3D_PROP .

Requisiti

Requisito Valore
Client minimo supportato Windows 10 [app desktop | App di Windows Store]
Server minimo supportato Windows 10 [app desktop | App di Windows Store]
Intestazione d2d1effects_2.h
Libreria d2d1.lib, dxguid.lib