Use ternary if in a few more places in raytracer
This commit is contained in:
parent
8ba5345daf
commit
4545713bab
1 changed files with 8 additions and 16 deletions
|
|
@ -209,25 +209,17 @@ func log(x: f32) -> f32:
|
||||||
return logf(x)
|
return logf(x)
|
||||||
|
|
||||||
func abs(x: f32) -> f32:
|
func abs(x: f32) -> f32:
|
||||||
if x < 0.0:
|
return if x >= 0.0 then x else -x
|
||||||
return -x
|
|
||||||
return x
|
|
||||||
|
|
||||||
func min(x: f32, y: f32) -> f32:
|
func min(x: f32, y: f32) -> f32:
|
||||||
if x < y:
|
return if x <= y then x else y
|
||||||
return x
|
|
||||||
return y
|
|
||||||
|
|
||||||
func max(x: f32, y: f32) -> f32:
|
func max(x: f32, y: f32) -> f32:
|
||||||
if x > y:
|
return if x >= y then x else y
|
||||||
return x
|
|
||||||
return y
|
|
||||||
|
|
||||||
// I want function overloading so badly
|
// I want function overloading so badly
|
||||||
func min_u32(x: u32, y: u32) -> u32:
|
func min_u32(x: u32, y: u32) -> u32:
|
||||||
if x < y:
|
return if x <= y then x else y
|
||||||
return x
|
|
||||||
return y
|
|
||||||
|
|
||||||
func clamp(x: f32) -> f32:
|
func clamp(x: f32) -> f32:
|
||||||
return max(0.0, min(1.0, x))
|
return max(0.0, min(1.0, x))
|
||||||
|
|
@ -767,19 +759,19 @@ const default_fovy = 2.0 * atan(0.5)
|
||||||
func main():
|
func main():
|
||||||
let scene = make_default_scene()
|
let scene = make_default_scene()
|
||||||
|
|
||||||
// let image = create_image(512ul, 512ul)
|
let image = create_image(512ul, 512ul)
|
||||||
// let image = create_image(256ul, 256ul)
|
// let image = create_image(256ul, 256ul)
|
||||||
let image = create_image(128ul, 128ul)
|
// let image = create_image(128ul, 128ul)
|
||||||
|
|
||||||
let aspect_ratio = (image.width as f32) / (image.height as f32)
|
let aspect_ratio = (image.width as f32) / (image.height as f32)
|
||||||
let camera = camera(vec3(0.0, 0.0, 15.0), identity, default_fovy, compute_fovx(default_fovy, aspect_ratio))
|
let camera = camera(vec3(0.0, 0.0, 15.0), identity, default_fovy, compute_fovx(default_fovy, aspect_ratio))
|
||||||
|
|
||||||
// const samples_per_pixel = 16384ul
|
// const samples_per_pixel = 16384ul
|
||||||
// const samples_per_pixel = 4096ul
|
const samples_per_pixel = 4096ul
|
||||||
// const samples_per_pixel = 2048ul
|
// const samples_per_pixel = 2048ul
|
||||||
// const samples_per_pixel = 1024ul
|
// const samples_per_pixel = 1024ul
|
||||||
// const samples_per_pixel = 512ul
|
// const samples_per_pixel = 512ul
|
||||||
const samples_per_pixel = 256ul
|
// const samples_per_pixel = 256ul
|
||||||
// const samples_per_pixel = 16ul
|
// const samples_per_pixel = 16ul
|
||||||
// const samples_per_pixel = 1ul
|
// const samples_per_pixel = 1ul
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue