Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.

Commit 7cd510f

Browse files
committed
update to v1.2
- Add Indirect Static Max:Min color ratio control - Add Indirect Directionality Mix - Add Indirect Directionality Blur - Add Matcap DIffuse multiply with MainTex mix - Add emission tint from MainTex (RGBA) - Add emission mask from MainTex (A) - Raise #pragma target 5.0 - Reorganized properties and change defaults - Internal GUI change
1 parent 23d321a commit 7cd510f

8 files changed

+195
-25
lines changed

Assets/shaders/aciil/ACLS/ACLS_CORE.cginc

+48-16
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,19 @@
148148
// uniform float _Occlusion_Rim;
149149
// uniform float _Occlusion_MatAdd;
150150
uniform int _ToonRampLightSourceType_Backwards;
151+
uniform half _diffuseIndirectDirectSimMix;
151152
uniform int _UseSpecularSystem;
152153
uniform float3 _backFaceColorTint;
153154
uniform float4 _SpecularMaskHSV;
154155
uniform int _forceLightClamp;
155156
uniform float _rimAlbedoMix;
156157
uniform float _directLightIntensity;
158+
uniform half _McDiffAlbedoMix;
159+
uniform half _indirectAlbedoMaxAveScale;
160+
uniform half _indirectGIDirectionalMix;
161+
uniform half _indirectGIBlur;
162+
uniform half _emissiveUseMainTexA;
163+
uniform half _emissiveUseMainTexCol;
157164

158165

159166

