From b5c9eaf692959bd620791ec362099885173300e9 Mon Sep 17 00:00:00 2001 From: Crizomb Date: Sun, 28 Sep 2025 17:50:16 +0200 Subject: [PATCH] little scene change --- src/main.go | 15 ++++++++------- src/material.go | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.go b/src/main.go index 8b092f2..d17e93f 100644 --- a/src/main.go +++ b/src/main.go @@ -15,7 +15,7 @@ import ( const WIDTH = 200 const HEIGHT = 200 -const TEXTURE_SCALE = 4 +const TEXTURE_SCALE = 2 const MAX_DIST = 500.0 const MAX_STEP = 100 @@ -32,8 +32,6 @@ var screenSpherical Vector3 var screenPhysicalSize float64 var cameraPos Vector3 -var sphere TranslatedSDF - func init() { lightPos = Vector3{100, -400, 400} @@ -46,7 +44,8 @@ func update(t float64) { sphereMat := RED_MAT sphereMat.specularFac = 0.5 - sphere = TranslatedSDF{Sphere{10, sphereMat}, Vector3{0, 100, 10}} + sphere := TranslatedSDF{Sphere{10, sphereMat}, Vector3{-15, 100, 10}} + sphere2 := TranslatedSDF{Sphere{10, sphereMat}, Vector3{15, 100, 10}} // boxMat := BLUE_MAT // box := TranslatedSDF{Box{Vector3{10, 2, 10}, boxMat}, Vector3{0, 100, 10}} @@ -54,7 +53,9 @@ func update(t float64) { plane := Plane{Vector3{0, 0, 1}, WHITE_GREY_GRID_MAT} sphere.translate.Z = 20 * math.Sin(t) - scene = SmoothUnionSDF{sphere, plane, 2.5} + sphere2.translate.Z = 20 * math.Sin(t*0.5) + // scene = SmoothUnionSDF{SmoothUnionSDF{sphere, plane, 2.5}, sphere2, 2.5} + scene = UnionSDF{UnionSDF{sphere, plane}, sphere2} // scene = UnionSDF{plane, sphere} } @@ -69,7 +70,7 @@ func compute_pixel(y0 int, y1 int, wg *sync.WaitGroup, screenCenter Vector3, phi origin := screenCenter.Add(phiVec.Scale(-sx)).Add(thetaVec.Scale(sy)) direction := (origin.Sub(cameraPos)).Normalized() - hit, colorVec := rayMarch(origin, direction, 1) + hit, colorVec := rayMarch(origin, direction, 5) var fr, fg, fb float64 if hit { fr, fg, fb = colorVec.Unpack() @@ -120,7 +121,7 @@ func main() { for !rl.WindowShouldClose() { new_time := rl.GetTime() dt := new_time - time - t += dt + t += dt * 0.4 time = new_time update(t) diff --git a/src/material.go b/src/material.go index d238e1a..bb10ee7 100644 --- a/src/material.go +++ b/src/material.go @@ -88,7 +88,7 @@ func DefaultMaterial(diffuseColor Color) MaterialBrut { specularColor: Vector3{255, 255, 255}, specularFac: 1, specularExp: 35.0, - reflectanceFac: 0.2, + reflectanceFac: 0.5, reflectanceTint: Vector3{255, 255, 255}, refractFac: 0.0, refractIndice: 1.0, -- 2.47.3