summaryrefslogtreecommitdiffstats
path: root/pbr.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-03-24 17:23:40 -0700
committeryum <yum.food.vr@gmail.com>2026-03-24 17:23:40 -0700
commit81637c1a3fab4f92e6da7517dd118d5bb4526865 (patch)
treed01e3ee10c5992460982767101dda070c46801ae /pbr.cginc
parent043de4d0360c54a507b90369e1afe1d1d6ace28f (diff)
Encapsulate ssfd and letter grid inside pbr.cginc
Diffstat (limited to 'pbr.cginc')
-rwxr-xr-xpbr.cginc27
1 files changed, 26 insertions, 1 deletions
diff --git a/pbr.cginc b/pbr.cginc
index 47ef00c..f81f95e 100755
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -1,11 +1,13 @@
#ifndef __PBR_INC
#define __PBR_INC
-#include "filamented.cginc"
#include "data.cginc"
#include "decal.cginc"
+#include "filamented.cginc"
#include "instancing.cginc"
#include "interpolators.cginc"
+#include "letter_grid.cginc"
+#include "ssfd.cginc"
#include "texture_utils.cginc"
#if defined(_PARALLAX_HEIGHTMAP)
@@ -168,6 +170,27 @@ void apply_kintsugi(float3 world_pos, inout float3 albedo, inout float smoothnes
#endif // _KINTSUGI
}
+void apply_letter_grid(v2f i, inout Pbr pbr) {
+#if defined(_LETTER_GRID)
+ LetterGridOutput lg = LetterGrid(i);
+ pbr.albedo.rgb = lerp(pbr.albedo.rgb, lg.albedo, lg.albedo.a);
+ pbr.metallic = lerp(pbr.metallic, lg.metallic, lg.albedo.a);
+ pbr.roughness = lerp(pbr.roughness, lg.roughness, lg.albedo.a);
+#if defined(FORWARD_BASE_PASS)
+ pbr.emission += lg.emission * lg.albedo.a;
+#endif
+#endif
+}
+
+void apply_ssfd(float2 uv, inout float3 albedo) {
+#if defined(_SSFD)
+ float ssfd_mask = ssfd(uv, _SSFD_Scale, _SSFD_Max_Fwidth, 0, _SSFD_Noise);
+ float ssfd_mask_fw = fwidth(ssfd_mask);
+ ssfd_mask = smoothstep(_SSFD_Threshold - ssfd_mask_fw * 0.5, _SSFD_Threshold + ssfd_mask_fw * 0.5, ssfd_mask);
+ albedo += ssfd_mask * _SSFD_Tint.rgb;
+#endif
+}
+
Pbr getPbr(v2f i) {
Pbr pbr = (Pbr) 0;
@@ -213,6 +236,8 @@ Pbr getPbr(v2f i) {
apply_marble(i.worldPos, pbr.albedo.xyz);
apply_kintsugi(i.worldPos, pbr.albedo.xyz, pbr.smoothness, pbr.metallic);
+ apply_ssfd(i.uv01.xy, pbr.albedo.xyz);
+ apply_letter_grid(i, pbr);
applyDecals(i, pbr, normal_tangent);