@@ -576,7 +583,7 @@
576583
float dynamicShadowMask = _DynamicShadowMask.SampleGrad(sampler_MainTex_trilinear_repeat, uv_toon.uv, uv_toon.dx, uv_toon.dy).g;
577584
float tmp = max(_shadowCastMin_black, dynamicShadowMask);
578585
shadowBlackness = saturate( (shadowAttenuation + tmp)/(1 - tmp));
579-
shadowMinPotential = saturate( (_LightShadowData.x + tmp)/(1 - tmp));
586+
// shadowMinPotential = saturate( (_LightShadowData.x + tmp)/(1 - tmp));
580587
} else
581588
{
582589
shadowBlackness = shadowAttenuation;
@@ -587,24 +594,37 @@
587594

588595
//// collect scene light sources
589596
#ifdef UNITY_PASS_FORWARDBASE
597+
//// build indirect light source
590598
float3 lightIndirectColAve = DecodeLightProbe_average(); //// average light from raw L0
591-
float3 lightIndirectMaxCol = SHEvalDirectL1(float4(i.dirGI,1)); //// direct most light raw L1
592-
float3 lightIndirectAngCol = shadeSH9LinearAndWhole(float4(i.wNormal,1)); //// All GI from direction and fixed for no negatives
593-
// float scaleGIL0L1 = saturate(LinearRgbToLuminance_ac(lightIndirectMaxCol) / (LinearRgbToLuminance_ac(lightIndirectColAve) + 0.00001) * .9);
594-
float scaleGIL0L1 = saturate(LinearRgbToLuminance_ac(lightIndirectMaxCol) - (LinearRgbToLuminance_ac(lightIndirectColAve)).xxx + 0.00001) * 1;
595-
float3 lightIndirectCol = lerp(lightIndirectMaxCol, lightIndirectColAve, scaleGIL0L1);
596-
//// build direct light sources
597-
float3 lightDirect = _LightColor0.rgb;
598-
float3 lightDirectSave = lightDirect;
599+
float3 lightIndirectColMax = SHEvalDirectL1(float4(i.dirGI,1)); //// direct most light raw L1
600+
float3 lightIndirectColStatic = 0, lightIndirectColDir = 0;
601+
if ((_indirectGIDirectionalMix) < 1)
602+
{
603+
half GI_Max = LinearRgbToLuminance_ac(lightIndirectColMax), GI_Ave = LinearRgbToLuminance_ac(lightIndirectColAve);
604+
half GI_MaxAveDif = ((GI_Max * _indirectAlbedoMaxAveScale) - GI_Ave);
605+
half GI_MaxAveSum = GI_Max + GI_Ave;
606+
half GI_MaxAveRatio = saturate(GI_MaxAveDif / GI_MaxAveSum);
607+
lightIndirectColStatic = lerp(lightIndirectColMax, lightIndirectColAve, GI_MaxAveRatio);
608+
}
609+
if (_indirectGIDirectionalMix > 0)
610+
{
611+
float4 indirectGIDirectionBlur = float4(i.wNormal, (_indirectGIBlur + 0.001) );
612+
lightIndirectColDir = max(0, ShadeSH9_ac(indirectGIDirectionBlur)) / (indirectGIDirectionBlur.w);
613+
// float3 lightIndirectColAngle = shadeSH9LinearAndWhole(float4(i.wNormal,1)); //// not blur adaptiable without intense math
614+
}
615+
float3 lightIndirectCol = lerp(lightIndirectColStatic, lightIndirectColDir, _indirectGIDirectionalMix);
616+
//// build direct light source
617+
float3 lightDirect = _LightColor0.rgb;
618+
float3 lightDirectSave = lightDirect;
599619
//// build ambient LUM for reflection types
600620
float lightAverageLum = LinearRgbToLuminance_ac((lightDirectSave * _LightShadowData.x * .5) + lightDirectSave + (lightIndirectCol)) * .34;
601621
float3 vertexLit = i.vertexLighting;
602622
//// out light source by types
603-
float3 lightDirectSource = (mixColorsMaxAve(lightIndirectMaxCol, lightDirect) + vertexLit) * _directLightIntensity;
604-
float3 lightIndirectSource = lightIndirectCol + vertexLit;
623+
float3 lightDirectSource = (mixColorsMaxAve(lightIndirectColMax, lightDirect) + vertexLit) * _directLightIntensity;
624+
float3 lightIndirectSource = (lightIndirectCol + vertexLit);
605625
#elif UNITY_PASS_FORWARDADD
606626
float3 lightIndirectColAve = 0;
607-
float3 lightIndirectAngCol = 0;
627+
float3 lightIndirectColAngle = 0;
608628
float3 lightDirect = _LightColor0.rgb;
609629
float3 lightDirectSave = lightDirect;
610630
lightDirect *= lightAtten;
@@ -689,12 +709,11 @@
689709
if (_ToonRampLightSourceType_Backwards > 0) //// diffuse lighting: backface ramp is part of shadow
690710
{
691711
float n2ShadowMask = 1 - min((1-shadeRamp_n2), shadowBlackness);
692-
shadeRamp_n2 = n2ShadowMask;
712+
shadeRamp_n2 = n2ShadowMask; //// make Backward Area be forced Dynamic shadow from its wrap
693713
float3 lightDirectSim = (lightDirectSource * shadowBlackness) + lightIndirectSource;
694714
shadeCol_1 *= lightDirectSim;
695715
shadeCol_2 *= lightDirectSim;
696-
shadeCol_3 *= lightIndirectSource;
697-
// shadeCol_3 *= (lightDirectSource * max(shadowMinPotential, _LightShadowData.x)) + lightIndirectSource;
716+
shadeCol_3 *= lerp(lightIndirectSource, lightDirectSim, _diffuseIndirectDirectSimMix);
698717
} else //// diffuse lighting: shadow is independent of ramp
699718
{
700719
float3 lightDirectSim = (lightDirectSource * shadowBlackness) + lightIndirectSource;
@@ -941,6 +960,14 @@
941960
#ifdef UNITY_PASS_FORWARDBASE
942961
float4 emissiveMask = _Emissive_Tex.Sample( sampler_EmissionColorTex_trilinear_repeat, TRANSFORM_TEX( i.uv, _Emissive_Tex));
943962
float4 emissionTex = _EmissionColorTex.Sample( sampler_EmissionColorTex_trilinear_repeat, TRANSFORM_TEX( i.uv, _EmissionColorTex));
963+
if (_emissiveUseMainTexA) //// because i know games that store emission mask in main texture alpha channel
964+
{
965+
emissiveMask.g = mainTex.a;
966+
}
967+
if (_emissiveUseMainTexCol) //// and color from main texture
968+
{
969+
emissionTex.rgba = mainTex.rgba;
970+
}
944971
float3 emissionColor = max( (_EmissiveProportional_Color * lightAverageLum), _Emissive_Color.rgb);
945972
float3 emissionMixReal = emissionTex.rgb * emissionColor * emissionTex.a;
946973
float3 emissionMix = emissionMixReal;
@@ -970,7 +997,12 @@
970997
{
971998
float3 lightDirectSim = (shadowBlackness * lightDirectSource) + lightIndirectSource;
972999
// float3 lightDirectSim = (shadowBlackness * lightDirectSource) + lightIndirectSource;
973-
colDiffuse = lerp(colDiffuse, (colDiffuse + (lightDirectSim * mcMixMult.rgb * _MatCapColMult.rgb * _MatCapColMult.a)), matcapMask);
1000+
float3 diffMixMC = 1;
1001+
if (_McDiffAlbedoMix)
1002+
{
1003+
diffMixMC = lerp(1, colDiffuse, _McDiffAlbedoMix);
1004+
}
1005+
colDiffuse = lerp(colDiffuse, (colDiffuse + (diffMixMC * (lightDirectSim * mcMixMult.rgb * _MatCapColMult.rgb * _MatCapColMult.a))), matcapMask);
9741006
}
9751007
}
9761008

Assets/shaders/aciil/ACLS/ACLS_HELPERS.cginc

+7
Original file line numberDiff line numberDiff line change
@@ -757,4 +757,11 @@
757757
return ((start*cos(theta)) + (RelativeVec*sin(theta)));
758758
}
759759

