PPDownsample.bsl 973 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "$ENGINE$\PPBase.bslinc"
  2. technique PPDownsample
  3. {
  4. mixin PPBase;
  5. code
  6. {
  7. [internal]
  8. cbuffer Input
  9. {
  10. float2 gInvTexSize;
  11. }
  12. SamplerState gInputSamp;
  13. Texture2D gInputTex;
  14. float4 fsmain(VStoFS input) : SV_Target0
  15. {
  16. float2 UV[4];
  17. // Blur using a 4x4 kernel. It's assumed current position is right in the middle of a 2x2 kernel (because the output
  18. // texture should be 1/2 the size of the output texture), and moving by one in each direction will sample areas
  19. // between a 2x2 kernel as well if bilinear filtering is enabled.
  20. UV[0] = input.uv0 + gInvTexSize * float2(-1, -1);
  21. UV[1] = input.uv0 + gInvTexSize * float2( 1, -1);
  22. UV[2] = input.uv0 + gInvTexSize * float2(-1, 1);
  23. UV[3] = input.uv0 + gInvTexSize * float2( 1, 1);
  24. float4 samples[4];
  25. for(uint i = 0; i < 4; i++)
  26. samples[i] = gInputTex.Sample(gInputSamp, UV[i]);
  27. return (samples[0] + samples[1] + samples[2] + samples[3]) * 0.25f;
  28. }
  29. };
  30. };