您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

67 行
1.2 KiB

Shader "Hidden/ContrastComposite" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
_MainTexBlurred ("Base Blurred (RGB)", 2D) = "" {}
}
// Shader code pasted into all further CGPROGRAM blocks
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _MainTexBlurred;
float4 _MainTex_TexelSize;
float intensity;
float threshhold;
v2f vert( appdata_img v ) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv[0] = v.texcoord.xy;
o.uv[1] = v.texcoord.xy;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv[0].y = 1-o.uv[0].y;
#endif
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D (_MainTex, i.uv[1]);
half4 blurred = tex2D (_MainTexBlurred, (i.uv[0]));
half4 difff = color - blurred;
half4 signs = sign (difff);
difff = saturate ( (color-blurred) - threshhold) * signs * 1.0/(1.0-threshhold);
color += difff * intensity;
return color;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader