PPDownsample.bsl 1.2 KB

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