760+
//// Lyuma. (Silent?)
761+
float stepButAntialiased(float x0, float x) {
762+
float u = (x - x0);
763+
float pixwid = fwidth(u);
764+
return clamp(u / pixwid + 0.5, 0.0, 1.0);
765+
}
766+
760767
#endif

Assets/shaders/aciil/ACLS/ACLS_base_cutout.shader

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Shader "ACiiL/toon/ACLS_Toon_Cutout" {
2424
_BaseShade_Feather("--Feather: forward", Range(0.0001, 1)) = 0.001
2525
_ShadeColor_Step("Step: back", Range(0, 1)) = 0.4
2626
_1st2nd_Shades_Feather("--Feather: back", Range(0.0001, 1)) = 0.001
27-
[Enum(All Light,0,Natural ambient,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
27+
[Enum(All Light,0,Natural Indirect,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
28+
_diffuseIndirectDirectSimMix("Backward (In)Direct Mix", Range(0, 1)) = 0
2829
// _Set_SystemShadowsToBase("shadows mix core tone mix",Range(0,1)) = 0
2930
// [Space(18)]
3031
[Enum(Off,0,On,1)] _Diff_GSF_01("Toon ramp GSF effect", Int) = 0
@@ -86,15 +87,21 @@ Shader "ACiiL/toon/ACLS_Toon_Cutout" {
8687
_TweakMatCapOnShadow("Specular shadow mask", Range(0, 1)) = 0
8788
_Set_MatcapMask("Diffuse matcap mask (G)", 2D) = "white" {}
8889
_Tweak_MatcapMaskLevel("--Tweak mask", Range(-1, 1)) = 0
90+
_McDiffAlbedoMix("MC diff albedo mix", Range(0,1)) = 0
8991

9092
// [Header(Emission)]
9193
[HDR] _Emissive_Color("Emissive color", Color) = (0,0,0,1)
9294
[HDR] _EmissiveProportional_Color("Emissive Proportional color", Color) = (0,0,0,1)
9395
_Emissive_Tex("Emissive mask (G)", 2D) = "white" {}
9496
_EmissionColorTex("--Emissive color (RGB)", 2D) = "white" {}
97+
[ToggleUI] _emissiveUseMainTexA("Emissive Use MainTex A",Int) = 0
98+
[ToggleUI] _emissiveUseMainTexCol("Emissive Use MainTex Color",Int) = 0
9599

96100
// [Header(Lighting Behaviour)]
97101
_directLightIntensity("Direct light intensity",Range(0,1)) = 1
102+
_indirectAlbedoMaxAveScale("Indirect albedo maxAve Scale",Range(0.5,2)) = 1
103+
_indirectGIDirectionalMix("Indirect GI dir mix",Range(0,1)) = 0
104+
_indirectGIBlur("Indirect GI blur",Range(.5,4)) = 1
98105
[Enum(HDR,0,Limit,1)] _forceLightClamp("Force scene Lights Clamp",Int) = 0
99106
[Enum(Real ADD,0,Safe MAX,4)] _BlendOp("Additional lights blending", Float) = 4
100107
_shadowCastMin_black("Dynamic Shadow Removal",Range(0.0,1.0)) = 0.1
@@ -177,6 +184,7 @@ Shader "ACiiL/toon/ACLS_Toon_Cutout" {
177184
}
178185

179186
CGPROGRAM
187+
#pragma target 5.0
180188
#pragma vertex vert
181189
#pragma fragment frag
182190
#include "UnityCG.cginc"
@@ -214,6 +222,7 @@ Shader "ACiiL/toon/ACLS_Toon_Cutout" {
214222
}
215223

216224
CGPROGRAM
225+
#pragma target 5.0
217226
#pragma vertex vert
218227
#pragma fragment frag
219228
#include "UnityCG.cginc"
@@ -241,6 +250,7 @@ Shader "ACiiL/toon/ACLS_Toon_Cutout" {
241250
ZWrite On ZTest LEqual
242251

243252
CGPROGRAM
253+
#pragma target 5.0
244254
#pragma vertex vert
245255
#pragma fragment frag
246256
#include "UnityCG.cginc"

Assets/shaders/aciil/ACLS/ACLS_base_cutoutAlpha.shader

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaTransparent" {
2424
_BaseShade_Feather("--Feather: forward", Range(0.0001, 1)) = 0.001
2525
_ShadeColor_Step("Step: back", Range(0, 1)) = 0.4
2626
_1st2nd_Shades_Feather("--Feather: back", Range(0.0001, 1)) = 0.001
27-
[Enum(All Light,0,Natural ambient,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
27+
[Enum(All Light,0,Natural Indirect,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
28+
_diffuseIndirectDirectSimMix("Backward (In)Direct Mix", Range(0, 1)) = 0
2829
// _Set_SystemShadowsToBase("shadows mix core tone mix",Range(0,1)) = 0
2930
// [Space(18)]
3031
[Enum(Off,0,On,1)] _Diff_GSF_01("Toon ramp GSF effect", Int) = 0
@@ -86,15 +87,21 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaTransparent" {
8687
_TweakMatCapOnShadow("Specular shadow mask", Range(0, 1)) = 0
8788
_Set_MatcapMask("Diffuse matcap mask (G)", 2D) = "white" {}
8889
_Tweak_MatcapMaskLevel("--Tweak mask", Range(-1, 1)) = 0
90+
_McDiffAlbedoMix("MC diff albedo mix", Range(0,1)) = 0
8991

9092
// [Header(Emission)]
9193
[HDR] _Emissive_Color("Emissive color", Color) = (0,0,0,1)
9294
[HDR] _EmissiveProportional_Color("Emissive Proportional color", Color) = (0,0,0,1)
9395
_Emissive_Tex("Emissive mask (G)", 2D) = "white" {}
9496
_EmissionColorTex("--Emissive color (RGB)", 2D) = "white" {}
97+
[ToggleUI] _emissiveUseMainTexA("Emissive Use MainTex A",Int) = 0
98+
[ToggleUI] _emissiveUseMainTexCol("Emissive Use MainTex Color",Int) = 0
9599

96100
// [Header(Lighting Behaviour)]
97101
_directLightIntensity("Direct light intensity",Range(0,1)) = 1
102+
_indirectAlbedoMaxAveScale("Indirect albedo maxAve Scale",Range(0.5,2)) = 1
103+
_indirectGIDirectionalMix("Indirect GI dir mix",Range(0,1)) = 0
104+
_indirectGIBlur("Indirect GI blur",Range(.5,4)) = 1
98105
[Enum(HDR,0,Limit,1)] _forceLightClamp("Force scene Lights Clamp",Int) = 0
99106
[Enum(Real ADD,0,Safe MAX,4)] _BlendOp("Additional lights blending", Float) = 4
100107
_shadowCastMin_black("Dynamic Shadow Removal",Range(0.0,1.0)) = 0.1
@@ -178,6 +185,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaTransparent" {
178185
}
179186

180187
CGPROGRAM
188+
#pragma target 5.0
181189
#pragma vertex vert
182190
#pragma fragment frag
183191
#include "UnityCG.cginc"
@@ -219,6 +227,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaTransparent" {
219227
}
220228

221229
CGPROGRAM
230+
#pragma target 5.0
222231
#pragma vertex vert
223232
#pragma fragment frag
224233
#include "UnityCG.cginc"
@@ -247,6 +256,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaTransparent" {
247256
ZWrite On ZTest LEqual
248257

249258
CGPROGRAM
259+
#pragma target 5.0
250260
#pragma vertex vert
251261
#pragma fragment frag
252262
#include "UnityCG.cginc"

Assets/shaders/aciil/ACLS/ACLS_base_cutoutAlphaDither.shader

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaCutout_Dither" {
2424
_BaseShade_Feather("--Feather: forward", Range(0.0001, 1)) = 0.001
2525
_ShadeColor_Step("Step: back", Range(0, 1)) = 0.4
2626
_1st2nd_Shades_Feather("--Feather: back", Range(0.0001, 1)) = 0.001
27-
[Enum(All Light,0,Natural ambient,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
27+
[Enum(All Light,0,Natural Indirect,1)] _ToonRampLightSourceType_Backwards("Toon ramp Backface light source type:",Int) = 0
28+
_diffuseIndirectDirectSimMix("Backward (In)Direct Mix", Range(0, 1)) = 0
2829
// _Set_SystemShadowsToBase("shadows mix core tone mix",Range(0,1)) = 0
2930
// [Space(18)]
3031
[Enum(Off,0,On,1)] _Diff_GSF_01("Toon ramp GSF effect", Int) = 0
@@ -86,15 +87,21 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaCutout_Dither" {
8687
_TweakMatCapOnShadow("Specular shadow mask", Range(0, 1)) = 0
8788
_Set_MatcapMask("Diffuse matcap mask (G)", 2D) = "white" {}
8889
_Tweak_MatcapMaskLevel("--Tweak mask", Range(-1, 1)) = 0
90+
_McDiffAlbedoMix("MC diff albedo mix", Range(0,1)) = 0
8991

9092
// [Header(Emission)]
9193
[HDR] _Emissive_Color("Emissive color", Color) = (0,0,0,1)
9294
[HDR] _EmissiveProportional_Color("Emissive Proportional color", Color) = (0,0,0,1)
9395
_Emissive_Tex("Emissive mask (G)", 2D) = "white" {}
9496
_EmissionColorTex("--Emissive color (RGB)", 2D) = "white" {}
97+
[ToggleUI] _emissiveUseMainTexA("Emissive Use MainTex A",Int) = 0
98+
[ToggleUI] _emissiveUseMainTexCol("Emissive Use MainTex Color",Int) = 0
9599

96100
// [Header(Lighting Behaviour)]
97101
_directLightIntensity("Direct light intensity",Range(0,1)) = 1
102+
_indirectAlbedoMaxAveScale("Indirect albedo maxAve Scale",Range(0.5,2)) = 1
103+
_indirectGIDirectionalMix("Indirect GI dir mix",Range(0,1)) = 0
104+
_indirectGIBlur("Indirect GI blur",Range(.5,4)) = 1
98105
[Enum(HDR,0,Limit,1)] _forceLightClamp("Force scene Lights Clamp",Int) = 0
99106
[Enum(Real ADD,0,Safe MAX,4)] _BlendOp("Additional lights blending", Float) = 4
100107
_shadowCastMin_black("Dynamic Shadow Removal",Range(0.0,1.0)) = 0.1
@@ -182,6 +189,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaCutout_Dither" {
182189
}
183190

184191
CGPROGRAM
192+
#pragma target 5.0
185193
#pragma vertex vert
186194
#pragma fragment frag
187195
#include "UnityCG.cginc"
@@ -223,6 +231,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaCutout_Dither" {
223231
}
224232

225233
CGPROGRAM
234+
#pragma target 5.0
226235
#pragma vertex vert
227236
#pragma fragment frag
228237
#include "UnityCG.cginc"
@@ -251,6 +260,7 @@ Shader "ACiiL/toon/ACLS_Toon_AlphaCutout_Dither" {
251260
ZWrite On ZTest LEqual
252261

253262
CGPROGRAM
263+
#pragma target 5.0
254264
#pragma vertex vert
255265
#pragma fragment frag
256266
#include "UnityCG.cginc"

0 commit comments

Comments
 (0)