diff options
| author | yum <yum.food.vr@gmail.com> | 2024-09-25 18:00:24 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-09-25 18:00:24 -0700 |
| commit | 7f0ddc5463608f30bcd854eb4fd8d157f1b99052 (patch) | |
| tree | ec373d572c7592a3a6f316ee85fd5707260eddc8 | |
| parent | 2b9e36fde45c5f488539f390288e0a2731d11fcf (diff) | |
Bugfixes & small tweaks
* UNITY_LIGHTING_COORDS no longer clashes with uv2
* Direct light is only sampled once in world mode
* Overlay mask always uses most detailed mip map
| -rw-r--r-- | interpolators.cginc | 6 | ||||
| -rw-r--r-- | pbr.cginc | 29 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 20 |
3 files changed, 28 insertions, 27 deletions
diff --git a/interpolators.cginc b/interpolators.cginc index bbe4742..09fd14c 100644 --- a/interpolators.cginc +++ b/interpolators.cginc @@ -32,7 +32,7 @@ struct v2f float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; #if defined(_WORLD_INTERPOLATORS) - UNITY_LIGHTING_COORDS(2, 3) + UNITY_LIGHTING_COORDS(3, 4) #else float2 uv3 : TEXCOORD3; float2 uv4 : TEXCOORD4; @@ -59,7 +59,7 @@ struct appdata float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; #if defined(_WORLD_INTERPOLATORS) - UNITY_LIGHTING_COORDS(2, 3) + UNITY_LIGHTING_COORDS(3, 4) #else float2 uv3 : TEXCOORD3; float2 uv4 : TEXCOORD4; @@ -80,7 +80,7 @@ struct v2f float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; #if defined(_WORLD_INTERPOLATORS) - UNITY_LIGHTING_COORDS(2, 3) + UNITY_LIGHTING_COORDS(3, 4) #else float2 uv3 : TEXCOORD3; float2 uv4 : TEXCOORD4; @@ -255,15 +255,6 @@ float4 getLitColor( UnityIndirect indirect_light; vertexLightColor *= _Vertex_Lighting_Factor; - UnityLight direct_light; - direct_light.dir = getDirectLightDirection(i); - direct_light.ndotl = DotClamped(normal, direct_light.dir); -#define POI_LIGHTING -#if defined(POI_LIGHTING) - direct_light.color = getPoiLightingDirect(normal); -#else - direct_light.color = getDirectLightColor(); -#endif #if defined(_WORLD_INTERPOLATORS) UNITY_LIGHT_ATTENUATION(shadow_attenuation, i, i.worldPos); @@ -271,6 +262,10 @@ float4 getLitColor( float shadow_attenuation = getShadowAttenuation(i); #endif + UnityLight direct_light; + direct_light.dir = getDirectLightDirection(i); + direct_light.ndotl = DotClamped(normal, direct_light.dir); + direct_light.color = 0; #if defined(_WORLD_INTERPOLATORS) { UnityGI gi = getBakedGI(i, view_dir, direct_light, shadow_attenuation, ao, @@ -279,10 +274,20 @@ float4 getLitColor( indirect_light = gi.indirect; } #else - indirect_light.diffuse = getIndirectDiffuse(vertexLightColor, normal); - indirect_light.specular = getIndirectSpecular(view_dir, normal, smoothness, - metallic, worldPos, uv); + { + direct_light.dir = getDirectLightDirection(i); + direct_light.ndotl = DotClamped(normal, direct_light.dir); +#define POI_LIGHTING +#if defined(POI_LIGHTING) + direct_light.color = getPoiLightingDirect(normal); +#else + direct_light.color = getDirectLightColor(); #endif + indirect_light.diffuse = getIndirectDiffuse(vertexLightColor, normal); + indirect_light.specular = getIndirectSpecular(view_dir, normal, smoothness, + metallic, worldPos, uv); + } +#endif // _WORLD_INTERPOLATORS if (normals_mode == 0) { float e = 0.8; diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index 8867630..fa65cec 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -723,9 +723,8 @@ void getOverlayAlbedoRoughnessMetallic(inout PbrOverlay ov, #endif #if defined(_PBR_OVERLAY0_MASK) - ov.ov0_mask = _PBR_Overlay0_Mask.SampleBias(GET_SAMPLER_OV0, - get_uv_by_channel(i, _PBR_Overlay0_UV_Select), - _Global_Sample_Bias + _PBR_Overlay0_Mip_Bias); + ov.ov0_mask = _PBR_Overlay0_Mask.SampleLevel(GET_SAMPLER_OV0, + get_uv_by_channel(i, _PBR_Overlay0_UV_Select), 0); ov.ov0_mask = ((bool) round(_PBR_Overlay0_Mask_Invert)) ? 1.0 - ov.ov0_mask : ov.ov0_mask; #else ov.ov0_mask = 1; @@ -766,9 +765,8 @@ void getOverlayAlbedoRoughnessMetallic(inout PbrOverlay ov, #endif #if defined(_PBR_OVERLAY1_MASK) - ov.ov1_mask = _PBR_Overlay1_Mask.SampleBias(GET_SAMPLER_OV1, - get_uv_by_channel(i, _PBR_Overlay1_UV_Select), - _Global_Sample_Bias + _PBR_Overlay1_Mip_Bias); + ov.ov1_mask = _PBR_Overlay1_Mask.SampleLevel(GET_SAMPLER_OV1, + get_uv_by_channel(i, _PBR_Overlay1_UV_Select), 0); ov.ov1_mask = ((bool) round(_PBR_Overlay1_Mask_Invert)) ? 1.0 - ov.ov1_mask : ov.ov1_mask; #else ov.ov1_mask = 1; @@ -809,9 +807,8 @@ void getOverlayAlbedoRoughnessMetallic(inout PbrOverlay ov, #endif #if defined(_PBR_OVERLAY2_MASK) - ov.ov2_mask = _PBR_Overlay2_Mask.SampleBias(GET_SAMPLER_OV2, - get_uv_by_channel(i, _PBR_Overlay2_UV_Select), - _Global_Sample_Bias + _PBR_Overlay2_Mip_Bias); + ov.ov2_mask = _PBR_Overlay2_Mask.SampleLevel(GET_SAMPLER_OV2, + get_uv_by_channel(i, _PBR_Overlay2_UV_Select), 0); ov.ov2_mask = ((bool) round(_PBR_Overlay2_Mask_Invert)) ? 1.0 - ov.ov2_mask : ov.ov2_mask; #else ov.ov2_mask = 1; @@ -852,9 +849,8 @@ void getOverlayAlbedoRoughnessMetallic(inout PbrOverlay ov, #endif #if defined(_PBR_OVERLAY3_MASK) - ov.ov3_mask = _PBR_Overlay3_Mask.SampleBias(GET_SAMPLER_OV3, - get_uv_by_channel(i, _PBR_Overlay3_UV_Select), - _Global_Sample_Bias + _PBR_Overlay3_Mip_Bias); + ov.ov3_mask = _PBR_Overlay3_Mask.SampleLevel(GET_SAMPLER_OV3, + get_uv_by_channel(i, _PBR_Overlay3_UV_Select), 0); ov.ov3_mask = ((bool) round(_PBR_Overlay3_Mask_Invert)) ? 1.0 - ov.ov3_mask : ov.ov3_mask; #else ov.ov3_mask = 1; |
