diff options
| author | yum <yum.food.vr@gmail.com> | 2024-09-18 22:45:23 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-09-18 22:45:23 -0700 |
| commit | 0b12f0aff502b04e48efd3141637fc0bb20a7f2d (patch) | |
| tree | 1cfb886cf4b211a0ddfc0b22e201397593b274d9 /pbr.cginc | |
| parent | 5f5cdb6cac392d681e8a57cdfb2bfc55d11e2194 (diff) | |
Tweak cubemap code
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -36,6 +36,7 @@ void ltcgi_cb_specular(inout ltcgi_acc acc, in ltcgi_output output) { #endif // __LTCGI UNITY_DECLARE_TEXCUBE(_Cubemap); +half4 _Cubemap_HDR; float _Cubemap_Limit_To_Metallic; float getShadowAttenuation(v2f i) @@ -146,17 +147,22 @@ float3 getIndirectSpecular(float3 view_dir, float3 normal, } #endif // UNITY_SPECCUBE_BLENDING - // Lifted from poi toon shader (MIT). - float horizon = min(1 + dot(reflect_dir, normal), 1); - specular *= horizon * horizon; - #if defined(_CUBEMAP) - float roughness = GetRoughness(smoothness); +#if 0 float3 specular_tmp = UNITY_SAMPLE_TEXCUBE_LOD( _Cubemap, reflect_dir, roughness * UNITY_SPECCUBE_LOD_STEPS); +#else + env_data.reflUVW = BoxProjection( + reflect_dir, worldPos, + unity_SpecCube0_ProbePosition, + unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax + ); + float3 specular_tmp = Unity_GlossyEnvironment( + UNITY_PASS_TEXCUBE(_Cubemap), _Cubemap_HDR, env_data); +#endif if (_Cubemap_Limit_To_Metallic) { specular = lerp(specular, specular_tmp, metallic); } else { @@ -164,6 +170,10 @@ float3 getIndirectSpecular(float3 view_dir, float3 normal, } #endif // _CUBEMAP + // Lifted from poi toon shader (MIT). + float horizon = min(1 + dot(reflect_dir, normal), 1); + specular *= horizon * horizon; + #endif // FORWARD_BASE_PASS return specular; |
