SharpDX Load bmp and send to pixel shader to sample it

Mihai Floares 1 Reputation point
2021-09-15T05:14:39.537+00:00

I have a bmp and I want to texture a mesh with it.I calculated the uvs for the mesh and sent them to vertex shader.I have no idea how to take the data from.bmp file and send it to pixel shader.
Bitmap bitmap = new Bitmap(texturePath);

The vertex shader:

  #pragma pack_matrix( row_major )
        cbuffer const_buffer : register(b0) {
        float4x4 object;
        float4x4 view;
        float4x4 proj;

    };

    struct VS_INPUT {
     float3 pos : POSITION;
     float2 uvs : TEXCOORD0;

    };
    struct VS_OUTPUT { //PS_INPUT
     float4 pos : SV_POSITION;
     float2 uvs : TEXCOORD0;

    };
    VS_OUTPUT main(VS_INPUT input)
    {
     VS_OUTPUT output;
     float4x4 OVP = mul(mul(object, view), proj);
     float4 position = float4(input.pos, 1);


     output.uvs = input.uvs;
     output.pos = mul(position, OVP);


     return output;
    }

The pixel shader:
Texture2D texture0; //how to receive the bmp here?
SamplerState SampleType;

struct PS_INPUT { //VS_OUTPUT
 float4 pos : SV_POSITION;
 float2 uvs : TEXCOORD0;

};
struct PS_OUTPUT {
 float4 color : SV_TARGET;

};


PS_OUTPUT main(PS_INPUT input)
{
 PS_OUTPUT output;
 output.color = texture0.Sample(SampleType, input.uvs);
 return output;
}
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,204 questions
0 comments No comments
{count} votes