question

MihaiFloares-4605 avatar image
0 Votes"
MihaiFloares-4605 asked XiaopoYang-MSFT edited

SharpDX Load bmp and send to pixel shader to sample it

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









dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers