little scene change #1

Merged
Crizomb merged 1 commit from dev into master 2025-09-28 18:43:03 +02:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit b5c9eaf692 - Show all commits

View file

@ -15,7 +15,7 @@ import (
const WIDTH = 200 const WIDTH = 200
const HEIGHT = 200 const HEIGHT = 200
const TEXTURE_SCALE = 4 const TEXTURE_SCALE = 2
const MAX_DIST = 500.0 const MAX_DIST = 500.0
const MAX_STEP = 100 const MAX_STEP = 100
@ -32,8 +32,6 @@ var screenSpherical Vector3
var screenPhysicalSize float64 var screenPhysicalSize float64
var cameraPos Vector3 var cameraPos Vector3
var sphere TranslatedSDF
func init() { func init() {
lightPos = Vector3{100, -400, 400} lightPos = Vector3{100, -400, 400}
@ -46,7 +44,8 @@ func update(t float64) {
sphereMat := RED_MAT sphereMat := RED_MAT
sphereMat.specularFac = 0.5 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 // boxMat := BLUE_MAT
// box := TranslatedSDF{Box{Vector3{10, 2, 10}, boxMat}, Vector3{0, 100, 10}} // 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} plane := Plane{Vector3{0, 0, 1}, WHITE_GREY_GRID_MAT}
sphere.translate.Z = 20 * math.Sin(t) 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} // 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)) origin := screenCenter.Add(phiVec.Scale(-sx)).Add(thetaVec.Scale(sy))
direction := (origin.Sub(cameraPos)).Normalized() direction := (origin.Sub(cameraPos)).Normalized()
hit, colorVec := rayMarch(origin, direction, 1) hit, colorVec := rayMarch(origin, direction, 5)
var fr, fg, fb float64 var fr, fg, fb float64
if hit { if hit {
fr, fg, fb = colorVec.Unpack() fr, fg, fb = colorVec.Unpack()
@ -120,7 +121,7 @@ func main() {
for !rl.WindowShouldClose() { for !rl.WindowShouldClose() {
new_time := rl.GetTime() new_time := rl.GetTime()
dt := new_time - time dt := new_time - time
t += dt t += dt * 0.4
time = new_time time = new_time
update(t) update(t)

View file

@ -88,7 +88,7 @@ func DefaultMaterial(diffuseColor Color) MaterialBrut {
specularColor: Vector3{255, 255, 255}, specularColor: Vector3{255, 255, 255},
specularFac: 1, specularFac: 1,
specularExp: 35.0, specularExp: 35.0,
reflectanceFac: 0.2, reflectanceFac: 0.5,
reflectanceTint: Vector3{255, 255, 255}, reflectanceTint: Vector3{255, 255, 255},
refractFac: 0.0, refractFac: 0.0,
refractIndice: 1.0, refractIndice: 1.0,