From 42dbd067eb455d4b67d6ae8c57f1cbe4ec7dccfa Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 8 Aug 2025 19:28:27 -0700 Subject: Optimize sh9 implementation Saves ~20 instructions (572 -> 552). --- filamented.cginc | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'filamented.cginc') diff --git a/filamented.cginc b/filamented.cginc index fb019cb..f6bd67a 100644 --- a/filamented.cginc +++ b/filamented.cginc @@ -213,30 +213,6 @@ #include "UnityCG.cginc" #include "UnityImageBasedLightingMinimal.cginc" -float normalFiltering(float perceptualRoughness, const float3 worldNormal) { - // Kaplanyan 2016, "Stable specular highlights" - // Tokuyoshi 2017, "Error Reduction and Simplification for Shading Anti-Aliasing" - // Tokuyoshi and Kaplanyan 2019, "Improved Geometric Specular Antialiasing" - - // This implementation is meant for deferred rendering in the original paper but - // we use it in forward rendering as well (as discussed in Tokuyoshi and Kaplanyan - // 2019). The main reason is that the forward version requires an expensive transform - // of the half vector by the tangent frame for every light. This is therefore an - // approximation but it works well enough for our needs and provides an improvement - // over our original implementation based on Vlachos 2015, "Advanced VR Rendering". - - float3 du = ddx(worldNormal); - float3 dv = ddy(worldNormal); - - float variance = _Specular_AA_Variance * (dot(du, du) + dot(dv, dv)); - - float roughness = perceptualRoughnessToRoughness(perceptualRoughness); - float kernelRoughness = min(2.0 * variance, _Specular_AA_Threshold); - float squareRoughness = saturate(roughness * roughness + kernelRoughness); - - return roughnessToPerceptualRoughness(sqrt(squareRoughness)); -} - half3 Unity_GlossyEnvironment_local (UNITY_ARGS_TEXCUBE(tex), half4 hdr, Unity_GlossyEnvironmentData glossIn) { half perceptualRoughness = glossIn.roughness /* perceptualRoughness */ ; -- cgit v1.2.3