testgpurender_effects_grayscale.frag.hlsl 500 B

12345678910111213141516171819
  1. Texture2D u_texture : register(t0, space2);
  2. SamplerState u_sampler : register(s0, space2);
  3. struct PSInput {
  4. float4 v_color : COLOR0;
  5. float2 v_uv : TEXCOORD0;
  6. };
  7. struct PSOutput {
  8. float4 o_color : SV_Target;
  9. };
  10. PSOutput main(PSInput input) {
  11. PSOutput output;
  12. float4 color = u_texture.Sample(u_sampler, input.v_uv) * input.v_color;
  13. float gray = color.r * 0.299 + color.g * 0.587 + color.r * 0.114;
  14. output.o_color = float4(gray, gray, gray, color.a);
  15. return output;
  16. }