Title: Problems in custom ray marcher Post by: Efoia on September 17, 2016, 05:05:47 PM Hello all, I've been struggling with a few problems in my custom ray marcher for quite some time (on and off for months) and was hoping to get some guidance. The ray marcher works fine for the KIFS fractals. For other fractals however, I get strange clipping and pinching issues. I've stripped my code down to the bare minimum needed to reproduce the problem and have included it in this post. I've tried distance equations from multiple sources and the problems persist, so this leads me to believe that the source of the problems is in the ray marcher itself.
Below are some of the issues I'm experiencing, the image colors correspond the the surface normals. The julia fractal appears correct at close camera distances, but starts clipping as the camera moves away. The screenshots below from top to bottom are me moving the camera away from the fractal: (http://i.imgur.com/Oogz93n.png) (http://imgur.com/Mu1hOkP.png) (http://imgur.com/AKsSSj2.png) (http://imgur.com/6TUzOLI.png) Here is the same problem occurring with the mandelbulb: (http://imgur.com/Xq8TGvs.png) (http://imgur.com/Mf8fipv.png) (http://imgur.com/UdGfWNv.png) (http://imgur.com/Q8vxz0x.png) The knot fractal appears to work correctly initially: (http://imgur.com/6iYkkjL.png) But at some camera angles I see what looks like pinches in the surface: (http://imgur.com/bOf1bjI.png) I also get these artifacts: (http://imgur.com/MnhgF1X.png) Here is a variant that looks correct from one angle: (http://imgur.com/4I7GzNy.png) But from a side camera angle it appears completely incorrect: (http://imgur.com/tFePKqC.png) Here is my ray marcher stripped down to only the necessary parts: Code: #version 330 core Here is how I'm calculating the model matrix that I use for the camera view: Code: glm::mat4 modelMatrix = glm::mat4(1.0f); Julia distance equation for reference. I don't think the distance equations themselves are relevant to the problem but I can post the others if requested: Code: float DE(vec3 point) Thanks for your time. Title: Re: Problems in custom ray marcher Post by: Buddhi on September 17, 2016, 06:32:15 PM It looks like overstepping during ray-marching.
Try to reduce ray-marching step by multiplying estimated distance by some number lower than 1.0, e.g.: float d = DE(p); t += 0.5 * d; DE() calculates only estimated distance so it can be much to high in some cases. Title: Re: Problems in custom ray marcher Post by: Efoia on September 17, 2016, 09:34:40 PM Thank you so much for your reply, overstepping was precisely the source of the problem! In a single line of code you have ended a months-long headache for me! :beer: :beer: :beer: From the complete renderer: (http://i.imgur.com/Slaqdu9.png) |