summaryrefslogtreecommitdiffstats
path: root/pbr.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'pbr.cginc')
-rw-r--r--pbr.cginc16
1 files changed, 16 insertions, 0 deletions
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;