SharpDX Load bmp and send to pixel shader to sample it

Started by
0 comments, last by bogdan7 2 years, 8 months ago

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 vertexShader.hlsl:

#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 pixelShader.hlsl:

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;
}

This topic is closed to new replies.

Advertisement