Various bug fixes + Material setters

This commit is contained in:
Crizomb 2025-09-27 02:37:11 +02:00
parent e35cca1830
commit f5c912c489
5 changed files with 53 additions and 22 deletions

7
sdf.go
View file

@ -140,7 +140,7 @@ func (s SmoothSubstractionSDF) Distance(p Vector3) (float64, Material) {
h := math.Max(k-math.Abs(-d1-d2), 0.0)
d := math.Max(-d1, d2) + h*h*0.25/k
t := SmoothStep(d2-d1, -k, k)
mat := MixMat(mat1, mat2, t, p)
mat := MixMat(mat2, mat1, t, p)
return d, mat
}
@ -154,8 +154,9 @@ func (s SmoothIntersectionSDF) Distance(p Vector3) (float64, Material) {
k := 4 * s.k
d1, mat1 := s.primitive1.Distance(p)
d2, mat2 := s.primitive2.Distance(p)
d := math.Max(k-math.Abs(d1-d2), 0.0)
h := math.Max(k-math.Abs(d1-d2), 0.0)
d := math.Max(d1, d2) + h*h*0.25/k
t := SmoothStep(d2-d1, -k, k)
mat := MixMat(mat1, mat2, t, p)
mat := MixMat(mat2, mat1, t, p)
return d, mat
}