the Twarchive

This is a record of a twitter thread, originally posted in 2016

Thew
@AmazingThew

Good evening twitter

I have raymarched an Orb

Thew
@AmazingThew

Hello everyone

Now I have raymarched The Absence of an Orb

Thew
@AmazingThew

Hello again

As you have no doubt surmised, I have now raymarched a Vast Profusion of Orbs

Thew
@AmazingThew

For real though; pick a few colors that look nice together and use those for all your graphics tests. Makes boring experiments look cool

Thew
@AmazingThew

This was supposed to be a fisheye projection but uh

Thew
@AmazingThew

There are some super weird fish though so hey maybe

Thew
@AmazingThew

What If M. C. Escher Had Very Little Idea What He Was Doing

Thew
@AmazingThew

Raymarching has super interesting artifacts. Surfaces start attracting/interfering with each other at acute view angles

Thew
@AmazingThew

Don't understand the technique deeply enough to know exactly what causes this/how to fix it but not sure I want to right now

Thew
@AmazingThew

Oh okay I figured it out: To keep a cap on execution time, algo limits to how many steps it'll march before giving up. If a ray passes

Thew
@AmazingThew

super close to a surface but doesn't quite hit it, the step size ends up super tiny and you expend all remaining steps before getting

Thew
@AmazingThew

any significant distance past the surface. So curved surfaces end up with a halo of unresolved pixels around their edges

Cool!

Thew
@AmazingThew

Have seen some stuff on shadertoy that doesn't have this problem so I guess a solution exists

Thew
@AmazingThew

I guess as a last resort temporal filtering could fix it in most cases. Overkill for my purposes though

Thew
@AmazingThew

The camera code in the tutorial I started with is total garbage but my attempts at writing my own are proving... interesting

Thew
@AmazingThew

Hey this looks correct

*increases fov*

Hmm

Thew
@AmazingThew

If nothing else, raymarching bugs are certainly more interesting than vertex shader bugs

Thew
@AmazingThew

Hmmmm

Thew
@AmazingThew

Weird thought: Hypothetically, an alien brain could make perfect sense of these images

Thew
@AmazingThew

They contain the same information as a "normal" perspective image; the projection's just totally different from what we're used to

Thew
@AmazingThew

The worst part is when I actually get this working it'll look like a totally normal render instead of all this cool weirdness

Thew
@AmazingThew

Thew
@AmazingThew

Thew
@AmazingThew

Thew
@AmazingThew

Okay here we go; finally got fisheye projection working

Told you it wouldn't look as cool as the bugs

Thew
@AmazingThew

Also added some dither fog which helps a lot with differentiating surfaces

Thew
@AmazingThew

Forgot to do the make-one-pixel-transparent-to-force-twitter-to-use-PNG trick for most of these so jpeg's kinda pooping on the dithering :(

Thew
@AmazingThew

Greetings once again

At last, the image you have waited for: A Vast Profusion of Orbs in Five-Point Perspective

Thew
@AmazingThew

Wait crap I screwed up the gif export it was supposed to have shading but now it already has RTs

Thew
@AmazingThew

It was supposed to look like this

Thew
@AmazingThew

540-DEGREE FIELD OF VIEW

SUCK IT GAMERS

Thew
@AmazingThew

I should point out that this is literally impossible with normal game rendering. Games use a pinhole projection, which is linear

Thew
@AmazingThew

Side effect is you can't render a fov larger than 180 degrees. Even if you set it to 1000 in the ini and post a screenshot on reddit. 180

Thew
@AmazingThew

This is why I get IRRATIONALLY ANGRY when people refer to the distortion from wide fovs in games as "fisheye"

FISHEYE IS A COMPLETELY DIFFE

Thew
@AmazingThew

The distortion in a game with 180 fov is so bad specifically because it's NOT fisheye. Can't curve straight lines so it loses its mind

Thew
@AmazingThew

"loses its mind" is the formal term mathematicians use to describe things that involve the asymptote of the tangent function, btw

Thew
@AmazingThew

(this also means gaming on curved monitors or wraparound multi-monitor rigs is Dumb. You're not fixing the distortion; you're *adding more*)

Thew
@AmazingThew

(if you want to use multiple monitors to view a wider in-game fov they need to be flat on the wall perpendicular to your view to be correct)

Thew
@AmazingThew

(assuming you sit 2 feet away, for a fov of 120 you need about a seven-foot wide monitor wall

160: 23 feet

170: 46 feet

Asymptotes!)

Thew
@AmazingThew

I guess this is too many tweets to be considered parenthetical anymore

In a similar way, fisheye is only distorted on flat displays

Thew
@AmazingThew

A curved monitor and a properly-calibrated fisheye projection would be perfect: All fovs <=360 supported with zero distortion

Thew
@AmazingThew

Problem is all the ways of doing fisheye in games are really complicated and have significant performance considerations

Thew
@AmazingThew

Also nobody makes ring-shaped 360-degree monitors

Thew
@AmazingThew

Ooh stereographic projection does really cool stuff at large angles

(earlier images were using equiangular)

Thew
@AmazingThew

So the term "fisheye" generically refers to any number of curvilinear perspective projections

Thew
@AmazingThew

My aim here has been to figure out a generic camera for raymarching where I can just plug in any old projection and see the result

Thew
@AmazingThew

And I have succeeded!

Currently going off this list:

Would like to find more expressed in that form

attached image

https://en.wikipedia.org/wiki/Fisheye_lens#Mapping_function
Fisheye lens - Wikipedia

Thew
@AmazingThew

Will post shadertoy in a bit; gotta make the code at least vaguely readable first

Thew
@AmazingThew

Also "fisheye" is a dumb name; your actual human eyes see curvilinear perspective. Brain just interprets it flawlessly

Thew
@AmazingThew

Stand perpendicular in a hallway some time and stare at the wall. Can see it converge towards both vanishing points in peripheral vision

Thew
@AmazingThew

The part in front of you *looks* straight because Brain Stuff but you can force yourself to notice the curvature if you focus on periphery

Thew
@AmazingThew

Okay, it's done! Code for raymarching using various curvilinear perspective projections:

attached image

https://www.shadertoy.com/view/MtV3Dd#

Thew
@AmazingThew

Looking forward to making tweets that aren't part of this three-day-long reply thread