summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-08-07 18:39:00 -0700
committeryum <yum.food.vr@gmail.com>2025-08-07 18:39:00 -0700
commit7fe9d7357ef5788745200012205954b9a484a3ed (patch)
treef1a79143ddf4ee54d13e3da948bd8cc11ba1cb30 /math.cginc
parentf13c88295826d439c70cb9dfb4a9dd5d6ae46ff0 (diff)
begin roughing out marble gimmick
Diffstat (limited to 'math.cginc')
-rw-r--r--math.cginc15
1 files changed, 15 insertions, 0 deletions
diff --git a/math.cginc b/math.cginc
index 4b91209..0d59121 100644
--- a/math.cginc
+++ b/math.cginc
@@ -4,6 +4,21 @@
#define PI 3.14159265358979f
#define RCP_PI (1.0f / PI)
+float sin_noise_3d(float3 uvw) {
+ return sin(uvw[0]) * sin(uvw[1]) * sin(uvw[2]);
+}
+
+float sin_noise_3d_fbm(float3 uvw, uint octaves, float k, float strength) {
+ float result = 0;
+ float factor = 1.0f;
+ for (uint i = 0; i < octaves; i++) {
+ result += sin_noise_3d(uvw) * factor * strength;
+ uvw *= k;
+ factor /= k;
+ }
+ return result;
+}
+
// Wrap a dot product. Assume it's already clamped.
// At k=0, you get standard lambertian shading.
// At k=0.5, you get half-lambertian shading.