PPDownsample.bsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. Language = "HLSL11";
  15. Pass =
  16. {
  17. Fragment =
  18. {
  19. cbuffer Input
  20. {
  21. float2 gInvTexSize;
  22. }
  23. SamplerState gInputSamp;
  24. Texture2D gInputTex;
  25. float4 main(VStoFS input) : SV_Target0
  26. {
  27. float2 UV[4];
  28. // Blur using a 4x4 kernel. It's assumed current position is right in the middle of a 2x2 kernel (because the output
  29. // texture should be 1/2 the size of the output texture), and moving by one in each direction will sample areas
  30. // between a 2x2 kernel as well if bilinear filtering is enabled.
  31. UV[0] = input.uv0 + gInvTexSize * float2(-1, -1);
  32. UV[1] = input.uv0 + gInvTexSize * float2( 1, -1);
  33. UV[2] = input.uv0 + gInvTexSize * float2(-1, 1);
  34. UV[3] = input.uv0 + gInvTexSize * float2( 1, 1);
  35. float4 sample[4];
  36. for(uint i = 0; i < 4; i++)
  37. sample[i] = gInputTex.Sample(gInputSamp, UV[i]);
  38. return (sample[0] + sample[1] + sample[2] + sample[3]) * 0.25f;
  39. }
  40. };
  41. };
  42. };
  43. Technique : inherits("PPBase") =
  44. {
  45. Language = "GLSL";
  46. Pass =
  47. {
  48. Fragment =
  49. {
  50. // TODO
  51. };
  52. };
  53. };