smooth + mixmat bug fix

This commit is contained in:
Crizomb 2025-09-26 23:23:52 +02:00
parent 60730edb7b
commit e35cca1830
3 changed files with 20 additions and 16 deletions

6
sdf.go
View file

@ -1,6 +1,8 @@
package main
import "math"
import (
"math"
)
type SDF interface {
Distance(Vector3) (float64, Material)
@ -121,7 +123,7 @@ func (s SmoothUnionSDF) Distance(p Vector3) (float64, Material) {
h := math.Max(k-math.Abs(d1-d2), 0.0)
d := math.Min(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
}