I'm looking into ways to add more shapes to my hobby path tracer, such as cylinder, cone, ellipse. So, I'm at this reference:
http://www.bmsc.washington.edu/people/m ... drics.html which is taken from Lindley book on ray tracing (which I also have, but without CD). It briefly explains generalized quadratic formula with A...J parameters and how to calculate normals.
While this could be what I need, there is no much detail on meaning of AJ parameters. For instance If I take ellipse, then ideally I would want to specify it in terms of 'a' and 'b' radius on the x and y exes respectively, origin and orientation (3x3 matrix).
Can anyone please point me to where to learn more about these AJs parameters or alternative (simple) approaches.
Thank you very much in advance.
Intersection of ray with quadric surface for hobby ray tracer
Re: Intersection of ray with quadric surface for hobby ray tracer
Here's an explanation of how to build up the 4x4 matrix for several quadric types: https://www.siggraph.org/education/mate ... inter4.htm
I believe that Glassner's 1980's book "Introduction to Ray Tracing" also has a paragraph on this.
There's a ray/quadric implementation in the ray tracing skeleton program of the programming course that I teach at University: https://vis.unikoeln.de/raytracer0.html (the program itself won't compile out the box, making it compile is part of the students' task, anyhow, the "geoquadric" class should work right away).
Cheers, Stefan
I believe that Glassner's 1980's book "Introduction to Ray Tracing" also has a paragraph on this.
There's a ray/quadric implementation in the ray tracing skeleton program of the programming course that I teach at University: https://vis.unikoeln.de/raytracer0.html (the program itself won't compile out the box, making it compile is part of the students' task, anyhow, the "geoquadric" class should work right away).
Cheers, Stefan
Re: Intersection of ray with quadric surface for hobby ray tracer
This here paper btw. uses quadrics to project 3D ellipsoids to 2D: https://pdfs.semanticscholar.org/df2e/0 ... b231e6.pdf
Re: Intersection of ray with quadric surface for hobby ray tracer
The explanation behind general quadrics is not so simple and obvious. It does get quite tedious doing the math with 10 quadric coefficients and 12 more coefficients of a general affine transform.
If you feel like digging through the source code of another toy raytracer, I can offer an older experiment of mine:
http://www.vectorizer.org/boar/boarCore1.tar.bz2
http://www.vectorizer.org/boar/boarCore ... nt.tar.bz2
The first tarball is just the source. In transform.c++ is code for the usual rotations and translations, as well as concatenating such transforms. In quadric.c++ there are initialization routines for common shapes (sphere, cylinder, cone) and less common shapes (slab, lathe, product of planes). The quadric class also knows how to transform a quadric given an affine transform.
The second tarball contains an explanation of the scene description language (heavily inspired by PoVRay, http://www.povray.org), and an example scene file. I think the three syntaxes (in the doc, in the actual parser, and in the example scene) do slightly differ from each other  this is not a proper release, sorry.
The source code is moderately commented. I have since abandoned this particular approach, but will gladly answer any questions you might have.
If you feel like digging through the source code of another toy raytracer, I can offer an older experiment of mine:
http://www.vectorizer.org/boar/boarCore1.tar.bz2
http://www.vectorizer.org/boar/boarCore ... nt.tar.bz2
The first tarball is just the source. In transform.c++ is code for the usual rotations and translations, as well as concatenating such transforms. In quadric.c++ there are initialization routines for common shapes (sphere, cylinder, cone) and less common shapes (slab, lathe, product of planes). The quadric class also knows how to transform a quadric given an affine transform.
The second tarball contains an explanation of the scene description language (heavily inspired by PoVRay, http://www.povray.org), and an example scene file. I think the three syntaxes (in the doc, in the actual parser, and in the example scene) do slightly differ from each other  this is not a proper release, sorry.
The source code is moderately commented. I have since abandoned this particular approach, but will gladly answer any questions you might have.
Re: Intersection of ray with quadric surface for hobby ray tracer
Thanks a lot! I'm still testing, but it started to work now.
Also found relatively simple and compact ref here: https://people.cs.clemson.edu/~dhouse/c ... adrics.pdf
My next challenge is solid constructions.
Also found relatively simple and compact ref here: https://people.cs.clemson.edu/~dhouse/c ... adrics.pdf
My next challenge is solid constructions.
 Attachments

 path_trace1.jpeg (45.77 KiB) Viewed 8823 times
Re: Intersection of ray with quadric surface for hobby ray tracer
My code above is not a good reference for constructive solid geometry. It does have a rather inefficient implementation; but that would only make sense in conjunction with spatial subdivision (where the voxels contained only pruned CSG subtrees).asyrov wrote:My next challenge is solid constructions.
Re: Intersection of ray with quadric surface for hobby ray tracer
BRLCAD has OpenCL code for quite a lot of primitives:
https://svn.code.sf.net/p/brlcad/code/b ... rimitives/
We are still working on porting primitives over but this is what we have already:
https://svn.code.sf.net/p/brlcad/code/b ... rimitives/
We are still working on porting primitives over but this is what we have already:
 an equation solver (solves quartic, cubic, and quadric equations).
 rayprimitive and surface normal code for: Bag o' Triangles (trimeshes), Arbitrary Polyhedrons, Elliptical Hyperboloids, Generalized Ellipsoids, Elliptical Paraboloids, Elliptical Torus, Right Elliptical Cylinders, Right Hyperbolic Cylinders, Right Parabolic Cylinders, Spheres, Truncated General Cones, Torus, and more...