diff options
| author | yum <yum.food.vr@gmail.com> | 2026-03-15 16:36:46 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-03-15 16:36:46 -0700 |
| commit | f607646ad46ead5fc404f4313a901a13b2df466f (patch) | |
| tree | 1c9cd96a823ccbdf48f93302e63b73a9624773f6 /pbr.cginc | |
| parent | c6727a2be7d39323e0be050090114415d969bb49 (diff) | |
Finish marble rework
Diffstat (limited to 'pbr.cginc')
| -rwxr-xr-x | pbr.cginc | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -125,8 +125,36 @@ void propagateSmoothness(inout Pbr pbr) { void apply_marble(float3 world_pos, inout float3 albedo) { #if defined(_MARBLE) float3 uvw = world_pos * _Marble_Scale; - float3 noise = _Marble_Noise.Sample(aniso4_trilinear_repeat_s, uvw).rgb; - albedo = noise.x; + + float3 noises[10]; + + float3 noise = 0; + float gain = 1; + + float3 offset = 0; +#if defined(_MARBLE_TIME) + offset += _Time[0] * _Marble_Speed * _Marble_Direction; +#endif +#if defined(_MARBLE_OFFSET) + offset += _Marble_Offset; +#endif + + uvw += offset; + + for (uint ii = 0; ii < _Marble_Octaves; ++ii) { + noises[ii] = _Marble_Noise.Sample(aniso4_trilinear_repeat_s, uvw + noise * _Marble_Strength).rgb * gain; + noise += noises[ii]; + + uvw *= _Marble_Lacunarity; + gain *= _Marble_Gain; + } + + // In general, the series 1 + r + ... + r^{n-1} = (1 - r^n) / (1 - r) + noise *= (1 - _Marble_Gain) / (1 - pow(_Marble_Gain, _Marble_Octaves)); + + noise = _Marble_Post_Ramp.Sample(linear_clamp_s, float2(noise.x, 0)); + + albedo = noise; #endif } |
