is there people good enough for a math problem (for a shader)? I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping space, no raymarching, at least axis aligned.

The goal is to write a shader. The benefit, is that, since it's analytic, I can do trick by passing parameters with the texture per pixel.

I already do this by abusing simpler variants of of interior design, by cranking the space between side low, and get dense (simple) foliage and grass for free, or brick walls, or any greebles. Except I'm confined to simple convex shapes with interior style shader, with this I could have more interesting parallax to abuse artistically. I use the flow of the polygon surface to create interesting shapes, and UV texture to break pattern artistically. Work wonder for low specs machine!

I figure out how to do it with a single point at the boundaries of the space, using the planet alignment problem (akin to the two clock hand overlap problem). But I failed to generalized it.



This problem is similar to this math problem https://amininima.wordpress.com/2013/05/27/the-laser-gun/

But without the reflection. enter image description here

Other potential benefits is that it have a period we can find mathematically, we could probably infer an analytical "overdraw", by "discarding depth" have a "traversed thickness", if we generalized the, such as we can also shift the position of the primitive at each "jump", we could probably find a consistent "integral 3D noise", which would made cloud noise in convex volume much cheaper than marching.

Optionally "the graal" would be at least 1 period coil repeated on axis aligned. But we can't intersect cosine "cheaply", I tried using x² approximations but my math melted. A unit coil being an unwrap unit cylinder diagonal, was the next step explored, ie to intersect axis aligned cylinder then find on its surface the diagonal: Cylinder coil tracing sktech the idea above is, taking the perpendicular going through the cylinder center, we observe that the tracing "regularly" step through it, using that stepping and the slope of the ray, we can infer point on the wrapping surface of the cylinder, the entire idea is to find the step pattern so we can intersect the diagonal within a certain distance.

EDIT: While talking below in the comment, I realized that I probably could shift the 1D wrapping space to the 2D projection of the ray direction, then find the period of the primitive's "axis" projected on that line, and since I already found the case for 1D, use that to infer the remaining intersection. Just an idea not developed yet. Should make a drawing to show what I mean, it's not clear yet in words.

  • \$\begingroup\$ I think you're asking for a bit too much here. To handle any primitive generically, we'll almost certainly need to use raymarching. If we can't use raymarching, then we might be limited in the primitives that offer a closed-form solution to this problem, if indeed any do. Can you give us more context about what you're trying to do and why these constraints are necessary? \$\endgroup\$ – DMGregory Mar 8 at 11:30
  • \$\begingroup\$ Well I know it's possible because some people have done it, the dev of that clay game (he made that first pencil drawing that explain cylinder and sphere tracing) and some shadertoy demonstrate recursive space raytracing that isn't marching. The benefit are multiple, but I need single O(1) trace for open gl es 2.0, notably fur. I could so the single point version, I just failed to generalized. \$\endgroup\$ – user29244 Mar 8 at 13:07
  • \$\begingroup\$ Including a link would be a great start on the path toward a solution then. So far as I'm aware, Claybook does use raymarching, but there may be other examples we can learn from \$\endgroup\$ – DMGregory Mar 8 at 13:08
  • \$\begingroup\$ I have added to my former comment, but yes claybook do use raymarching, because the data is as good as random, BUT the dev did some experiment he shared on twitter, also the guy who made the blog demofox. I also linked the laser math problem that pose part of the problem, reposting here: amininima.wordpress.com/2013/05/27/the-laser-gun \$\endgroup\$ – user29244 Mar 8 at 13:12
  • \$\begingroup\$ I had made further exploration here: forum.unity.com/threads/… my main contribution is trying to get rid of the modulo by replacing it with a "beat synchronicity" system inspired by planet alignment/clock hand overlap math riddle here is the original tweet of seb aaltonen of Claybook fame: twitter.com/SebAaltonen/status/784692080765464576 \$\endgroup\$ – user29244 Mar 8 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.