BloomExtract.fx 681 B

1234567891011121314151617181920212223242526272829
  1. // Pixel shader extracts the brighter areas of an image.
  2. // This is the first step in applying a bloom postprocess.
  3. #include "Macros.hlsl"
  4. DECLARE_TEXTURE(TextureSampler, 0);
  5. BEGIN_CONSTANTS
  6. float BloomThreshold;
  7. END_CONSTANTS
  8. float4 PixelShaderF(float2 texCoord : TEXCOORD0) : COLOR0
  9. {
  10. // Look up the original image color.
  11. float4 c = SAMPLE_TEXTURE(TextureSampler, texCoord);
  12. // Adjust it to keep only values brighter than the specified threshold.
  13. return saturate((c - BloomThreshold) / (1 - BloomThreshold));
  14. }
  15. technique BloomExtract
  16. {
  17. pass Pass1
  18. {
  19. PixelShader = compile PS_SHADERMODEL PixelShaderF();
  20. }
  21. }