I truly enjoy your work on Ray-Marching. You have a way of explaining it to where it makes sense. I would love to see how you would map textures to these 3D objects!
Best day when the art of code releases a new video! I think it is so amazing how you can do this with just a few lines of glsl and just the distance to an object :)
I love your channel and I'm learning a lot. Love your videos, thanks! As regards the issue about the "sinned" plane, I believe the real problem isn't in the ray marching algorithm but it is that the deformation of the plane distance field is not the real distance field of the "sinned" plane (i.e. it doesn't give the true distance from a point to that set). Actually it is really simple to find and to compute, but I think one could find the true distance field of that object and keep the algorithm in its original form, but maybe this function would be a bit messy. Thanks for the video!
You could make the minimum for a step for curvy plane to be the distance between camera and top of the waves (if the camera is still above the weights)
Great information and great performance. As usual. But another observation I made today is how balanced you talk at different levels of depth regarding different levels of knowledge of different viewers. I had so many math heavy lectures on CG with lecturers that just didn't know or care that computer science is not mathmatics. THUMBS UP!!!
Martine... I absolutely adore these videos; thank you so much for making them. Do you plan on making a video to illustrate how to structure the raymarching code such that distinct colors can be assigned to each object?
This has been solid gold for getting a better conceptual grasp on some of the techniques I've been experimenting with recently. I'm curious if you have any tips regarding culling and optimisation for larger/more complex scenes. Ray Marching's biggest issue is needing to constantly calculate distances to every primitive in the scene, so obviously culling to minimise the number of distance calculations (some of which are quite expensive) would be desirable. However, I haven't yet been able to figure out a solution beyond manually adding/removing objects from the list of items sent to the distance estimator via loading triggers. Have you managed to find a way to implement occlusion/frustrum culling, or perhaps dividing space into cells, similar to collision detection techniques?
Do you have any thoughts on or examples of using SDFs to model clouds? I've made shader that uses a coverage map sdf texture that gives the lateral shapes of the clouds, and I want to be able to create the vertical detail and give it the blobby appearance. I know people usually use 3D noises like perlin-worly for stuff like this, but I for the overall blobby shape, it would be nice to be able to nail it down with SDFs, and only use the 3D noises within a limited distance from the surface.
Have you ever worked with compute shaders? If so, do you know how ray marching could benefit from GPGPU vs. being stuck on a per pixel loop (fragment shaders)?
I notice you get some artifacts around the bottom of the box and on the horizon (when the box overlaps the horizon), it's particularly noticeable if you put the camera near the ground. Why does this happen?
I love your videos. I have a question. What causes the black pixels around the edges of the box? See what I mean here: imgur.com/a/9C2mJyr Is it because of the box distance formula and lighting? I saw that you did ambient occlusion in another video. Maybe that can solve that issue? Thanks!
Great content! i have a question, if i want to implement a raymarching system to trace a set of dots like a mandelbulb how could i do that? i mean in this tutorials you are using some functions to get the boundaries of objects like a sphere or a cube adding some distortions like the rotations. btw thank you very much for your content!
That's really great learning way! Many Thanks! Is actually it possible to use signed distance field for collision detection between simple polygonal figures? It will be not efficient to send all transform data to the shader. but could it work at all?
Yeah I think you could use sdf to do collision detection of polygonal meshes. You'd do the sdf calculation in a regular script though, not inside of a shader.
So, how does this affect the processing power of the computer; is it more expensive / taxing on the hardware to render these crazy shapes with a shader rather than just modeling them using 3D modeling software? I imagined that it's less taxing because you're not changing the poly count of the cube, just changing how it's rendered. Is this right?
This is actually more expensive than rendering normal 3d mesh objects. It does have the advantage that the shapes are purely procedural so you can do things (like blend shapes) that you couldn't do with mesh objects. I would not recommend this is to make a video game for instance
@@TheArtofCodeIsCool why not for a video game? im planning to use raymarching for a project that renders fractals. however i was thinking I might just use this technique for lighting in certain scenes in other projects nothing too crazy just raytracing is a bit slow for me. I could be wrong but for some reason I cant seem to get samples fast enough to make real use of raytracing and baked lights arent good for me since i want real time movement in the long run . raymarching seems like a good bet
how do I march to a a skybox. In other words, how do I make a 2D shader works inside of a cube where i can rotate the camera and each face of the cube I see a different part of the shader
hiya. not sure if this should be done differently in my case but i have tried to apply the sine wave on my own ray tracer and i feel like im stuck, i alter the distance of the intersected object and it seems to affect the shape well enough, however my normals do not make sense (black/possibly inverted at certain areas). would you know a way to get around this?
@@TheArtofCodeIsCool heya! long time, i guess i was looking for a good displacement mapping implementation for path tracing.. is ray marching a good approach at tackling displaced surfaces? using texture UV coords that is
hey, I've got a question for you if you don't mind. I'll be kind of long one. AFAIK, ShaderToy is basically a some sort of a rendering engine (WebGL based?) that just lets you frivolously code shaders giving you some of its inputs e.g. time, resolution, and outputs your transformations of these. if so, would this actually mean that I'm able to reuse the shader code everywhere I want to unless the render doesn't support it?
Ray marching is just a lighter version of ray tracing but it's still too expensive to spam it. The test is done for each fragment, or for every pixel, on your screen. Games use ray marching for shader effects that produce visual effects that justify the costs, e.g screen space reflections.
@@ThylineTheGay In certain situations it is slower. If you march along the surface or march in a hole without actually hitting anything your stepsize would be very small or your result inaccurate. Regardless, ray marching is used in games and it does replace ray tracing in some cases but due to its flaws you can't replace ray tracing with it.
Hello, you didn't mention how to decrease the raymarching steps as it oversteps away from the surface of the plane. How should you decrease the raymarching steps per iteration when calculating the step radius from where you are in the step to the closest plane distance?
I havent really looked into that but off the top of my head its just adding a value to the SURF_DIST based on the distance you have marched from the origin. So something like if(dS
I still don't follow what makes the 3D shape inside the object. I get the concept of ray marching as you explained, but where does the 3D shape come from??
i was wondering how i could get the 2 spheres to mold into eachother like clay? i have a test project on p5.js with basically your shade code in it (assets/shader.frag) editor.p5js.org/jklw10/sketches/U9WYDv28w
wow that "fudgy" trick you showed to fix marching size artifacts for the wavy planes fixed a bug I had in a seperate raymarcher I made form a tutorial i found via google tutorial! imgur.com/BMusdWO (this is it fixed) . cant thank you enough for this series man. im converting the shader toy raymarcher into unity
Thanks for this video I can see this shader is using raymarching(because of the variable ro), but I don't understand anything else. can you clarify how they are getting the clouds? www.shadertoy.com/view/3l23Rh
Curious, I see no downvotes yet. But I believe bots produce random downvotes (also upvotes) to mimic organic traffic. Maybe whichever bot you saw the downvote of got banned.
@@TheArtofCodeIsCool There is music the first 80 seconds and then a 120 Hz constant tone. Later 190 Hz and 300 Hz are also there. If you bring your audio track into Audacity or Adobe Audition and look at the frequency view. manual.audacityteam.org/man/spectrogram_view.html
This channel is pure gold.
I truly enjoy your work on Ray-Marching. You have a way of explaining it to where it makes sense. I would love to see how you would map textures to these 3D objects!
Honestly this is hands down the best tool tip of ray marching that exist online
So I just arrived from work, bought sushi and then BAM go a notif on this :)
So relaxing and pleasing.
Oh boy! new Art of Code video!
Best day when the art of code releases a new video! I think it is so amazing how you can do this with just a few lines of glsl and just the distance to an object :)
I love your channel and I'm learning a lot. Love your videos, thanks! As regards the issue about the "sinned" plane, I believe the real problem isn't in the ray marching algorithm but it is that the deformation of the plane distance field is not the real distance field of the "sinned" plane (i.e. it doesn't give the true distance from a point to that set). Actually it is really simple to find and to compute, but I think one could find the true distance field of that object and keep the algorithm in its original form, but maybe this function would be a bit messy. Thanks for the video!
Love the channel! I really enjoy the pairing of educational information with a more relaxed style of communication.
Again a great tutorial. Thanks
My favorite video so far!
Really useful!
Respect from Russia! 🪆
This is so interesting, praise uploader!
Very helpful stuff ! I already wait your next raymarching tips !
Very helpful about the waves! I was gonna do the experiment about this, now I don’t need to :)
You could make the minimum for a step for curvy plane to be the distance between camera and top of the waves (if the camera is still above the weights)
Top quality work Martijn! Thanks for making this!
Great information and great performance. As usual. But another observation I made today is how balanced you talk at different levels of depth regarding different levels of knowledge of different viewers. I had so many math heavy lectures on CG with lecturers that just didn't know or care that computer science is not mathmatics. THUMBS UP!!!
Thanks! ANd thanks for watching.
Thank you so much
Martine... I absolutely adore these videos; thank you so much for making them. Do you plan on making a video to illustrate how to structure the raymarching code such that distinct colors can be assigned to each object?
I did a video on how to texture sdfs, perhaps that helps?
This has been solid gold for getting a better conceptual grasp on some of the techniques I've been experimenting with recently. I'm curious if you have any tips regarding culling and optimisation for larger/more complex scenes.
Ray Marching's biggest issue is needing to constantly calculate distances to every primitive in the scene, so obviously culling to minimise the number of distance calculations (some of which are quite expensive) would be desirable. However, I haven't yet been able to figure out a solution beyond manually adding/removing objects from the list of items sent to the distance estimator via loading triggers. Have you managed to find a way to implement occlusion/frustrum culling, or perhaps dividing space into cells, similar to collision detection techniques?
Do you have any thoughts on or examples of using SDFs to model clouds? I've made shader that uses a coverage map sdf texture that gives the lateral shapes of the clouds, and I want to be able to create the vertical detail and give it the blobby appearance. I know people usually use 3D noises like perlin-worly for stuff like this, but I for the overall blobby shape, it would be nice to be able to nail it down with SDFs, and only use the 3D noises within a limited distance from the surface.
Thanks!
We need a tutorial on Parametric UV`s.
muy buen video e interesante los tips!!!
"This is very ugly. We don't want this."
You sound just like my parents.
haha
the "planes" you define are technically half-spaces, hence the working booleans.
very useful as always. thanks ;)
Can you do wrapping of a 2D texture onto a 3D object, like a sphere or cube?
Yeah that would definitely be a good topic for a video. I'll start thinking about it!
The Art of Code That would be awesome! Having trouble finding good info on it, especially for HLSL/CG.
Such a surprise!
nice
Have you ever worked with compute shaders? If so, do you know how ray marching could benefit from GPGPU vs. being stuck on a per pixel loop (fragment shaders)?
I notice you get some artifacts around the bottom of the box and on the horizon (when the box overlaps the horizon), it's particularly noticeable if you put the camera near the ground. Why does this happen?
Be honest with me here. You're actually a wizard, aren't you? You're dressing this all up as if it's merely math, but I'm on to you, sir...
Thats right, in middle earth they call me Gandalf the Bald. ;)
I love your videos. I have a question. What causes the black pixels around the edges of the box? See what I mean here: imgur.com/a/9C2mJyr Is it because of the box distance formula and lighting? I saw that you did ambient occlusion in another video. Maybe that can solve that issue? Thanks!
My friend make 2d Ray marching in Mindustry game. He name is Domovoy or Домовой.
Huii, wtf. That video was helpfull
It is f*cking great!
Great content! i have a question, if i want to implement a raymarching system to trace a set of dots like a mandelbulb how could i do that? i mean in this tutorials you are using some functions to get the boundaries of objects like a sphere or a cube adding some distortions like the rotations. btw thank you very much for your content!
You would have to use a distance function for the mandelbulb. If you search on shadertoy, I'm sure you can find one.
That's really great learning way! Many Thanks!
Is actually it possible to use signed distance field for collision detection between simple polygonal figures? It will be not efficient to send all transform data to the shader. but could it work at all?
Yeah I think you could use sdf to do collision detection of polygonal meshes. You'd do the sdf calculation in a regular script though, not inside of a shader.
Perhaps you could use a distance-field approximation of a polygonal object and use it to do collisions. I'd have to think about it.
So, how does this affect the processing power of the computer; is it more expensive / taxing on the hardware to render these crazy shapes with a shader rather than just modeling them using 3D modeling software? I imagined that it's less taxing because you're not changing the poly count of the cube, just changing how it's rendered. Is this right?
This is actually more expensive than rendering normal 3d mesh objects. It does have the advantage that the shapes are purely procedural so you can do things (like blend shapes) that you couldn't do with mesh objects. I would not recommend this is to make a video game for instance
@@TheArtofCodeIsCool why not for a video game? im planning to use raymarching for a project that renders fractals. however i was thinking I might just use this technique for lighting in certain scenes in other projects nothing too crazy just raytracing is a bit slow for me. I could be wrong but for some reason I cant seem to get samples fast enough to make real use of raytracing and baked lights arent good for me since i want real time movement in the long run . raymarching seems like a good bet
how do I march to a a skybox.
In other words, how do I make a 2D shader works inside of a cube where i can rotate the camera and each face of the cube I see a different part of the shader
That is a very good question and should be the topic of a future video. You would have to match the unity camera with the camera in your shader.
hiya. not sure if this should be done differently in my case but i have tried to apply the sine wave on my own ray tracer and i feel like im stuck, i alter the distance of the intersected object and it seems to affect the shape well enough, however my normals do not make sense (black/possibly inverted at certain areas). would you know a way to get around this?
You have a link?
@@TheArtofCodeIsCool heya! long time, i guess i was looking for a good displacement mapping implementation for path tracing.. is ray marching a good approach at tackling displaced surfaces? using texture UV coords that is
hey, I've got a question for you if you don't mind. I'll be kind of long one. AFAIK, ShaderToy is basically a some sort of a rendering engine (WebGL based?) that just lets you frivolously code shaders giving you some of its inputs e.g. time, resolution, and outputs your transformations of these. if so, would this actually mean that I'm able to reuse the shader code everywhere I want to unless the render doesn't support it?
Yeah pretty much. Check my video on how to convert from ShaderToy to Unity for instance.
@@TheArtofCodeIsCool tks, I'll take a look at it.
if raymarching is so good, why is it not more popular?
Ray marching is just a lighter version of ray tracing but it's still too expensive to spam it. The test is done for each fragment, or for every pixel, on your screen. Games use ray marching for shader effects that produce visual effects that justify the costs, e.g screen space reflections.
@@WXKFA still, why don't games and rendering engines use it instead of raytracing? it seems a lot faster
@@ThylineTheGay In certain situations it is slower. If you march along the surface or march in a hole without actually hitting anything your stepsize would be very small or your result inaccurate. Regardless, ray marching is used in games and it does replace ray tracing in some cases but due to its flaws you can't replace ray tracing with it.
@@WXKFA hmm ok
Hello, you didn't mention how to decrease the raymarching steps as it oversteps away from the surface of the plane. How should you decrease the raymarching steps per iteration when calculating the step radius from where you are in the step to the closest plane distance?
I havent really looked into that but off the top of my head its just adding a value to the SURF_DIST based on the distance you have marched from the origin. So something like
if(dS
@@TheArtofCodeIsCool Thanks for the information. Understood what to do now. Hope to see you continue with new videos for this channel.
I still don't follow what makes the 3D shape inside the object. I get the concept of ray marching as you explained, but where does the 3D shape come from??
From the distance function of that shape. I did a video explaining these: ray marching simple shapes.
i was wondering how i could get the 2 spheres to mold into eachother like clay? i have a test project on p5.js with basically your shade code in it (assets/shader.frag)
editor.p5js.org/jklw10/sketches/U9WYDv28w
You can use a smooth min function instead of a normal min function. I did a video on smooth min, check it out!
wow that "fudgy" trick you showed to fix marching size artifacts for the wavy planes fixed a bug I had in a seperate raymarcher I made form a tutorial i found via google tutorial! imgur.com/BMusdWO (this is it fixed) . cant thank you enough for this series man. im converting the shader toy raymarcher into unity
Thanks for this video
I can see this shader is using raymarching(because of the variable ro),
but I don't understand anything else. can you clarify how they are getting the clouds?
www.shadertoy.com/view/3l23Rh
That's a whole topic on its own. I'm sure I'll do a video about it at some point!
@@TheArtofCodeIsCool awesome, looking out for that tutorial
Obviously he is Alien. Can`t find another explain about his skills)
How to fix all raymarching bugs
1. Ray tracing.
hmm not sure about that one. Also, there are many thing you can do with ray marching that you can't with ray tracing.
The big question: who down-voted this ?!
Curious, I see no downvotes yet. But I believe bots produce random downvotes (also upvotes) to mimic organic traffic. Maybe whichever bot you saw the downvote of got banned.
@@4.0.4 Nice try, but good you removed your down-vote :-D :-D :-D
Please, please do not have background music. It makes it very hard to hear what you say. Also, that humming sound. Ouch
Sound is admittedly my weak point. I don't really hear a humming sound though?
@@TheArtofCodeIsCool for most video editors or audio tools look for "ducking" , it lowers the music when you speak.
@@TheArtofCodeIsCool There is music the first 80 seconds and then a 120 Hz constant tone. Later 190 Hz and 300 Hz are also there.
If you bring your audio track into Audacity or Adobe Audition and look at the frequency view. manual.audacityteam.org/man/spectrogram_view.html
maybe actually use a real distance measurement instead of the shitty one there?
You mean for the sine height field? I guess you could, be my guest :)