Hey man! You're the best! I've been needing this kind of tutorials for a very long time. Unity tutorials for raymarchng and HLSL and dominant on youtube. This one, for Unreal, for beginners is the best! I'd love to understand how to make fog using raymarching that either utilizes volume texture or procedural noise. Or even know both! That would be perfect!
As an alternative solution to the centering issue, you can also use objectposition as SphereCenter, and change the distance calculation to RayOrigin + SphereCenter instead of subtract. That removes the need for the extra subtraction operation in the material graph. Edit: Ah, I see you handled inverting the view direction in the next video also.
Hi renderbucket. Im loving your series, always mind opening for me. I have a suggestion tho, you end up quite often using IF, but in reality is not a very good idea doing these opperations on a GPU. 99% of the times you can have basic math operations to do these IFs for you, example step(x,y) is non other than an if statement. Also you can use floor and ceil, min and max.
Glad you are enjoying the videos!, I generally find it a bit easier for beginners to grasp If statements so I made use of that. Your suggestion is spot on! There are much more efficient alternatives to If statements that can yield much better performance. I will definitively try to take a more optimized approach going forward in future videos. The compiler in a lot of cases will also do some form of optimization on your code for uniform conditionals. However a lot of it is also very hardware dependent. Usually mobile GPU/Devices become one of the hardest things to optimize for to the point where its almost its own art form.
@@renderbucket yep. In the case of the RayMarching code i struggle to imagine how to convert it all, but for example in the case of your rain one single step instead of the complicated IF and it makes it all. U can also draw one circle only and then sine it to obtain the frequencies hence its ripples, so you don’t have to draw 2 circles and remove the intersection. I’m very curious to see what’s next on your videos, really wish to see some compute shaders since I have no clue how to approach them in Unreal.
Could you explain the practical usages of the things you explain in the tutorial ?. Because to learn more efficiently if we can get a practical usage of all these HLSL and using it in an actual production case that'd be more beneficial. Thank You
Your change is the correct result and pretty straighfoward. He confused himself in the video. As viewDir = Camera Vector = cameraPosition - worldPos. Thus in his video rayOrigin = viewDir - worldPos = cameraPosition - 2 * worldPos, which makes non-sense by subtracting worldPos 2 times. The result is just correct by coincidence. Actually he made a little correction in the next video but he doesn't seems to understand what the logic truely means.
I have a question, as this material can be used on any shape, say i use it on a plane which would be two triangles, would this be better performance than using a sphere, say 10,000 instances of each, which would be better a sphere or a plane using this material?
Would have to benchmark it to be sure, but I assume if your utilizing Nanite or LODs the Geo might be a better choice. Mainly because you would have more direct access to the surface for collisions/shading.etc. And GPUs can handle geometry pretty easily now days. The approach of raymarching would maybe work better for gooey liquids or things that might need to be there bubbling around doing things but not necessarily interacting with the world. Nebulas, Clouds, those things are often done with Raymarching.
Using math to generate geometries can improve performance. Additionally, you can create much more complex procedural geometry with the raymarching technique.
Funny enough I just did something similar for atmospheres and somehow this video pops up lol. Anyway I wish you het a hlsl node in material editor like one in Niagara. Much easier to read and write code.
I'm sorry but you're not really explaining but merely telling it as it is - But at least I could watch other tutorials to understand it more and then watch your tutorials to learn how to implement it in unreal engine. I mean why is the rayOrigin = Camera Vector - World position. This vector doesnt make sense to me. can you please explain this more? Why not use the Camera Position as our ray Origin?