Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BVH acceleration #12

Closed
Cewein opened this issue Dec 19, 2020 · 5 comments
Closed

BVH acceleration #12

Cewein opened this issue Dec 19, 2020 · 5 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@Cewein
Copy link
Owner

Cewein commented Dec 19, 2020

it's been more than a month since 2b5fb40

so here a run down of the actual state of the BVH acceleration :

  • Computed on the CPU
  • Flatten and sended to the GPU
  • traversal is down inside the shader

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.

@Cewein Cewein added bug Something isn't working enhancement New feature or request labels Dec 19, 2020
@Cewein Cewein self-assigned this Dec 19, 2020
@Cewein Cewein added this to the Bounding volume Hierarchies milestone Dec 19, 2020
Cewein added a commit that referenced this issue Dec 19, 2020
added a option to debug the bvh.

#12
@Cewein
Copy link
Owner Author

Cewein commented Dec 19, 2020

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

@Cewein
Copy link
Owner Author

Cewein commented Dec 23, 2020

So, looking at the code of PBRT didn't help, I will look into 3 potential sources :

  • RTOW BVH tutorial
  • Radeon Ray BVH
  • Tinsel CUDA BVH

We have to keep in mind with the GLSL BVH traversal it cannot be don't with recursive functions.

Cewein added a commit that referenced this issue Dec 27, 2020
last push before the rewritte of the BVH
Cewein added a commit that referenced this issue Dec 28, 2020
the bvh traversal was hard to understand and the stack use was missleading ence the need of a rewrite
Cewein added a commit that referenced this issue Dec 31, 2020
the BVHBounds and Bounds sctruct where useless and added to much bloat the programm to we merged them into a unique one AABB struct.

we also update the whole code and BVHNode class in consequence

#12
Cewein added a commit that referenced this issue Jan 2, 2021
@Cewein
Copy link
Owner Author

Cewein commented Jan 2, 2021

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 :

  • bvh is creating a tree that work for the up to the leaf node but after the triangle detection is bugged

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

@Cewein Cewein added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Jan 2, 2021
@Cewein
Copy link
Owner Author

Cewein commented Jan 20, 2021

the bug is found !

bug

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.

@Cewein
Copy link
Owner Author

Cewein commented Jan 20, 2021

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
image

here the data files if you want to experiment yourself
dump.zip

@Cewein Cewein closed this as completed in e3c9446 Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant