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

GeomID, PrimID in Pathtracer Tutorial #457

Open
tbhunderbird opened this issue Aug 31, 2023 · 5 comments
Open

GeomID, PrimID in Pathtracer Tutorial #457

tbhunderbird opened this issue Aug 31, 2023 · 5 comments

Comments

@tbhunderbird
Copy link

I am trying to figure out, where and how geometry IDs and primitive IDs are assigned in the Tutorial Code (specifically the pathtracer tutorial).
Could someone please help me to understand how a read .obj file with a single mesh ends up with hundreds of primitive IDs and thousands of geometry Ids?

All the best and thanks,
Tobias

@svenwoop
Copy link
Collaborator

The Embree API supports geometries (such as triangle meshes) and primitives inside these geometries (such as triangles inside a triangle mesh). You attach geometries to Embree scenes, and the slot it got attached corresponds to the geometry ID returned. The n'th triangle has primitive ID of n.
The pathtracer in default mode loads an obj mesh and splits it up into geometries/triangle meshes whenever a different material is used. What do you want to do? The precise way of splitting the input into geometries does not matter from the pathtracer side much, the pathtracer itself just indexes with these geomIDs into its scene representation to access materials for instance, or use the primID to access triangle vertices when required.

@tbhunderbird
Copy link
Author

I have two associated problems/ideas in mind:
1.) I need to generate a pseudo-random number that is always the same, when the same triangle is hit. I guess I could use the combination of geom and prim ID if I understand you correctly.
2.) I need to know which of the added geometried is hit (obj1, obj2, ...). How would I do that?

@svenwoop
Copy link
Collaborator

  1. Yes, the geomID/primID pair identifies your triangle in default mode (no instancing)
  2. The geometry/triangle mesh is identified by the geomID

@tbhunderbird
Copy link
Author

Regarding 2.) use case:
You mentioned that the pathtracer splits it up into geometries whenever a new material is encountered. Thus, the geomId is more or less random and I cannot infer the original object ID I added.
Is there a way to assign some sort of ID that I can infer or read once I found an intersection?

@svenwoop
Copy link
Collaborator

You could change the OBJ loader to create a mesh for each object. Have a look at the obj_loader.cpp and execute flushFaceGroup at the places you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants