diff options
| author | yum <yum.food.vr@gmail.com> | 2025-02-20 17:58:06 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-02-20 17:58:06 -0800 |
| commit | 01eeb68639ee4e3a5aeacf321c35a46c7dfe5c3d (patch) | |
| tree | a2f20ba0d81bdc9427eec155fe4fc5ed4209648a /yum_pbr.cginc | |
| parent | 36bd33d973f54f91f881cee87a234994d3fbd4eb (diff) | |
Add metallic+gloss map
Diffstat (limited to 'yum_pbr.cginc')
| -rw-r--r-- | yum_pbr.cginc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/yum_pbr.cginc b/yum_pbr.cginc index 93c615d..2f7113b 100644 --- a/yum_pbr.cginc +++ b/yum_pbr.cginc @@ -34,12 +34,23 @@ YumPbr GetYumPbr(v2f i) { float3x3 tangentToWorld = float3x3(i.tangent, i.binormal, i.normal); result.normal = normalize(mul(normal_raw, tangentToWorld)); - result.smoothness = _Smoothness; +#if defined(_METALLICS) + float4 metallic_gloss = tex2D(_MetallicGlossMap, UV_SCOFF(i, _MetallicGlossMap_ST, /*which_channel=*/0)); + float metallic = metallic_gloss.r * _Metallic; + float smoothness = metallic_gloss.a * _Smoothness; + + result.smoothness = smoothness; result.roughness_perceptual = normalFiltering(1.0 - result.smoothness, result.normal); result.roughness = result.roughness_perceptual * result.roughness_perceptual; - - result.metallic = _Metallic; + result.metallic = metallic; +#else + result.smoothness = 0.2; + result.roughness_perceptual = + normalFiltering(1.0 - result.smoothness, result.normal); + result.roughness = result.roughness_perceptual * result.roughness_perceptual; + result.metallic = 0; +#endif #if defined(_AMBIENT_OCCLUSION) result.ao = lerp(1, tex2D(_OcclusionMap, i.uv01), _OcclusionStrength); |
