Skip to content

Instantly share code, notes, and snippets.

@peroon
Created June 17, 2015 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peroon/4b217b16a32a427ab0b4 to your computer and use it in GitHub Desktop.
Save peroon/4b217b16a32a427ab0b4 to your computer and use it in GitHub Desktop.
カラーバスシェーダ。赤が強いところだけカラーにする
Shader "Custom/ColorBathRed" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Threshold( "Threshold", Range(0.0, 1.0) ) = 0.5 // added
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _Threshold; // added
fixed4 frag(v2f_img i) : SV_Target {
float4 c = tex2D(_MainTex, i.uv);
// 赤色が強い箇所はそのままの色で描画
if(c.r - c.g > _Threshold && c.r - c.b > _Threshold){
return c;
}
else{
float g = (c.r+c.g+c.b)/3;
return float4(g,g,g,1);
}
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment