I want to represent ovaloids with ray-marching. I have ovaloids defined with an implicit equation.
For instance, we can consider the equation of an ellipsoid given as: $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} -1 = 0, $$ where $a, b, c$ are constant.
Given this equation I need to caculate the normal for the shading of the suface. In an standard course of Curves and Surfaces I would take $f(x,y,z) = \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} -1 $ and compute $N(p) = \frac{\nabla f(p)}{|\nabla f(p)|}$ as the normal of the surface.
Here I have to check that $0$ is a regular value of $f$ and that $f $ is differentiable. However, the second check is not automate.
- How can I calculate this normal from the implicit equation?
- How is it done in real-world systems?
- Can you give an explanation of the methods used and ideally point me some implementations that exist?
Please, answer in full generality and not only considering the example given above.