summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-09-18 22:45:23 -0700
committeryum <yum.food.vr@gmail.com>2024-09-18 22:45:23 -0700
commit0b12f0aff502b04e48efd3141637fc0bb20a7f2d (patch)
tree1cfb886cf4b211a0ddfc0b22e201397593b274d9
parent5f5cdb6cac392d681e8a57cdfb2bfc55d11e2194 (diff)
Tweak cubemap code
-rw-r--r--pbr.cginc20
-rw-r--r--tooner.shader2
2 files changed, 16 insertions, 6 deletions
diff --git a/pbr.cginc b/pbr.cginc
index ab49e30..b9582a0 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -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;
diff --git a/tooner.shader b/tooner.shader
index e98092f..57759a7 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -3,7 +3,7 @@ Shader "yum_food/tooner"
// Unity fucking sucks ass and sometimes incorrectly uses an old cached
// version of the shader. Bump the nonce below to encourage it to use the
// current version.
- // Build nonce: 28
+ // Build nonce: 29
Properties
{
_Color("Base color", Color) = (0.8, 0.8, 0.8, 1)