3D fractals demo

Lately I was playing with raymarching and 3d-fractals. I came up with the method to optimize raymarching and implemented it in Urho. I also added volumetric light scattering for point and spot lights. Taking from this demo: blog.mmacklin.com/2010/05/29/in-scattering-demo/ and using some ugly hackery to make it work with finite attenuation lights (it uses inverse square fore light attenuation ).

Requires modern GPU.

Screenshots and download:

Follow me: https://twitter.com/Bananaft


Looks freaking amazing man. Reminds me of those ShaderToy fractal demos.
Any chance to get the C++ source code or is it all done in shader code?
Edit: Found the code in Angelscript.

super cool.
The lights look great. Are you also building collision objects for that character to stand on?

I did some similar work a while ago… but I never took it as far as you have:

nice, I love fractals

I like the lighting effect. Awesome demo.

Thank you all for feedback. So it actually works :slight_smile:. Forgot to ask, I really want to know what hardware you have and what performance you are getting?

My go to source.

With this project I’ve made my first baby steps in C++. Whole raymarching thing is purely glsl and renderpath.xml. But I had to disable Z-culling for light volumes, to make them work with raymarching result. Also I passed couple additional shader parameters for light scattering of spotlights. That’s like 5-6 lines changed.

No, I just placed him there :slight_smile:. I haven’t tried collisions yet, but I will. Mesh is not an option, I have to calculate SDF for collisions either on GPU or CPU, both ways seems terrible. CPU will require to write code twice, keep it same, and may still give different results (in theory). GPU has problems with bringing information back to CPU to update objects.

I wonder if a Linux version can be built. :-/

just put the linux binary player in the folder and run it.
it works partially, I experimented somes bugs…

Here is my fork and all the changes.

Very nice demo !

Do you think you could make a pull request in Urho3D master branch for adding this volumetric effect support to point and spot lights ? That would be awesome.

Hi, sorry for long reply.

I never did a pull requests, might use an assistance, and my coding style is a bit savage.

Also, it works easily only with deferred lighting, other modes will need an additional light volumes pass, witch is not cool.
Plus, this light scattering should somehow interact with fog, and trying to resolve this will rise many complicated questions.

The new version features four different fractals, smoother lights scattering, cubemap sky and colored ambient occlusion, and some more minor tweaks.


So cool…
Unfortunately the misspelling of a certain resource prevents me from pouring the submarine some tea.

What do you mean? Is there an error, it won’t load or something?

Yea, it’s looking for a Teapot where there only is a TeaPot.

So you’ve built Linux binary from my brunch? How does it work? What GPU do you have?

I ran the game.as with a natively built Urho3D player. It’s a simple naming issue fixed by changing line 234 of game.as from:

tpObject.model = cache.GetResource("Model","Models/Teapot.mdl");


tpObject.model = cache.GetResource("Model", "Models/TeaPot.mdl");

…damned alternative spellings. :stuck_out_tongue_winking_eye:

1 Like

New video.


Fractals are goddamn amazing. How the physics is implemented?

Everything has to be sphere approximated. Character controller uses 2 spheres. Submarine uses 3. It’s calculated with pixel shader. I use small 16bit textures to pass data to and from GPU. Position and radius is sent to GPU, distance and normal(estimated with given radius) are sent back. It is not very accurate, but with signed distance you can do soft collisions