kidoman / rays

Ray tracing based language benchmarks
https://kidoman.com/programming/go-getter.html
95 stars 23 forks source link

Maintain FOV #11

Closed t-mat closed 10 years ago

t-mat commented 10 years ago

Currently, we get different field of view (FOV) image when we set -width and -height. So when increase resolution, almost all rays go straight to sky or ground. And amount of computation is not increase properly.

Following change resolve this problem :

// original
dir := t.Scale(-1)
    .Add(
        a.Scale(rnd(seed) + float64(x))
        .Add(b.Scale(float64(r) + rnd(seed)))
        .Add(c)
        .Scale(16)
    ).Normalize()
// modified
dir := t.Scale(-1)
    .Add(
        a.Scale(rnd(seed) + float64(x*512) / float64(*width))
        .Add(b.Scale(float64(r*512) / float64(*height) + rnd(seed)))
        .Add(c)
        .Scale(16)
    ).Normalize()

This solution make different problem

kidoman commented 10 years ago

This is definitely something I have been thinking about. To make the higher resolution benchmarks "effective" we need to be able to scale the rendered "image" along with the image size

kidoman commented 10 years ago

I have implemented some changes in the Go version. Will need to port these over to the other programs. Thanks for finding the fix