diff options
| author | yum <yum.food.vr@gmail.com> | 2024-05-26 14:31:25 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-05-26 14:31:25 -0700 |
| commit | 0f59fc5fa8a0d57e3c5780f49b6279738c0b55a8 (patch) | |
| tree | 1b2b822c15e7388417bb004907b2578dab71c18b /pbr.cginc | |
| parent | 8dd60d9c674ea5859f13471525419aaa41534dce (diff) | |
Overhaul PBR overlay
Add second PBR overlay and fix masking behavior.
Also elide keywords based on shader variant. This should improve
performance.
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -10,11 +10,11 @@ UNITY_DECLARE_TEXCUBE(_Cubemap); -UnityLight CreateDirectLight(float3 normal, v2f i) +UnityLight CreateDirectLight(float3 normal, float ao, v2f i) { UNITY_LIGHT_ATTENUATION(attenuation, i, i.worldPos); UnityLight light; - light.color = _LightColor0.rgb * attenuation; + light.color = _LightColor0.rgb * attenuation * ao; #if defined(POINT) || defined(POINT_COOKIE) || defined(SPOT) light.dir = normalize((_WorldSpaceLightPos0 - i.worldPos).xyz); #else @@ -51,7 +51,7 @@ float3 BoxProjection ( } UnityIndirect CreateIndirectLight(float4 vertexLightColor, float3 view_dir, float3 normal, - float smoothness, float3 worldPos, float2 uv) { + float smoothness, float3 worldPos, float ao, float2 uv) { UnityIndirect indirect; indirect.diffuse = vertexLightColor; indirect.specular = 0; @@ -109,6 +109,8 @@ UnityIndirect CreateIndirectLight(float4 vertexLightColor, float3 view_dir, floa indirect.specular = probe0; #endif // FORWARD_BASE_PASS + indirect.diffuse *= ao; + return indirect; } @@ -117,7 +119,8 @@ float4 getLitColor( float4 albedo, float3 worldPos, float3 normal, - float metallic, float smoothness, float2 uv, v2f i) + float metallic, float smoothness, float2 uv, float ao, + v2f i) { float3 specular_tint; float one_minus_reflectivity; @@ -135,9 +138,9 @@ float4 getLitColor( normal = lerp(spherical_normal, flat_normal, flat); UnityIndirect indirect_light = CreateIndirectLight(vertexLightColor, - view_dir, normal, smoothness, worldPos, uv); + view_dir, normal, smoothness, worldPos, ao, uv); - UnityLight direct_light = CreateDirectLight(normal, i); + UnityLight direct_light = CreateDirectLight(normal, ao, i); if (flat) { float e = 0.8; indirect_light.diffuse += direct_light.color * e; |
