Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1369501 Posts in 64351 Topics- by 56368 Members - Latest Member: concrete_games

November 20, 2019, 02:30:25 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Ray marching feasibility in games
Pages: [1]
Print
Author Topic: Ray marching feasibility in games  (Read 490 times)
diegzumillo
Level 10
*****


This avatar is so old I still have a some hair


View Profile WWW
« on: August 29, 2019, 07:09:31 AM »

I've been reading up on Ray marching techniques where objects are described by signed distance functions. I find this particular video a good short summary of the idea:



(I thought we could embed videos. Edit: oh there it is!)


He also provided a unity project to play around with, which I am. I got the general idea but I have this project in mind that needs a way of rendering sci fi environments and I'm pretty skeptical about this approach, but also curious. Maybe you guys can talk me out (or in) of it.

So I've been thinking about this and why we don't see this used more in games. For one, it's extremely unconventional; distance functions are a completely different thing from models, not even mentioning animation. But still, what if I'm still interested in trying this, are there more obstacles? Performance is the first thing that comes to mind, but it looks very efficient. I increased the number of torus in the example scene and it barely made a dent in the frame rate. But each object is a different function, so its performance isn't easily predictable by number of objects only, but by how complex it is.

Another issue is how flexible is it to make things with this. Everything I see are simple shapes and fractals (usually the same one).

Given these initial considerations here's what I'm considering wasting a week working on:

I will try to create a scifi environment with buildings and a lot of fog. The fog is an attempt to mitigate the performance limitations I expect to have. I can totally justify that in the narrative. This is a foggy world. Fog world. Whatever, you can't see far.

A city can be previously modeled though. I can lay down some basic shapes and create distance functions that randomly assign fractals inside its volume or something like that. I like how scifi-y fractals can look but it needs variety, so maybe stitching together different fractal rules could come together nicely.

Logged

Prinsessa
Level 10
*****


Ava Skoog


View Profile WWW
« Reply #1 on: August 30, 2019, 05:55:42 AM »

I can't really answer your questions since frankly I don't know, but I just wanted to post something relevant and potentially helpful I watched the other day!

Have you seen the Shadertoy thing making the rounds lately with an orange creature jumping around in a gooey green field? The author streamed remaking the whole thing from scratch and I went from knowing nothing about this to understanding it quite well just from watching this:





Overall, I feel it's very similar to regular polygon rendering with regards to lighting calculations and so on, so there are a lot of skills that transfer readily once you get the basics! There are also certain things that you can do a lot more easily than you can do with polygons, like metaballing and shadows, so while there are certainly disadvantages in comparison, there absolutely seem to be advantages too. Would be super cool to see a game based on this!
Logged

miki
Level 0
**


View Profile
« Reply #2 on: August 30, 2019, 06:33:56 AM »

I believe this 2003 realtime raytracing demo uses functions for all its objects:


So possibly in raytracing you can find some of the answers.
Logged
diegzumillo
Level 10
*****


This avatar is so old I still have a some hair


View Profile WWW
« Reply #3 on: August 30, 2019, 10:40:21 AM »

I can't really answer your questions since frankly I don't know, but I just wanted to post something relevant and potentially helpful I watched the other day!

Have you seen the Shadertoy thing making the rounds lately with an orange creature jumping around in a gooey green field? The author streamed remaking the whole thing from scratch and I went from knowing nothing about this to understanding it quite well just from watching this:





Overall, I feel it's very similar to regular polygon rendering with regards to lighting calculations and so on, so there are a lot of skills that transfer readily once you get the basics! There are also certain things that you can do a lot more easily than you can do with polygons, like metaballing and shadows, so while there are certainly disadvantages in comparison, there absolutely seem to be advantages too. Would be super cool to see a game based on this!

Thanks for sharing that. I'll definitely check the shader out. The 5 hours video I might skim over though haha.

I'm playing around with meta balling, and boolean in general, which is amazing. I instinctively associate boolean with headaches caused by bad polygons and bugs and poor performance. Here it's free of charge.

If anyone is interested I can start dumping all the resources I'm finding on the subject. People have created entire libraries of distance functions for all kinds of primitive shapes, as well as transformations (twist, bend etc). And when it comes to fractals a whole world of possibilities open up. It starts to get a bit more math heavy, because finding distance functions for fractals is not trivial. There is even a forum dedicated to fractals!

I'm finding the subject surprisingly easy to get into (I mean, comparatively with what I expected to find and to other computer graphics topics). The parallelization implementation is the hardest part but that's its own challenge. Parallelization is usually the hardest part of anything that requires parallelization.

I believe this 2003 realtime raytracing demo uses functions for all its objects: [video]
So possibly in raytracing you can find some of the answers.

It might just be parametric objects, not distance function. But I'll check it out!
Logged

NovaSilisko
Level 2
**


Real life space alien (not fake)


View Profile
« Reply #4 on: August 30, 2019, 06:47:29 PM »

Space Engine has some pretty fantastic looking raymarched nebulae:

http://spaceengine.org/media/2019/02/scr00205.jpg

They're doing some clever optimizations. I believe they render at reduced resolution when you're moving, and then when you stop moving, or move slowly enough, they're baked to a skybox texture and have zero performance hit. A technique which I shall be shamelessly stealing for my own implementation  Ninja

As for replacing more traditional rendering, I would be very interested to see a graphics pipeline highly optimized for SDF-based geometry rendering. Pretty much all GPUs nowadays are deeply optimized for rendering polygonal objects, but I wonder what hackery could be pulled off.
« Last Edit: August 30, 2019, 10:48:59 PM by NovaSilisko » Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #5 on: August 31, 2019, 02:20:18 AM »

Just saw this today, it's raymarched fractals that he's hacked collision detection to. Probably the only game that's done this so far. Cool stuff.



Logged
diegzumillo
Level 10
*****


This avatar is so old I still have a some hair


View Profile WWW
« Reply #6 on: August 31, 2019, 12:51:51 PM »

Right! This channel is in my list of resources to constantly check. Really great stuff.

Anyway, I think my curiosity has slightly faded already. I could push a little further but my display driver keeps crashing and "recovering" and the Unity editor needs to be restarted constantly. I can see the mandelbrut for a few seconds and BAM there goes the driver. That is my cue to move on and resume the main project.

The lesson I'm taking from this is even if I get it to work stably on my machine, chances are it will not on other machines. Too dependent on GPU, and not in traditional and predictable ways either.

I might come back to this later but for now I'll restrict myself to talking about it only. It's a cool subject.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #7 on: October 20, 2019, 07:05:27 AM »

I'm late, sorry
- Media molecule dreams is based on splatting and distance field




- Claybook is a game entirely in distance field, here is the thread about porting that game to switch
https://twitter.com/SebAaltonen/status/1076765876148490240

Logged

diegzumillo
Level 10
*****


This avatar is so old I still have a some hair


View Profile WWW
« Reply #8 on: October 20, 2019, 07:29:50 AM »

Hah. Someone took the shot and made a game with distance functions alone? that is awesome.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic