The Lambda Lab
/
projects
/
raymarcher.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switched output format to P6.
[raymarcher.git]
/
Render.lua
diff --git
a/Render.lua
b/Render.lua
index
17f244d
..
57cb407
100644
(file)
--- a/
Render.lua
+++ b/
Render.lua
@@
-43,7
+43,7
@@
local function render(scene, width, height, filename)
print("Rendering to file " .. filename .. "...")
local f = io.open(filename, "w")
print("Rendering to file " .. filename .. "...")
local f = io.open(filename, "w")
- f:write("P
3
", width, " ", height, " 255\n")
+ f:write("P
6
", width, " ", height, " 255\n")
local c = scene.camera
local cam_dir = V.normalize(c.point_at - c.location)
local c = scene.camera
local cam_dir = V.normalize(c.point_at - c.location)
@@
-64,15
+64,13
@@
local function render(scene, width, height, filename)
for x=1,width do
local ray_dir = normalize(rayy + right*((x/width - 0.5)*c.fov))
local col = march(c.location, c.location, ray_dir, scene.sdf, 0)
for x=1,width do
local ray_dir = normalize(rayy + right*((x/width - 0.5)*c.fov))
local col = march(c.location, c.location, ray_dir, scene.sdf, 0)
- col = {math.
min(col[1]*255, 255
),
- math.
min(col[2]*255, 255
),
- math.
min(col[3]*255, 255
)}
+ col = {math.
floor(math.min(col[1]*255, 255)
),
+ math.
floor(math.min(col[2]*255, 255)
),
+ math.
floor(math.min(col[3]*255, 255)
)}
- f:write(
math.floor(col[1]), " ", math.floor(col[2]), " ", math.floor(col[3]), " "
)
+ f:write(
string.char(col[1]), string.char(col[2]), string.char(col[3])
)
end
end
- f:write("\n")
end
end
- f:write("\n")
f:close()
f:close()