HardLight
Смешиваем две текстуры:
Синтаксис:
Используется glsl
Shader "BlendAdvanced/HardLight" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_BlendTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _BlendTex;
struct Input {
float2 uv_MainTex;
float2 uv_BlendTex;
//TODO: add 2nd uv channel
};
half HardLight(half B, half L)
{
return (L < 0.5) ? (2 * B * L):(1.0 - 2 * (1.0 - B) * (1.0 - L));
}
void surf (Input IN, inout SurfaceOutput o) {
half4 base = tex2D (_MainTex, IN.uv_MainTex);
half4 blend = tex2D (_BlendTex, IN.uv_BlendTex);
half red = HardLight(blend.r, base.r);
half green = HardLight(blend.g, base.g);
half blue = HardLight(blend.b, base.b);
half3 result = half3(red, green, blue);
o.Albedo = result.rgb;
o.Alpha = base.a;
}
ENDCG
}
FallBack "Diffuse"
}
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_BlendTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _BlendTex;
struct Input {
float2 uv_MainTex;
float2 uv_BlendTex;
//TODO: add 2nd uv channel
};
half HardLight(half B, half L)
{
return (L < 0.5) ? (2 * B * L):(1.0 - 2 * (1.0 - B) * (1.0 - L));
}
void surf (Input IN, inout SurfaceOutput o) {
half4 base = tex2D (_MainTex, IN.uv_MainTex);
half4 blend = tex2D (_BlendTex, IN.uv_BlendTex);
half red = HardLight(blend.r, base.r);
half green = HardLight(blend.g, base.g);
half blue = HardLight(blend.b, base.b);
half3 result = half3(red, green, blue);
o.Albedo = result.rgb;
o.Alpha = base.a;
}
ENDCG
}
FallBack "Diffuse"
}
"Свой" лайтмап:
Синтаксис:
Используется glsl
Shader "LightmapAdvanced/HardLight2" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
struct Input {
float2 uv_MainTex;
float2 uv2_Illum;
//TODO: add 2nd uv channel
};
half HardLight(half B, half L)
{
return (L < 0.5) ? (2 * B * L):(1.0 - 2 * (1.0 - B) * (1.0 - L));
}
void surf (Input IN, inout SurfaceOutput o) {
half4 base = tex2D (_MainTex, IN.uv_MainTex);
half4 blend = tex2D(_Illum, IN.uv2_Illum);
half red = HardLight(blend.r, base.r);
half green = HardLight(blend.g, base.g);
half blue = HardLight(blend.b, base.b);
half3 result = half3(red, green, blue);
o.Albedo = base.rgb;
o.Emission = result.rgb;
o.Alpha = base.a;
}
ENDCG
}
FallBack "Diffuse"
}
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
struct Input {
float2 uv_MainTex;
float2 uv2_Illum;
//TODO: add 2nd uv channel
};
half HardLight(half B, half L)
{
return (L < 0.5) ? (2 * B * L):(1.0 - 2 * (1.0 - B) * (1.0 - L));
}
void surf (Input IN, inout SurfaceOutput o) {
half4 base = tex2D (_MainTex, IN.uv_MainTex);
half4 blend = tex2D(_Illum, IN.uv2_Illum);
half red = HardLight(blend.r, base.r);
half green = HardLight(blend.g, base.g);
half blue = HardLight(blend.b, base.b);
half3 result = half3(red, green, blue);
o.Albedo = base.rgb;
o.Emission = result.rgb;
o.Alpha = base.a;
}
ENDCG
}
FallBack "Diffuse"
}
Если поменять местами blend\base получится overlay.
Результат вроде не совсем похож на то что получается в фотошопе - поэтому если кто-то найдет косяк, буду рад .