Last active
August 15, 2026 04:45
-
-
Save amirrajan/6894f307efe04227a019f155812c0ad9 to your computer and use it in GitHub Desktop.
gray scale shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Texture2D tex_scene : register(t0, space2); | |
| SamplerState sam_scene : register(s0, space2); | |
| struct Input { | |
| float4 tex_color : COLOR0; | |
| float2 tex_coord : TEXCOORD0; | |
| }; | |
| struct Output { | |
| float4 frag_color : SV_Target; | |
| }; | |
| Output main(Input input) { | |
| Output output; | |
| float4 color = tex_scene.Sample(sam_scene, input.tex_coord) * input.tex_color; | |
| // https://en.wikipedia.org/wiki/Grayscale | |
| float4 luma = dot(color.rgb, float3(0.2126, 0.7152, 0.0722)); | |
| output.frag_color = float4(luma.r, luma.g, luma.b, color.a); | |
| return output; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment