FlatFramebufferToTexture.bsl 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Technique =
  2. {
  3. Pass =
  4. {
  5. DepthRead = false;
  6. DepthWrite = false;
  7. Common =
  8. {
  9. struct VStoFS
  10. {
  11. float4 position : SV_POSITION;
  12. float2 uv0 : TEXCOORD0;
  13. };
  14. };
  15. Vertex =
  16. {
  17. struct VertexInput
  18. {
  19. float2 screenPos : POSITION;
  20. float2 uv0 : TEXCOORD0;
  21. };
  22. VStoFS main(VertexInput input)
  23. {
  24. VStoFS output;
  25. output.position = float4(input.screenPos, 0, 1);
  26. output.uv0 = input.uv0;
  27. return output;
  28. }
  29. };
  30. Fragment =
  31. {
  32. cbuffer Params : register(b0)
  33. {
  34. uint2 gFramebufferSize;
  35. uint gSampleCount;
  36. }
  37. Buffer<float4> gInput : register(t0);
  38. uint getLinearAddress(uint2 coord, uint sampleIndex)
  39. {
  40. return (coord.y * gFramebufferSize.x + coord.x) * gSampleCount + sampleIndex;
  41. }
  42. float4 main(VStoFS input, uint sampleIndex : SV_SampleIndex) : SV_Target0
  43. {
  44. int2 pixelPos = trunc(input.uv0);
  45. uint sourceIdx = getLinearAddress(pixelPos, sampleIndex);
  46. return gInput[sourceIdx];
  47. }
  48. };
  49. };
  50. };