Skip to content

Instantly share code, notes, and snippets.

@EsProgram
Created September 6, 2015 14:51
Show Gist options
  • Save EsProgram/b5a03832807fc4ac539a to your computer and use it in GitHub Desktop.
Save EsProgram/b5a03832807fc4ac539a to your computer and use it in GitHub Desktop.
Shader "Custom/GrayScaleVF" {
Properties{
_MainTex("Main", 2D) = "white" {}
}
SubShader{
Lighting Off
Pass{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 frag(v2f_img i) :COLOR{
float4 tex_col = tex2D(_MainTex, i.uv);
//NTSC Coef. methodによるグレースケーリング
tex_col.rgb = (2 * tex_col.r + 4 * tex_col.g + tex_col.b) / 7;
return tex_col;
}
ENDCG
}
}
}
@EsProgram
Copy link
Author

グレースケールするシェーダ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment