
Voxel Quest Fluid Dynamics and New Rendering Method - akavel
http://www.voxelquest.com/news/update-05-20-2015
======
gavanwoolery
Author here - as mentioned I was not expecting this to get posted but I am
happy to answer any questions or elaborate further. For so long as I can stay
awake at least. :)

Some other shots worth looking at:

Some terrain I quickly whipped up based on this method, using Voxel Quest's
actual generated map:
[https://twitter.com/gavanw/status/589499986854838272](https://twitter.com/gavanw/status/589499986854838272)

Screenshot of the test scene, with median filter:
[https://twitter.com/gavanw/status/590895532509265920](https://twitter.com/gavanw/status/590895532509265920)

Here is a short vid showing that it is in fact volumetric:
[https://twitter.com/gavanw/status/590903499342229504](https://twitter.com/gavanw/status/590903499342229504)

A few basic tricks I use:

A "macro" pass that ignores small, expensive to compute details.

A "micro" pass that avoids texture reads but produces complex algorithmic
textures (texture reads will KILL your performance in many cases because of
cache invalidation).

Supercover lines used for raymarching to precisely march through each cell.

[http://lifc.univ-fcomte.fr/home/~ededu/projects/bresenham/](http://lifc.univ-
fcomte.fr/home/~ededu/projects/bresenham/)

~~~
chrisseaton
Can you give an overview of the technique you are using for this project (in
general, not just this demo) for someone with only undergraduate level
graphics knowledge?

Do you basically draw two triangles that fill the whole screen and then render
everything using a shader?

And how do you store that many voxels? A sparse data structure? When you have
a large solid area do you simply say this entire area is filled so don't have
to represent the voxels individually?

I saw a video where you cut away sections of a building using a brush. Do you
store the building voxels and then store the subtraction separately? If you
had a world with thousands of buildings in it and cut away a little at each
does that mean you can no longer share the shape of each building and space
requirements blow up?

~~~
gavanwoolery
> Do you basically draw two triangles that fill the whole screen and then
> render everything using a shader?

Yes. It determines the ray origin and direction for each pixel, and casts out
a ray from there with pretty standard ray tracing methods and a few additional
tricks I mention above.

> And how do you store that many voxels? A sparse data structure? When you
> have a large solid area do you simply say this entire area is filled so
> don't have to represent the voxels individually?

No voxels anymore, although it can be fairly easily "voxelized" by clamping
the step space of the rays to approximate towards the nearest cube. So, I
guess I might have to change the name, or make it look more voxel-ly :)

> I saw a video where you cut away sections of a building using a brush. Do
> you store the building voxels and then store the subtraction separately? If
> you had a world with thousands of buildings in it and cut away a little at
> each does that mean you can no longer share the shape of each building and
> space requirements blow up?

You can store a million modifications in a few megabytes. I was never
intending for it to allow that many though, but I will figure out what corner
cases are worth addressing.

~~~
rsp1984
> No voxels anymore

So how do you represent geometry then? Mesh? SDF? Space tetrahedralization?

~~~
gavanwoolery
Same way I've always done in VQ - with math/logic :)

~~~
chrisseaton
I don't get it - do you write a mathematical function that says whether or not
you have intersected with anything in the world? How does that not turn into a
huge piecewise? How does that allow you to change the geometry, as I guess it
gets compiled into the shader?

~~~
gavanwoolery
You can get somewhat of an idea how it works here:

[http://www.voxelquest.com/news/how-does-it-
work](http://www.voxelquest.com/news/how-does-it-work)

You can change geometry by passing parameters to to the shader or creating
special object generation functions within the shader. This is not intended to
render everything in the game, mostly just aspects of the environment that can
be easily procedurally generated like terrain and structures. Other things can
be merged in from a traditional pipeline like using polygonal character models
(or even sprites, as I have shown in my past demos).

The more that you can define mathematically, the better. Doing texture lookups
is almost an order of magnitude more expensive sometimes, and less precise
always.

You start really simple, and say did I hit the bounding box that contains the
object? If so, did I hit the more complex piece of geometry within that? If
so, what UVW coordinate did I hit on the geometry? Marching through the UVW
coordinates on the ray, you can create any sort of procedural texture. I have
shown a voronoi texture and a shingle texture but really anything can be
created and some procedural textures are very cheap compares to others
(voronoi is relatively expensive). If you look at old shots of my terrain, it
is all created with voronoi and noise pretty much.

[http://www.voxelquest.com/gallery.html](http://www.voxelquest.com/gallery.html)

It is possible things will get too expensive to do in realtime, but the option
will always be there. Worst case scenario is that I can render like I did with
my old isometric engine and cache the render results. At the very least the
option will always be there for more powerful computers in the future. That
said I think realtime is feasible on decent midrange/modern hardware.

------
david-given
This sounds a bit like Euclideon's Unlimited Detail tech demo video, which got
some press a couple of years ago and then vanished without trace:

[https://www.youtube.com/watch?v=00gAbgBu8R4](https://www.youtube.com/watch?v=00gAbgBu8R4)

(Warning. Video may contain critical levels of overhyped vapourware.)

To me it sounded like Euclideon had figured out a new wrinkle in efficiently
storing and searching very large instanced voxel spaces, and Voxel Quest
sounds very similar. While Euclideon's demo was obviously a rigged tech demo,
it still looked very cool, and I'm glad that it's turning out that this sort
of thing is feasible.

~~~
rsp1984
Since I happen to know the founder of Euclideon and the company a little bit I
have to emphasize here that their tech was and is real. Sure in the videos it
wasn't presented in a neutral academic setting but it's far from rigged and in
fact is being used in the geospatial industry today.

Voxelquests technology looks very promising too and I am looking forward to
seeing this applied in a game setting.

~~~
M4v3R
For those who didn't seen it - Euclideon released a new video about that:
[https://www.youtube.com/watch?v=5AvCxa9Y9NU](https://www.youtube.com/watch?v=5AvCxa9Y9NU)

~~~
anc84
"Euclideon Makes World’s Most Realistic Graphics"

Yeah, honest and humble as always. I wonder how the people who actually
developed the algorithms and procedures they used about this.

~~~
threeseed
The same way everyone in any industry takes credit for work done by other
people.

And it's just product marketing. Most of the world aren't engineers. Boring
them with technologies and specifics isn't how you sell products.

~~~
CyberDildonics
It isn't 'just product marketing' Their videos are ridiculous and prey upon
people not being able to identify what they aren't seeing.

They made grandiose claims and diverted attention to things that didn't
matter. How many games are using what they've done?

~~~
threeseed
It seemed pretty clear that they were more interested in geospatial, real
estate etc industries. Gaming is not even a sensible industry to break into
given how fundamentally different the workflow would be to use this
technology.

And sure it was a little over the top but then again so is most marketing.

~~~
CyberDildonics
That is 100% not true, their videos were of them running around in video game
engines and pointing at low poly trees!

------
c3d
No discussion of ray marching is complete wihtout mentioning Shadertoy
([http://www.shadertoy.com](http://www.shadertoy.com)) and the work of great
shader artists such as Iñigo Quílez, Paul Malin, Dave Hoskins, Reinder Nijhoff
and many others. If you are interested in these techniques, check it out.

One of my favorites is Elevated:
[https://www.shadertoy.com/view/MdX3Rr](https://www.shadertoy.com/view/MdX3Rr).

I've converted many of the most beautiful ones to auto-stereoscopic 3D for
Tao3D ([http://tao3d.sourceforge.net](http://tao3d.sourceforge.net)). An
infinite landscape in glasses free 3D is a thing of beauty :-)

~~~
jere
I've seen this website mentioned many, many times. What kind of background
would one need to begin to start understanding/making these things?

Every time I see this site, I think _I should figure this out_. I don't see
any sort of introduction area, so I click on a shader and am presented with
some totally indecipherable code.

~~~
david-given
The maths isn't hard, but you do need a decent grasp of vectors and
(optionally) 3D transformation matrices, and it's pretty opaque until you
figure out the terminology.

I haven't done GPU raymarching myself but I've used the same techniques on the
CPU side in order to develop a whole-planet procedural renderer (in Ada, of
course); the raymarching was relatively straightforward but I got horribly
bogged down trying to make a volumetric atmosphere work.

One resource I found really useful was Iñigo Quilez' website; in particular,
his article on basic terrain raymarching explains most of the concepts:
[http://www.iquilezles.org/www/articles/terrainmarching/terra...](http://www.iquilezles.org/www/articles/terrainmarching/terrainmarching.htm)

(Also known as iq, he's responsible for a number of amazing demos, including
the 4kB demo _Elevated_:
[https://www.youtube.com/watch?v=jB0vBmiTr6o](https://www.youtube.com/watch?v=jB0vBmiTr6o)
He also appears to have written ShaderToy. Search for iq to see his stuff omfg
ShaderToy lets you write shaders to produce _music_ now?
[https://www.shadertoy.com/view/ldXXDj](https://www.shadertoy.com/view/ldXXDj))

------
newobj
Looks awesome.

Gavan, any advice where to get started on graphics programming? I'm an ex-
games programmer (AI, networking) who always avoided graphics like the plague
- too many weird hardware permutations, fallbacks, crappy drivers, etc. Now
that I'm not in the industry, I'd like to learn for fun. But I have no idea
what the "sweet spot" is for desktop (non-mobile/console) graphics - DirectX?
OpenGL? What version of vertex/pixel/geom shaders are the norm? Are there
standard practices for shadows/lighting now, or are they still done on an ad-
hoc basis? How normal is GPU ray tracing? Virtual textures? And so and so on.
I haven't been able to find anything that kind of discusses these issues at a
comprehensive/holistic level. Anything useful you've found?

~~~
gavanwoolery
Thanks!

My advice is to find a good set of tutorials and start ripping them apart. In
another comment I mentioned Three.js is a great way to get up and running
fast. WebGL has limitations but the ease of development pays off especially if
you are just learning.

TBH does not matter what versions you use too much. I am still using one of
the older shader versions (1.2 or 1.3) but I will probably upgrade just
because there is not a major downside to using a newer version.

Lighting and shadows vary everywhere and there is no best way, just depends on
your use case. Cascaded shadow maps are quite common in high-quality, polygon-
based pipelines. Commercially, GPU ray tracing is very rare, if for no other
reason than the tooling is just not there like it is for polygons.

Ultimately, no fast path - you just take it one step at a time starting with
simple goals and you will ultimately get there. Even a year of hobby
development will make a dramatic difference in your understanding, but the
payoff is slower from there.

------
pervycreeper
I'd be curious to know what the new algorithm is that dispenses with "chunk
loading" allows all scene data to appear instantly.

~~~
corysama
I expect that it's signed distance field ray marching.

You can see a demo of the tech here:
[http://m.youtube.com/watch?v=lwFVlNytq0Q](http://m.youtube.com/watch?v=lwFVlNytq0Q)

And a presi of how that demo works here: [http://on-demand-
gtc.gputechconf.com/gtcnew/on-demand-gtc.ph...](http://on-demand-
gtc.gputechconf.com/gtcnew/on-demand-
gtc.php?searchByKeyword=Timeless&searchItems=&sessionTopic=&sessionEvent=&sessionYear=&sessionFormat=&submit=&select=)

~~~
VikingCoder
Wow, thanks!

------
markus2012
Looking forward to playing with the API and building my own worlds/demos/games
:-)

I'm hoping your license terms let folks initially play with it for free like
the UT4/Unity licenses.

~~~
gavanwoolery
Full source will be up on Github (with possible exception of any code that
needs to be secure like server stuff). It will get leaked/pirated anyway, so
not going to bother charging for the source.

~~~
bobajeff
I understand if you just don't want to deal with commercial licensing and
developer support. But really, regardless of if your code is leaked or not you
can get royalties the same way Unreal does on commercial products that use it.

~~~
gavanwoolery
Yeah there will be some sort of license in place although I hope to one day
have it under permissive open source. All I mean is that I'm not limiting code
to people who have purchased the game. :)

------
erikb
Did they just add a feature or replace the whole rendering engine? It looks
like a replacement with the second video. I start to wonder if it will ever be
finished.

~~~
gavanwoolery
Much of the old rendering pipeline is still there for materials, fog, post
process fx, screenspace lighting, etc. The only part of the rendering that has
changed is the part that generates the depth and normals. I have been using a
test scene to quickly get some other stuff up and running, stress test things,
and debug. But its still capable of rendering the old stuff, although there is
a bit of work to get it back in. :)

I think the performance improvements were a necessary evil. The old chunk
loading was simply too slow and had a negative impact on gameplay. I'm hoping
to keep things going on the gameplay front as well but I am only one man! :)

~~~
kenrikm
To me it looks like the effort was worth it. The chunk loading was a
showstopper where as this looks really slick now.

~~~
gavanwoolery
Thanks!

