PPDownsample.bsl 1.1 KB

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