premultiplied_alpha.effect 657 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. uniform float4x4 ViewProj;
  2. uniform texture2d image;
  3. sampler_state def_sampler {
  4. Filter = Linear;
  5. AddressU = Clamp;
  6. AddressV = Clamp;
  7. };
  8. struct VertInOut {
  9. float4 pos : POSITION;
  10. float2 uv : TEXCOORD0;
  11. };
  12. VertInOut VSDefault(VertInOut vert_in)
  13. {
  14. VertInOut vert_out;
  15. vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
  16. vert_out.uv = vert_in.uv;
  17. return vert_out;
  18. }
  19. float4 PSDraw(VertInOut vert_in) : TARGET
  20. {
  21. float4 rgba = image.Sample(def_sampler, vert_in.uv);
  22. if (rgba.a > 0.0)
  23. rgba.rgb /= rgba.a;
  24. return saturate(rgba);
  25. }
  26. technique Draw
  27. {
  28. pass
  29. {
  30. vertex_shader = VSDefault(vert_in);
  31. pixel_shader = PSDraw(vert_in);
  32. }
  33. }