diff options
| author | yum <yum.food.vr@gmail.com> | 2025-08-07 18:39:00 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-08-07 18:39:00 -0700 |
| commit | 7fe9d7357ef5788745200012205954b9a484a3ed (patch) | |
| tree | f1a79143ddf4ee54d13e3da948bd8cc11ba1cb30 /pbr.cginc | |
| parent | f13c88295826d439c70cb9dfb4a9dd5d6ae46ff0 (diff) | |
begin roughing out marble gimmick
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; |
