Created
June 17, 2015 07:16
-
-
Save peroon/4b217b16a32a427ab0b4 to your computer and use it in GitHub Desktop.
カラーバスシェーダ。赤が強いところだけカラーにする
This file contains 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
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