Skip to main content
GameDev.net gamedev.net
🔒 Locked

GPU ray tracing

Started by taby Dec 19, 2022 at 4:16 PM 33 replies 22k views
Original Post
taby
taby

In Unreal Engine 5 there is a ray tracing option when creating new projects. For fun, I enabled the checkbox, created my project, and then I had to wait for 10 minutes while it compiled 6,500 or so shaders. Unfortunately, there was no visible difference (on my low-end GPU) when I went to run the level.

Can a Niagara fluid simulation cast light and shade on the environment?

Is ray tracing necessary? If so, what hardware supports this ray tracing?

To have the fluid sim hooked up to the global illumination would be a dream, like that scene in the clone war in Star Wars, where there is so much smoke, and the lasers light up that smoke.

taby
taby

I've been informed that I need an nVidia RTX 2000 or better to do ray tracing in the hardware.

JoeJ
JoeJ

taby said:
To have the fluid sim hooked up to the global illumination would be a dream

I would be optimistic this works, even without HW RT.
Their SW RT uses SDF for tracing, and then looks up ‘cards’ on the hit point to get a material. You can see this stuff in some ‘Lumen Preview’.
Idk, how Lumen works in detail, but in general emissive light sources are free with GI solutions.
So it would be easy for them to add fluid as a GI light source for sure, but maybe not yet and they have other priorities.

Lumen does not need HW RT. The software path was developed first.
But it's very expensive non the less, so what low-end GPU do you have?
With my Vega 56 it was low fps, but practical.

taby
taby

I have a GeForce GTX 1650, 4GB of shared RAM.

I know that Lumen is otherwise working…. warp9 and I got glowing red eyes working in Unreal Engine, and it casts light into the scene. So, lights can be any shape. That's pretty cool.

JoeJ
JoeJ

Found this:

https://docs.unrealengine.com/5.0/en-US/how-to-create-particle-effects-that-emit-light-in-niagara-for-unreal-engine/​

Looks like it illuminates the ground.

taby said:
If so, what hardware supports this ray tracing?

Any NV RTX GPU, but no GTX.
Any AMD RDNA2 GPU, so the models 6xxx and higher.
Intels ARC GPUs.

But for emissive fluids, HW RT sounds useless, because it primarily works with triangles.
The mesh needs static topology (e.g. a skinned character).
You could use isosurface, but because topology changes every frame, you would need to rebuild the BVH each frame too. So all of that together is expensive, but could work if you don't do much else.

HW RT also supports procedural content. So if the ray hits a box marked to be procedural, you can generate procedural shape and ray intersection with code. (I have forgotten how this shader is called.)
This would be better. You could raymarch the actual Eulerian Grid of smoke simulations. Particles would be difficult, if they lack any volume. Than you would need an acceleration structure for the particles.

SW RT sounds the best option, due to flexibility. HW RT simply is no win here.
SW RT is also faster with Lumen, mostly. At less accuracy, especially with reflections.

So i guess you can use that. Getting some interesting / good looking lighting out of fluidy gas is another problem. I expect some bright blob, but no real structure or shape. Likely it's pretty uniform and lacks direction. Maybe not as cool as expected.
Contrary, if you illuminate the gas with some external light source, the self shadowing and scattering can create interesting and beautiful images. Though, volumetric lighting is limited in realtime. But there sure are some options with UE.

JoeJ
JoeJ

JoeJ said:
Getting some interesting / good looking lighting out of fluidy gas is another problem. I expect some bright blob, but no real structure or shape. Likely it's pretty uniform and lacks direction. Maybe not as cool as expected.

Oh, after watching the VDB video in the blog above… explosions, ofc. :D How could i forget about explosions?
So i guess if you can control emission with some simulation properties, like heat, or pressure… it might look very cool.

taby
taby

I will try those steps, but there is a major difference between using the sprites alone and using them as a fuel source.

I emailed Epic and asked them three questions:

1) Fine control of particle emission in a Niagara System: Is it possible (through Blueprints) to emit a single particle with arbitrary location and velocity somewhere within the simulation grid? This is pretty much the finest level of control that there could be. I don't need to know how to do it, just whether or not it's possible.

2) Texture sampling: Is it possible (through Blueprints) to read back the simulation density and temperature textures from the GPU? For example, I wish to know the temperature at the centre of an actor, to determine if said actor is suffering heat damage. Again, I don't need to know how to do it, just whether or not it's possible.

3) Hardware ray tracing: From what I understand, if I obtain an nVidia RTX 2000 series or better video card, then I will be able to support ray tracing on the hardware. If I enable ray tracing in my project, will the Niagara fluid simulations cast light and project shadow onto the scene? Likewise, will the fluid simulation be lit up from the inside, if a light is placed at the centre of, say, a screen-filling cloud of smoke? I'm totally going to steal all of the effects from Star Wars and Harry Potter, and put them into a spaceship shoot 'em up game. Time is not really of the essence, because I don't care if I'm beaten to the punch, plus my project will be open source, for all to experiment with.

Hopefully the answer to all of these questions is "yes".

taby
taby

Question 3 isn’t a dealbreaker, unlike questions 1 & 2.

taby
taby

See, maybe the isosurface via marching cubes isn’t such a bad idea after all lo

there are dozens of parameters!

taby
taby

Apparently, Lumen takes into account the lighting from a gas emitter, so there are no steps needed to get that working. The only part not working now is the shadows.

taby
taby

Hmm… the lighting only works well when using a curve to light the fluid. When one uses blackbody, there is no lighting of nearby surfaces. Is this a bug?

JoeJ
JoeJ

That's very interesting for me to watch. I myself did only pretty static tests and could not observe the lag of Lumen.

I see the reflections are not laggy. But the GI is pretty much. It even seems to miss most particels, and catches just some of them randomly?
Or is this because it catches only particles which come close to the surface?

taby said:
the lighting only works well when using a curve to light the fluid. When one uses blackbody, there is no lighting of nearby surfaces.

What's a curve light? Eventually a emissive spline? And it needs to be created from the trajectory of individual particles? That would rule out emissive smoke, i guess.
Idk what's a blackbody neither.

JoeJ
JoeJ

JoeJ said:
(I have forgotten how this shader is called.)

It's called Intersection Shader. (example https://github.com/microsoft/DirectX-Graphics-Samples/blob/master/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingProceduralGeometry/readme.md)

Would not require isosurface, nor BVH. You could raymarch the density volume directly. Should be much faster than Iso → BVH.
But idk if there is an option to make such thing interact with Lumen.

taby
taby

JoeJ said:

That's very interesting for me to watch. I myself did only pretty static tests and could not observe the lag of Lumen.

Yeah it is laggy, isn't it….

I see the reflections are not laggy. But the GI is pretty much. It even seems to miss most particels, and catches just some of them randomly?
Or is this because it catches only particles which come close to the surface?

I have no clue what's going on LOL.

What's a curve light? Eventually a emissive spline? And it needs to be created from the trajectory of individual particles? That would rule out emissive smoke, i guess.
Idk what's a blackbody neither.

Sorry, I didn't explain that well. Black body radiation gives a peak in the electromagnetic spectrum based on temperature. So as temperature drops, the peak goes from red-hot to orange-hot to yellow-hot, to gray-hot (smoke). Basically, the gradient is like a rainbow. In UE5 you can bypass black body radiation and define a non-rainbow gradient instead.

JoeJ
JoeJ

taby said:
Sorry, I didn't explain that well. Black body radiation gives a peak in the electromagnetic spectrum based on temperature. So as temperature drops, the peak goes from red-hot to orange-hot to yellow-hot, to gray-hot (smoke). Basically, the gradient is like a rainbow. In UE5 you can bypass black body radiation and define a non-rainbow gradient instead.

Sounds like some convention to describe colors? Color temperature, lux or nits, or such stuff? Or even worse - spectral rendering :O ?
s-RGB? Rec. 709?? Hopeless attempts on uniform calibration??? Linear color space vs. gamma what?? CMYK???? YcBcR?
Vanta black? Black Hole Black? Hawking radiation Purple Haze? Gravitational Greys?? … all that… confusing shit?

nah, nah - not with me. Give me just RGB. And if its higher than one, it's ‘very bright’. That's enough for me.

taby
taby

I am chomping at the bit to learn Vulkan LOL. Must…. Focus… on… UE5!

P.S. Now I just need to win the lottery, so that I can buy a desktop with RTX GPUs. LOL

taby
taby

Dude, in case you're not pulling my leg… Planck and Einstein started quantum physics. It was Einstein's interpretation of the photoelectric effect that proved Planck right: photons are quanta, with an energy of E = h * frequency.

JoeJ
JoeJ

taby said:
P.S. Now I just need to win the lottery, so that I can buy a desktop with RTX GPUs. LOL

I've heard RTX 5xxx will have 6 x faster RT, 12 x more tensor cores, AI DOF, motion blur and player input prediction to compensate lag, on a chip that's only 10 x 10 cm in size.
No more need for computer case, because the GPU is so big that you can now put motherboard and some HDDs inside the GPU.
And you get 3 PSUs for free with it. (only two are needed, the third just in case one melts)

But it won't be cheap. Winning the lottery won't be enough, i'm afraid. So no, it's not for you. I am sorry. But no.

taby said:
I am chomping at the bit to learn Vulkan LOL. Must…. Focus… on… UE5!

Sounds you're exhausted from all those options, tools, effects, content browsers, and sheer awesomeness.
But just as disappointed from those small features you need but aren't there.

Idk what to suggest. Be creative on working around restrictions? Doing it somewhat differently than intended?

I liked this one, very impressive:

This uses MPM method. Simulation is all on CPU. GPU does the rendering.

Framerate was quite bad for me, maybe 20-30 fps. Not really a game, just a tech demo. but cool.

Though, i do not really believe in 3D fluid simulation for games yet. Anything volumetric is crazy expensive. And you know, the lottery….
For a Shmup you sure can keep the fluid box small, but how do you intend to deal with the scrolling?
For my own fluid sim i can set the boundary conditions to a warping mode, so fluid that goes out on the left, comes back from the right. This may be a standard option in UE too.
With some external velocity to drive the fluid at constant speed to the left, this would work similar like a scrolling background, or match the background scrolling visually.
Though, you'd notice the repetition and tiling. Explosion that goes out on the left, comes back from the right? Not sure how to deal with that.

There are some nice 2D games with fluid. Like this:

A fraction of the cost, and much larger simulation area is possible. And Shmup is 2D anyway, so i would consider 2D simulation as well.

JoeJ
JoeJ

taby said:
Dude, in case you're not pulling my leg… Planck and Einstein started quantum physics. It was Einstein's interpretation of the photoelectric effect that proved Planck right: photons are quanta, with an energy of E = h * frequency.

Sigh, i don't even know what ‘pulling a leg means’ : )

But did you hear about the wormhole in a quantum computer? Based on the idea that black hole wormholes and quantum entanglement is the same thing?
Maybe that's some progress on those fields.

But well, enough YT for now ; )

taby
taby

Sorry man. I meant to say are you joking? ?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.