1
votes

I was able to get a starter code for a ray tracer online and the starter code has two "Geometries":

class sphere

class triangle

I understand the triangle since the code creates a mesh using triangles and gets the intersection between triangles and ray from each pixel. But how does sphere come into play?

So I've done some online researching and a lot of them discuss about triangle intersection and sphere intersection. but how do we use sphere in mesh?

1
"how does sphere come into play" - How should we know? All you've told us is the ray tracer includes one.Captain Obvlious
@CaptainObvlious I guess i'm expecting an answer from people who know about ray tracing algorithm. A lot of ray tracing textbooks have triangles and spheres as primitives. I get the triangles but i don't understand how spheres work unless they are used in meshJayC
@CaptainObvlious I guess i should've made it clear that i am asking about the ray tracing algorithm. Even if I provide the code to you, i don't think you would know but thanks for commenting captain oblivious.JayC
Aside from your snarky attitude yhe problem is your post is unclear. "how does sphere come into play" is pretty broad and can mean anything from how is it implemented to how does it interact with other objects to how is it managed. If you want to know how spheres work then that's the question you should be asking.Captain Obvlious
whoa, shots fired haha. I'm just here to ask why a lot of ray tracing algorithms explain about spheres. i know my question isn't the most specific question out there but that's also the reason why i'm asking so that people who know about it can guide me through it. also snarky? haha. you're the one who got all snarky with your first comment. but it's cool man.JayC

1 Answers

1
votes

A mesh is a collection of triangles and to render that object using ray tracing, you have to solve lots of ray tracing equations with all the triangles. However, a sphere has a closed form implicit function for which solving the ray intersection is very easy. These two sample object are coming from the fact that we have two ways of representing objects in computer graphics, implicit objects for which we have a closed form implicit functions and polygonal mesh representation for which we have a collection of triangles. Usually, in ray tracing, we have objects such as sphere, cylinder, plane (triangle), and torus for which we have a closed form function and we can find their intersection with rays. For complicated objects like bunny, ray is casted and intersected with a collection of planes (triangles).