Question

I am wondering how to actually sample the data I am passing to the shader file. I am using two methods, is it the same for both? Are there any resources online for me to actually read up on this sort of thing?

Compiling at 5.0 but the version number does not matter so much.


I have two methods to pass the data.

The first;

    for( UINT row = 0; row < textureDesc.Height; row++ )
    {
        UINT rowStart = row * mappedResource.RowPitch;
        for( UINT col = 0; col < textureDesc.Width; col++ )
        {
            //width * number of channels (r,g,b,a)
            UINT colStart = col * 4;
            pTexels[rowStart + colStart + 0] = 10.0f; // Red
            pTexels[rowStart + colStart + 1] = 10.0f; // Green
            pTexels[rowStart + colStart + 2] = 255.0f; // Blue
            pTexels[rowStart + colStart + 3] = 255.0f; // Alpha
        }
    }

The second;

    float elements[416][416];
    int elementsCount = 416*416;

    for( int i = 0; i < 416; i++ )
    {
        for( int k = 0; k < 416; k++ )
        {
            elements[i][k] = 0;
        }
    }

    memcpy(mappedResource.pData, elements, sizeof(float) * elementsCount);
Was it helpful?

Solution

Seems that I missed an important part of all of this.

When creating a texture, in the texture description, the Format is the type that will be returned when the object is sampled. Many thanks to Drop for the help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top