diff options
| author | yum <yum.food.vr@gmail.com> | 2024-07-18 17:13:06 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-07-18 17:13:06 -0700 |
| commit | 0592c85cd172369625e084be6b037f8c122cbf16 (patch) | |
| tree | fdb900100ff0f8b9808a76b2d4fa6952c945f42f | |
| parent | 17c5f581851799676af414ae7f35bc20b295e0b2 (diff) | |
Temporarily disable direct lighting in outlines
| -rw-r--r-- | pbr.cginc | 9 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 2 | ||||
| -rw-r--r-- | tooner_outline_pass.cginc | 8 |
3 files changed, 13 insertions, 6 deletions
@@ -174,7 +174,12 @@ float4 getLitColor( float4 albedo, float3 worldPos, float3 normal, - float metallic, float smoothness, float2 uv, float ao, + float metallic, + float smoothness, + float2 uv, + float ao, + // hack while i figure out view-dependent flickering in outlines + bool enable_direct, v2f i) { float3 specular_tint; @@ -218,7 +223,7 @@ float4 getLitColor( } #endif - direct_light.color *= _Lighting_Factor * _Direct_Lighting_Factor; + direct_light.color *= _Lighting_Factor * _Direct_Lighting_Factor * enable_direct; indirect_light.specular *= _Lighting_Factor * _Indirect_Specular_Lighting_Factor; indirect_light.diffuse *= _Lighting_Factor * _Indirect_Diffuse_Lighting_Factor; diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index 2040c6d..68cfa57 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -1226,7 +1226,7 @@ float4 effect(inout v2f i) #endif float4 lit = getLitColor(vertex_light_color, albedo, i.worldPos, normal, - metallic, 1.0 - roughness, i.uv, ao, i); + metallic, 1.0 - roughness, i.uv, ao, /*enable_direct=*/true, i); #if defined(_GIMMICK_FLAT_COLOR) if (round(_Gimmick_Flat_Color_Enable_Dynamic)) { diff --git a/tooner_outline_pass.cginc b/tooner_outline_pass.cginc index 479194c..d225dc9 100644 --- a/tooner_outline_pass.cginc +++ b/tooner_outline_pass.cginc @@ -71,7 +71,7 @@ v2f vert(appdata v) #endif v2f o; - o.worldPos = mul(unity_ObjectToWorld, objPos); + o.worldPos = mul(unity_ObjectToWorld, float4(objPos.xyz, 1)); o.objPos = objPos; o.pos = UnityObjectToClipPos(objPos); o.normal = UnityObjectToWorldNormal(v.normal); @@ -340,6 +340,8 @@ void geom(triangle v2f tri_in[3], fixed4 frag (v2f i) : SV_Target { + i.normal = -normalize(i.normal); + #if defined(_OUTLINES) float iddx = ddx(i.uv.x) / 4; float iddy = ddx(i.uv.y) / 4; @@ -380,9 +382,9 @@ fixed4 frag (v2f i) : SV_Target float ao = 1; float4 result = getLitColor( vertex_light_color, - albedo, i.worldPos, -i.normal, + albedo, i.worldPos, i.normal, /*metallic=*/0, /*smoothness=*/0, - i.uv, ao, i); + i.uv, ao, /*enable_direct=*/false, i); result += albedo * _Outline_Emission_Strength; |
