Closed Cewein closed 3 years ago
so maybe it's the code behind the BVH who's bad, i will try to look into the PBRT Book code base and import as a third party there bvh to see if i work. and also look into radeon rays
So, looking at the code of PBRT didn't help, I will look into 3 potential sources :
We have to keep in mind with the GLSL BVH traversal it cannot be don't with recursive functions.
this will mark the point of merge for the bvh because i'm loosing to much time on the bvh, i want to focus more on the light transport part.
I will do a recap of what the bvh do and not do as of now :
it might come from two thing, the triangle in the bvh are poorly setup so the leaf boxs contains the wrong tris or it's my traversal in the code who's wrong.
bvh will have more support in the future but taking a break on it as of know
the bug is found !
As you can see in the picture above the triangle are outside the leaf rather being in it. The triangles in the nodes are wrong, so the bug come from here.
alright after some dumping of the BVH and the Triangles data, i've come up with a small python script to debug the whole thing :
# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import numpy as np
import matplotlib.pyplot as plt
import pandas
#open the data files
bvh = np.array(pandas.read_csv("bvh.csv"))
tris = np.array(pandas.read_csv("tris.csv"))
#selection a triangle to watch
nTri = 122
#get the triangle and the bvh leaf
index = np.where(triangle[:,0] == nTri)
indexBVH = np.where(bvh[:,9] == nTri)
#data alignement
tri = tris[index,:][0][0]
leaf = bvh[indexBVH,:][0][0]
#ploting
fig = plt.figure()
ax = Axes3D(fig)
#plot the triangle
x = [tri[1],tri[5],tri[9]]
y = [tri[2],tri[6],tri[10]]
z = [tri[3],tri[7],tri[11]]
verts = [list(zip(x,y,z))]
ax.add_collection3d(Poly3DCollection(verts))
#plot the bvh node
xs = [leaf[1],leaf[5]]
ys = [leaf[2],leaf[6]]
zs = [leaf[3],leaf[7]]
ax.scatter(xs, ys, zs, marker=m, color='red')
#show everything
plt.show()
this show us as it should the wrong leaf and the wrong tris
here the data files if you want to experiment yourself dump.zip
it's been more than a month since https://github.com/Cewein/nerv_pathtracer/commit/2b5fb4002459b63c3f11c6c4314d5b74b7524b6f
so here a run down of the actual state of the BVH acceleration :
normally it should boost the performance but, it doesn't. the problem is heavly worked on before touching at anything else like shadow or light because it will be a great help in the and.
as of know a bug come in when the is a interaction with the bouding boxes, on the other hand the BVH tree is ok because when doing a stack traversal the model is fully rendered.
More info will come since it the holiday and now i have time to work on it. University put a harder stop than I trough to this project.