fogleman / pt

A path tracer written in Go.
MIT License
2.08k stars 110 forks source link

Crytek sponza not working :'( #15

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello. I trying crytek sponza (not dabrovic). And gets these errors.

Code

package main

// http://graphics.cs.williams.edu/data/meshes/dabrovic-sponza.zip

import . "../pt"

func main() {
    scene := Scene{}
    material := GlossyMaterial(HexColor(0xFCFAE1), 1.5, Radians(20))
    mesh, err := LoadOBJ("sponza.obj", material)
    if err != nil {
        panic(err)
    }
    mesh.MoveTo(Vector{}, Vector{0.5, 0, 0.5})
    scene.Add(mesh)
    scene.Add(NewSphere(Vector{0, 20, 0}, 3, LightMaterial(White, 100)))
    camera := LookAt(Vector{-10, 2, 0}, Vector{0, 4, 0}, Vector{0, 1, 0}, 45)
    sampler := NewSampler(4, 4)
    renderer := NewRenderer(&scene, &camera, sampler, 960, 540)
    renderer.IterativeRender("out%03d.png", 1000)
}

Error

C:\Users\acterhd\Downloads\pt-master\examples>go run sponza.go
Loading OBJ: sponza.obj
Loading MTL: sponza.mtl
Loading IMG: textures\sponza_thorn_diff.png
Loading IMG: textures\sponza_thorn_bump.png
Loading IMG: textures\vase_round.png
Loading IMG: textures\vase_round_bump.png
Loading IMG: textures\vase_plant.png
Loading IMG: textures\background.png
Loading IMG: textures\background_bump.png
Loading IMG: textures\gi_flag.png
Loading IMG: textures\spnza_bricks_a_diff.png
Loading IMG: textures\spnza_bricks_a_bump.png
Loading IMG: textures\sponza_arch_diff.png
Loading IMG: textures\sponza_ceiling_a_diff.png
Loading IMG: textures\sponza_column_a_diff.png
Loading IMG: textures\sponza_column_a_bump.png
Loading IMG: textures\sponza_floor_a_diff.png
Loading IMG: textures\sponza_column_c_diff.png
Loading IMG: textures\sponza_column_c_bump.png
Loading IMG: textures\sponza_details_diff.png
Loading IMG: textures\sponza_column_b_diff.png
Loading IMG: textures\sponza_column_b_bump.png
Loading IMG: textures\sponza_flagpole_diff.png
Loading IMG: textures\sponza_fabric_green_diff.png
Loading IMG: textures\sponza_fabric_blue_diff.png
Loading IMG: textures\sponza_fabric_diff.png
Loading IMG: textures\sponza_curtain_blue_diff.png
Loading IMG: textures\sponza_curtain_diff.png
Loading IMG: textures\sponza_curtain_green_diff.png
Loading IMG: textures\chain_texture.png
Loading IMG: textures\chain_texture_bump.png
Loading IMG: textures\vase_hanging.png
Loading IMG: textures\vase_dif.png
Loading IMG: textures\vase_bump.png
Loading IMG: textures\lion.png
Loading IMG: textures\lion_bump.png
Loading IMG: textures\sponza_roof_diff.png
Loading IMG: textures\sponza_roof_bump.png
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x38 pc=0x4596c6]

goroutine 1 [running]:
panic(0x505b60, 0xc04200c090)
        C:/Go/src/runtime/panic.go:500 +0x1af
