From 7fe9d7357ef5788745200012205954b9a484a3ed Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 7 Aug 2025 18:39:00 -0700 Subject: begin roughing out marble gimmick --- pbr.cginc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pbr.cginc') diff --git a/pbr.cginc b/pbr.cginc index 7167929..156fba2 100644 --- a/pbr.cginc +++ b/pbr.cginc @@ -23,12 +23,28 @@ void propagateSmoothness(inout Pbr pbr) { pbr.roughness = max(MIN_ROUGHNESS, pbr.roughness_perceptual * pbr.roughness_perceptual); } +void apply_marble(float3 world_pos, inout float3 albedo) { +#if defined(_MARBLE) + float3 uvw = world_pos * _Marble_Scale; + float noise_r = sin_noise_3d_fbm(uvw + _Time[0], _Marble_Octaves, 2.0f, _Marble_Strength); + float noise_g = sin_noise_3d_fbm(uvw+3.1 + _Time[0], _Marble_Octaves, 2.0f, _Marble_Strength); + float noise_b = sin_noise_3d_fbm(uvw+3.7 + _Time[0], _Marble_Octaves, 2.0f, _Marble_Strength); + + float3 r = _Marble_U_Ramp.Sample(linear_repeat_s, float2(noise_r, 0)); + float3 g = _Marble_V_Ramp.Sample(linear_repeat_s, float2(noise_g, 0)); + float3 b = _Marble_W_Ramp.Sample(linear_repeat_s, float2(noise_b, 0)); + + albedo = r + g + b; +#endif +} + Pbr getPbr(v2f i) { Pbr pbr = (Pbr) 0; pbr.normal = normalize(i.normal); pbr.albedo = _Color; pbr.smoothness = _Smoothness; propagateSmoothness(pbr); + apply_marble(i.worldPos, pbr.albedo.xyz); pbr.metallic = _Metallic; return pbr; -- cgit v1.2.3