FlatFramebufferToTexture.bsl 945 B

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