_/C_/Users/acterhd/Downloads/pt-master/pt.LoadMTL(0xc04205c4a7, 0xa, 0x3fef2d779e37e205, 0x3feea2c5857ecb8e, 0x3fe84c2e92434b0b, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/obj.go:137 +0x5c6
_/C_/Users/acterhd/Downloads/pt-master/pt.LoadOBJ(0x526f3e, 0xa, 0x3fef2d779e37e205, 0x3feea2c5857ecb8e, 0x3fe84c2e92434b0b, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/obj.go:46 +0x1423
main.main()
        C:/Users/acterhd/Downloads/pt-master/examples/sponza.go:10 +0x1fd
exit status 2

There these models, with you can test https://1drv.ms/f/s!AgEr-N6c2tdUhLMh11zNIP1besSUbQ

ghost commented 7 years ago

Okay, I changed textures.... (rm bump of roof)

But got this error


[Iteration 1 of 1000]
Building k-d tree (262267 shapes)... OK
Building k-d tree (2 shapes)... OK
960 x 540 pixels, 1 spp, 4 cores
  19 / 540 (  3%) [=                                 ] 0:00:00 892.8k panic: runtime error: index out of range

goroutine 5 [running]:
panic(0x505b60, 0xc04200c040)
        C:/Go/src/runtime/panic.go:500 +0x1af
_/C_/Users/acterhd/Downloads/pt-master/pt.(*ColorTexture).bilinearSample(0xc0420904b0, 0x3fe7aabde161d42a, 0x3ff0000000000000, 0x407a9bd4f8009550, 0x0, 0x40826f83ac14a23b)
        C:/Users/acterhd/Downloads/pt-master/pt/texture.go:85 +0x2b6
_/C_/Users/acterhd/Downloads/pt-master/pt.(*ColorTexture).Sample(0xc0420904b0, 0x3fe7aabde161d42a, 0x0, 0xbff0000000000000, 0x0, 0x3ff0000000000000)
        C:/Users/acterhd/Downloads/pt-master/pt/texture.go:99 +0xbe
_/C_/Users/acterhd/Downloads/pt-master/pt.(*ColorTexture).NormalSample(0xc0420904b0, 0x3fe7aabde161d42a, 0x0, 0x0, 0xbff0000000000000, 0x0)
        C:/Users/acterhd/Downloads/pt-master/pt/texture.go:103 +0x4e
_/C_/Users/acterhd/Downloads/pt-master/pt.(*Triangle).NormalAt(0xc086f36c40, 0xc079274bfdb29960, 0x406ec7ec56d5cfac, 0x408337b309db3dae, 0xc086f36c40, 0x407a9bd4f8009550, 0x0)
        C:/Users/acterhd/Downloads/pt-master/pt/triangle.go:97 +0x5d8
_/C_/Users/acterhd/Downloads/pt-master/pt.(*Hit).Info(0xc0b2dc6b70, 0xc047a31ff4ed7a0c, 0x40271810624dd2e0, 0x408317f3c3023fd6, 0xbfeab256c2fec40a, 0x3fe1a410b10a7d60, 0x3f8316fc5afaf20d, 0x0, 0x0, 0x0, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/hit.go:30 +0x13c
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).sample(0xc094502420, 0xc04207c070, 0xc047a31ff4ed7a0c, 0x40271810624dd2e0, 0x408317f3c3023fd6, 0xbfeab256c2fec40a, 0x3fe1a410b10a7d60, 0x3f8316fc5afaf20d, 0x3fe2c839d4860b01, 0x1, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:64 +0x121
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).sample(0xc094502420, 0xc04207c070, 0xc039de19614f59ae, 0x405efbec56d5cfaa, 0x40721ddf17a5bb55, 0xbfb013592c041b88, 0xbfd5198ee0e5647b, 0x3fee24ddd921c491, 0x3fde3db7c953ae01, 0x1, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:93 +0x6a1
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).sample(0xc094502420, 0xc04207c070, 0x40077c2eb12d5867, 0x40271810624dd2f0, 0xc003ad114f974ba0, 0xbfb771e424b4ae46, 0x3fd6decd3cc95608, 0x3fedbe381b97e19f, 0x3f76834721f39601, 0x1, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:93 +0x6a1
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).sample(0xc094502420, 0xc04207c070, 0x400b6c480bce5488, 0x4024ed42c3c9eec8, 0xc009be8aa4d4d49d, 0xbfd65250b438eda8, 0x3fe891b3433a1dd8, 0x3fe132dc6ba501b7, 0x3fdd582c48ab8900, 0x1, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:93 +0x6a1
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).sample(0xc094502420, 0xc04207c070, 0xc024000000000000, 0x4000000000000000, 0x0, 0x3fea881998d68c80, 0x3fe0b8f73a6ff40f, 0xbfc96f0146b8da6b, 0x46f601, 0x4, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:99 +0x4e1
_/C_/Users/acterhd/Downloads/pt-master/pt.(*DefaultSampler).Sample(0xc094502420, 0xc04207c070, 0xc024000000000000, 0x4000000000000000, 0x0, 0x3fea881998d68c80, 0x3fe0b8f73a6ff40f, 0xbfc96f0146b8da6b, 0xc0b2dbe000, 0x4000000000000000, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/sampler.go:53 +0x8c
_/C_/Users/acterhd/Downloads/pt-master/pt.(*Renderer).run.func1(0x21c, 0x4, 0x3c0, 0xc04207c150, 0x1, 0xc08351c580, 0x5a62c0, 0xc094502420, 0xc04207c070, 0xc094502450, ...)
        C:/Users/acterhd/Downloads/pt-master/pt/renderer.go:86 +0x9a9
created by _/C_/Users/acterhd/Downloads/pt-master/pt.(*Renderer).run
        C:/Users/acterhd/Downloads/pt-master/pt/renderer.go:119 +0x392
exit status 2
dakerfp commented 7 years ago

I just properly renamed the filenames. It worked.