diff options
| author | yum <yum.food.vr@gmail.com> | 2026-02-24 19:09:23 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-02-24 19:09:23 -0800 |
| commit | 80d511162ca90e29fd26c9a5893cde7aa9c23332 (patch) | |
| tree | 12c7bd37084b7ded5eb2472ca2b5bcc6d8e8d69b | |
| parent | 610607592438452e181eba98f05d58f838975266 (diff) | |
Add outline pass
| -rwxr-xr-x | 3ner.cginc | 8 | ||||
| -rwxr-xr-x | 3ner.shader | 41 | ||||
| -rwxr-xr-x | brdf.cginc | 2 | ||||
| -rwxr-xr-x | features.cginc | 4 | ||||
| -rwxr-xr-x | globals.cginc | 6 | ||||
| -rwxr-xr-x | lighting.cginc | 4 | ||||
| -rwxr-xr-x | pbr.cginc | 4 |
7 files changed, 66 insertions, 3 deletions
@@ -24,6 +24,9 @@ v2f vert(appdata v) { #if defined(SHADOW_CASTER_PASS) && !defined(_SHADOW_CASTER) return (v2f) asfloat(-1); #endif +#if defined(OUTLINES_PASS) && !defined(_OUTLINES) + return (v2f) asfloat(-1); +#endif v2f o; UNITY_SETUP_INSTANCE_ID(v); @@ -33,6 +36,11 @@ v2f vert(appdata v) { impostor_vert(v.vertex.xyz); +#if defined(OUTLINES_PASS) && defined(_OUTLINES) + float thickness = _Outlines_Thickness.SampleLevel(point_repeat_s, v.uv0, 0).r; + v.vertex.xyz += v.normal * _Outlines_Width * thickness; +#endif + #if defined(_VERTEX_DEFORMATION) && ( \ defined(_VERTEX_DEFORMATION_FRAGMENT_NORMALS) || \ defined(_VERTEX_DEFORMATION_TESSELLATION)) || \ diff --git a/3ner.shader b/3ner.shader index d08f2c7..6735229 100755 --- a/3ner.shader +++ b/3ner.shader @@ -94,6 +94,15 @@ Shader "yum_food/3ner" [HideInInspector] m_end_Wrapped_Lighting("Wrapped Lighting", Float) = 0 //endex + //ifex _Outlines_Enabled==0 + [HideInInspector] m_start_Outlines("Outlines", Float) = 0 + [ThryToggle(_OUTLINES)] _Outlines_Enabled("Enable", Float) = 0 + _Outlines_Color("Color", Color) = (1, 1, 1, 1) + _Outlines_Width("Width", Range(0, 1)) = 0.01 + _Outlines_Thickness("Thickness", 2D) = "white" {} + [HideInInspector] m_end_Outlines("Outlines", Float) = 0 + //endex + [HideInInspector] m_end_Main("Main", Float) = 0 [HideInInspector] m_start_Gimmicks("Gimmicks", Float) = 0 @@ -585,6 +594,38 @@ Shader "yum_food/3ner" #include "3ner.cginc" ENDCG } + //ifex _Outlines_Enabled==0 + Pass { + Name "OUTLINES" + Tags { "LightMode" = "ForwardBase" } + BlendOp [_BlendOp], [_BlendOpAlpha] + Blend [_SrcBlend] [_DstBlend], [_SrcBlendAlpha] [_DstBlendAlpha] + Cull Front + ZWrite [_ZWrite] + ZTest [_ZTest] + + CGPROGRAM + #pragma target 5.0 + #pragma multi_compile_fwdbase + #pragma multi_compile_fullshadows + #pragma multi_compile_instancing + #pragma multi_compile_fog + #pragma vertex vert + //ifex _Geometry_Enabled==0 + #pragma geometry geom + //endex + //ifex _Tessellation_Enabled==0 + #pragma hull hull + #pragma domain domain + //endex + #pragma fragment frag + + #define OUTLINES_PASS + + #include "3ner.cginc" + ENDCG + } + //endex Pass { Name "ADDITIVE" Tags { "LightMode" = "ForwardAdd" } @@ -153,7 +153,7 @@ float4 brdf(Pbr pbr, LightData data) { } // Indirect -#if !defined(FURNACE_TEST_DIRECT) && defined(FORWARD_BASE_PASS) +#if !defined(FURNACE_TEST_DIRECT) && (defined(FORWARD_BASE_PASS) || defined(OUTLINES_PASS)) { float3 specular_dfg = dfg.xxx * f0_color + dfg.yyy; // filament 5.3.4.6 float3 indirect_specular = data.indirect.specular * specular_dfg; diff --git a/features.cginc b/features.cginc index d7e81e9..4ad5c88 100755 --- a/features.cginc +++ b/features.cginc @@ -27,6 +27,10 @@ #pragma shader_feature_local _WRAPPED_LIGHTING //endex +//ifex _Outlines_Enabled==0 +#pragma shader_feature_local _OUTLINES +//endex + //ifex _Bent_Normals_Enabled==0 #pragma shader_feature_local _BENT_NORMALS //endex diff --git a/globals.cginc b/globals.cginc index d3b2a87..3dcb0ea 100755 --- a/globals.cginc +++ b/globals.cginc @@ -32,6 +32,12 @@ float _Specular_AA_Variance; float _Specular_AA_Threshold; float _BRDF_Specular_Min_Denom; +#if defined(_OUTLINES) +float4 _Outlines_Color; +float _Outlines_Width; +texture2D _Outlines_Thickness; +#endif // _OUTLINES + #if defined(_BRIGHTNESS_CLAMP) float _Brightness_Clamp_Min; float _Brightness_Clamp_Max; diff --git a/lighting.cginc b/lighting.cginc index f39d866..51b0c8f 100755 --- a/lighting.cginc +++ b/lighting.cginc @@ -186,7 +186,7 @@ float3 yumSH9(float4 n, float3 worldPos, inout LightIndirect light) { float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightIndirect light) { float4 diffuse = 0; -#if defined(FORWARD_BASE_PASS) +#if defined(FORWARD_BASE_PASS) || defined(OUTLINES_PASS) #if defined(_BENT_NORMALS) diffuse.xyz += max(0, yumSH9(float4(pbr.bent_normal, 1.0), i.worldPos, light)); #else @@ -194,7 +194,7 @@ float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightIndirect light) { #endif #endif -#if defined(_BRIGHTNESS_CLAMP) && defined(FORWARD_BASE_PASS) +#if defined(_BRIGHTNESS_CLAMP) && (defined(FORWARD_BASE_PASS) || defined(OUTLINES_PASS)) float3 diffuse_hsv = RGBtoHSV(diffuse.xyz); diffuse_hsv.z = clamp(diffuse_hsv.z, _Brightness_Clamp_Min, _Brightness_Clamp_Max); diffuse.xyz = HSVtoRGB(diffuse_hsv); @@ -196,9 +196,13 @@ Pbr getPbr(v2f i) { #if defined(_IMPOSTORS_DEPTH) pbr.objPos = imp.objPos; #endif +#else // !_IMPOSTORS +#if defined(OUTLINES_PASS) && defined(_OUTLINES) + pbr.albedo = _Outlines_Color; #else pbr.albedo = _MainTex.Sample(aniso4_trilinear_repeat_s, uv_parallax * _MainTex_ST.xy + _MainTex_ST.zw); pbr.albedo *= _Color; +#endif apply_marble(i.worldPos, pbr.albedo.xyz); float3 normal_tangent = UnpackNormal(_BumpMap.Sample(aniso4_trilinear_repeat_s, uv_parallax * _BumpMap_ST.xy)); |
