Fix error where it would show wrong function in error
This commit is contained in:
@@ -14,6 +14,9 @@ Raymarcher_Update :: ()
|
||||
forward := Vec3{0, 0, -1}
|
||||
side := Vec3_Normalize(Vec3_Cross(forward, up))
|
||||
|
||||
light_pos := Vec3{0, 4, 0}
|
||||
|
||||
|
||||
Xf := 1 / X->F32
|
||||
Yf := 1 / Y->F32
|
||||
ratio := X->F32 / Y->F32
|
||||
@@ -22,13 +25,14 @@ Raymarcher_Update :: ()
|
||||
uv := Vec3{x->F32 * Xf * 2 - 1, y->F32 * Yf * 2 - 1, 1.0}
|
||||
uv.x *= ratio
|
||||
dir := Vec3_Normalize(Vec3{Vec3_Dot(side, uv), Vec3_Dot(up, uv), Vec3_Dot(forward, uv)})
|
||||
pos := Vec3{0, 0, 5}
|
||||
pos := Vec3{0, 0, 2}
|
||||
|
||||
t: F32
|
||||
end: F32 = 100.0
|
||||
hit := true
|
||||
p: Vec3
|
||||
for i := 0, i < 255, i+=1
|
||||
p := Vec3_Add(pos, Vec3_MulF32(dir, t))
|
||||
p = Vec3_Add(pos, Vec3_MulF32(dir, t))
|
||||
|
||||
distance := SphereSDF(p)
|
||||
if distance < Epsilon
|
||||
@@ -40,8 +44,16 @@ Raymarcher_Update :: ()
|
||||
break
|
||||
|
||||
if hit
|
||||
Screen[x + y*X] = Vec3_ConvertToARGB({1, uv.y, 0})
|
||||
|
||||
normal := Vec3_Normalize(Vec3{
|
||||
SphereSDF({p.x + Epsilon, p.y, p.z}) - SphereSDF({p.x - Epsilon, p.y, p.z}),
|
||||
SphereSDF({p.x, p.y + Epsilon, p.z}) - SphereSDF({p.x, p.y - Epsilon, p.z}),
|
||||
SphereSDF({p.x, p.y, p.z + Epsilon}) - SphereSDF({p.x, p.y, p.z - Epsilon}),
|
||||
})
|
||||
|
||||
diffuse := Vec3_Dot(normal, Vec3_Negate())
|
||||
|
||||
Screen[x + y*X] = Vec3_ConvertToARGB(normal)
|
||||
|
||||
else;; Screen[x + y*X] = 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user