diff --git a/src/main.go b/src/main.go index d17e93f..8b092f2 100644 --- a/src/main.go +++ b/src/main.go @@ -15,7 +15,7 @@ import ( const WIDTH = 200 const HEIGHT = 200 -const TEXTURE_SCALE = 2 +const TEXTURE_SCALE = 4 const MAX_DIST = 500.0 const MAX_STEP = 100 @@ -32,6 +32,8 @@ var screenSpherical Vector3 var screenPhysicalSize float64 var cameraPos Vector3 +var sphere TranslatedSDF + func init() { lightPos = Vector3{100, -400, 400} @@ -44,8 +46,7 @@ func update(t float64) { sphereMat := RED_MAT sphereMat.specularFac = 0.5 - sphere := TranslatedSDF{Sphere{10, sphereMat}, Vector3{-15, 100, 10}} - sphere2 := TranslatedSDF{Sphere{10, sphereMat}, Vector3{15, 100, 10}} + sphere = TranslatedSDF{Sphere{10, sphereMat}, Vector3{0, 100, 10}} // boxMat := BLUE_MAT // box := TranslatedSDF{Box{Vector3{10, 2, 10}, boxMat}, Vector3{0, 100, 10}} @@ -53,9 +54,7 @@ func update(t float64) { plane := Plane{Vector3{0, 0, 1}, WHITE_GREY_GRID_MAT} sphere.translate.Z = 20 * math.Sin(t) - 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 = SmoothUnionSDF{sphere, plane, 2.5} // scene = UnionSDF{plane, sphere} } @@ -70,7 +69,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, 5) + hit, colorVec := rayMarch(origin, direction, 1) var fr, fg, fb float64 if hit { fr, fg, fb = colorVec.Unpack() @@ -121,7 +120,7 @@ func main() { for !rl.WindowShouldClose() { new_time := rl.GetTime() dt := new_time - time - t += dt * 0.4 + t += dt time = new_time update(t) diff --git a/src/material.go b/src/material.go index bb10ee7..d238e1a 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.5, + reflectanceFac: 0.2, reflectanceTint: Vector3{255, 255, 255}, refractFac: 0.0, refractIndice: 1.0,