diff options
| author | yum <yum.food.vr@gmail.com> | 2024-07-15 13:53:48 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-07-15 13:53:48 -0700 |
| commit | 65960b924a861f273b72157456aabaa694831976 (patch) | |
| tree | 26ae1b61e1581e5754843e70f785dda6bf4761a0 /MochieStandardBRDF.cginc | |
| parent | 09de70448b051e20fbfbd56ee00b24168bdd90ab (diff) | |
Add filament-style clearcoat
Diffstat (limited to 'MochieStandardBRDF.cginc')
| -rw-r--r-- | MochieStandardBRDF.cginc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/MochieStandardBRDF.cginc b/MochieStandardBRDF.cginc index 795bbee..90f5df5 100644 --- a/MochieStandardBRDF.cginc +++ b/MochieStandardBRDF.cginc @@ -1,6 +1,9 @@ #ifndef MOCHIE_STANDARD_BRDF_INCLUDED #define MOCHIE_STANDARD_BRDF_INCLUDED +#include "filament_math.cginc" +#include "globals.cginc" + /* * MIT License * @@ -54,7 +57,7 @@ float GSAARoughness(float3 normal, float roughness){ half4 BRDF1_Mochie_PBS ( half3 diffColor, half3 specColor, half oneMinusReflectivity, half smoothness, - half3 normal, half3 viewDir, half3 worldPos, half2 screenUVs, half4 screenPos, + half3 normal, half3 mesh_normal, half3 viewDir, half3 worldPos, half2 screenUVs, half4 screenPos, half metallic, half thickness, half3 ssColor, half atten, float2 lightmapUV, float3 vertexColor, UnityLight light, UnityIndirect gi) { @@ -170,6 +173,17 @@ half4 BRDF1_Mochie_PBS ( // reflCol *= lerp(1, vertexColor, _ReflVertexColor*_ReflVertexColorStrength); // #endif +#if defined(_CLEARCOAT) + half cc_nh = saturate(dot(mesh_normal, halfDir)); + float clearcoat = FilamentClearcoat( + _Clearcoat_Roughness, + _Clearcoat_Strength, + cc_nh, + lh, + halfDir); + specCol += clearcoat * saturate(dot(mesh_normal, light.dir)) * 10; +#endif + return half4(diffCol + specCol + reflCol + subsurfaceCol, 1); } |
