• Ever wanted an RSS feed of all your favorite gaming news sites? Go check out our new Gaming Headlines feed! Read more about it here.

Arthands

Banned
Oct 26, 2017
8,039
Polygon published a video today, where Valve developer Matthew Wilde shares his break down on how he made the fluid effect in Half-Life: Alyx look so damn impressive.




ebd09ce02b4b9b7c3d59eb442ee6afe22f20d291.gif

Matthew Wilde is able to build this in the basement with some booze
 
Last edited:

Tokyo_Funk

Banned
Dec 10, 2018
10,053
It really is amazing what can be done at the shader level.

Even more amazing that this guy finished the game and said "You know what, all these bottles need something extra" and patched it in. Good stuff.
 

mjhaas

Member
Aug 28, 2019
146
Oh wow, I thought that gif was real life at first glance! Very impressive.

Edit: I just watched the video and it's great too. Very informative. I'll have to check out her other stuff.
 
Last edited:

BeI

Member
Dec 9, 2017
5,966
Another cool physics sort of thing from Alyx was moving stuff around in drawers. Items seem to move around as you'd expect based on how much force you use on the drawer. Gently open or close it and the item will stay still, but go fast enough and the item will roll around, and it will get faster with more force.
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
I love visual hacks of all types. They encourage creativity and efficiency, and I hope the industry never stops striving to do things the 'cheap' way. A visual effect doesn't need to simulate reality behind the scenes, it just needs to make the viewer believe that that's what it's doing. That's all that matters!

I'm all about saving precious cycles for tasks that actually need them.
 
Oct 29, 2017
13,470
Using cubemaps for refractions is a great solution. Didn't think the bottles were entirely opaque objects. Even with new and optimized ray tracing techniques around the corner glass is one of the most expensive things to replicate if you actually want to brute force actual refraction. He's completely right when he says we don't know of the top of our heads how bottles normally look, nor how light and refractions would actually behave with complete accuracy like we could recognize that a face isn't realistic. So inaccurate fake refractions are more than good enough to fool us, so there's no need to actually use a more accurate method.
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
Using cubemaps for refractions is a great solution. Didn't think the bottles were entirely opaque objects. Even with new and optimized ray tracing techniques around the corner glass is one of the most expensive things to replicate if you actually want to brute force actual refraction, but he's completely right when he says we don't know how bottles normally look, nor how light and refractions would actually behave with complete accuracy like we could recognize that a face isn't realistic. So inaccurate fake refractions are more than good enough that fool us, so there's no need to actually use a more accurate method.

Honestly, when it comes to glass or ice refractions, a good screen space approach is enough to fool most people. They'll see the offset/distortion and think, "yup, that looks realistic!"

I think it also helps how dirty/blurry the reflections are. Crisper/cleaner reflections are much easier to scrutinize.
 
Last edited:
Oct 29, 2017
13,470
Honestly, when it comes to glass or ice refractions, a good screen space approach is enough to fool most people. They'll see the offset/distortion and think, "yup, that looks realistic!"

I think it also helps how dirty/blurry the reflections are. Crisper/cleaner reflections are much easier to scrutinize.
Begs the question if abandoned settings in AAA games are simply technology dictating narrative, because if you want to make TLoU2 or Half Life: Alyx look as realistic as possible, then you cover the walls and windows with dirt and dust.

Maybe in 20 years we are like "remember when every big budget game took place in dilapidated locations?"
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
Begs the question if abandoned settings in AAA games are simply technology dictating narrative, because if you want to make TLoU2 or Half Life: Alyx look as realistic as possible, then you cover the walls and windows with dirt and dust.

Maybe in 20 years we are like "remember when every big budget game took place in dilapidated locations?"

There is some truth to this. There is a reason why before real-time ray-tracing, it was pretty common for AAA games to avoid using many perfectly specular materials in the environment. Even the metals that were there were almost always dirty and/or oxidized (same with mirrors). Cubemapping can be an expensive process (what with rendering the environment six times) so the reflections needed to be heavily obfuscated in order to be cheaper to render while still being believable.

Now with performant RT, you can expect to see everything all clean and shiny again 🙃
 

Pikelet

Member
Oct 27, 2017
1,396
Begs the question if abandoned settings in AAA games are simply technology dictating narrative, because if you want to make TLoU2 or Half Life: Alyx look as realistic as possible, then you cover the walls and windows with dirt and dust.

Maybe in 20 years we are like "remember when every big budget game took place in dilapidated locations?"
Probably a few reasons for this. Post apocalypse narratives are popular in all forms of media currently, and also it is simply easier to create more convincing locations when there aren't that many people there.
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
Probably a few reasons for this. Post apocalypse narratives are popular in all forms of media currently, and also it is simply easier to create more convincing locations when there aren't that many people there.

Yeah this is true too. However, we haven't seen regular use of fully specular/reflective surfaces in video games since the ps2/GC days. Once rendering pipelines got more complex/costly during the 360/PS3 era, the render to texture planar reflections fell out of favor for more glossy/blurry/dirty 'reflections'. There were exceptions of course, but the absence of real reflections in most games during that time (and during last gen) was really noticeable.
 

DeadlyVenom

Member
Apr 3, 2018
2,763
I mean with an increase in RT Reflections, you will see fewer broken/removed mirrors in bathrooms.
 

Kent

Member
Jun 4, 2018
1,098
Mirrors that don't reflect bothers me more lol
It's still very common for mirrors to do reflections by simply duplicating all of the objects on the side the player is on, with the "mirror" itself being a literal "window" instead.

It may be relatively computationally-expensive to do, if you think about it in terms of just rendering everything again, but what's not computationally-expensive is typically the bathrooms in which they exist. It's basically why you see any non-raytraced mirrors exist in games at all.
 
Oct 25, 2017
3,721
Another cool physics sort of thing from Alyx was moving stuff around in drawers. Items seem to move around as you'd expect based on how much force you use on the drawer. Gently open or close it and the item will stay still, but go fast enough and the item will roll around, and it will get faster with more force.
The fact that this even ended up being used as a mechanic in a "boss fight" was amazing.
 

Tankshell

Member
Nov 1, 2017
2,111
I spent a good long while in that hotel lobby shaking bottles when they dropped this improvement. Time I'll never get back. Would shake again.
 

Ionic

Member
Oct 31, 2017
2,734
I'll be honest when this impressive visual feature that was otherwise inconsequential to the gameplay came out I was hoping over the next couple months we'd see a bunch of other visual flourishes added to the game by other employees. Would've been neat to see small parts of HL:Alyx evolve over the year.
 

Pottuvoi

Member
Oct 28, 2017
3,062
It's still just enthralling to look at. Really interested in hearing them expound on it further
Oh, yes.
The movement of fluid, bubbles and such really sell the illusion.
Using cubemaps for refractions is a great solution. Didn't think the bottles were entirely opaque objects. Even with new and optimized ray tracing techniques around the corner glass is one of the most expensive things to replicate if you actually want to brute force actual refraction. He's completely right when he says we don't know of the top of our heads how bottles normally look, nor how light and refractions would actually behave with complete accuracy like we could recognize that a face isn't realistic. So inaccurate fake refractions are more than good enough to fool us, so there's no need to actually use a more accurate method.
Yup.
Cubemaps can be used for many wonderful little hacks from faked transparency to distance LoD for windows or hallways.

I'm starting to think that highly transparent surfaces in many cases should be rendered as opaque objects, basically a first ray until transparent surface is hit.
After that a solution which handless refractions/reflections and whatever happens afterwards.
This solves the sorting problems of transparent surfaces, makes the rasterization pass a lot faster, allows easy lighting, shadows etc. (At least for the first hit.)
 

Vash63

Member
Oct 28, 2017
1,681
I'm starting to think that highly transparent surfaces in many cases should be rendered as opaque objects, basically a first ray until transparent surface is hit.
After that a solution which handless refractions/reflections and whatever happens afterwards.
This solves the sorting problems of transparent surfaces, makes the rasterization pass a lot faster, allows easy lighting, shadows etc. (At least for the first hit.)

Not sure it really makes shadowing easier, since you'd have to make sure its shadow is also transparent or you will have a clear glass bottle with a dark, sharp shadow.
 

Pottuvoi

Member
Oct 28, 2017
3,062
Not sure it really makes shadowing easier, since you'd have to make sure its shadow is also transparent or you will have a clear glass bottle with a dark, sharp shadow.
In some cases received shadows on transparent objects have been handled differently, also screen space tricks do not usually work with them.
Shadows cast from transparent objects need to be done differently. (Which you have to do even with current methods.. )

In UE4 you can have cheap transparent shadows by dithering transparent surface when rendering shadowmap, so you get somewhat cheap/decent version of transparent shadow. (Shadowmap blurring and TAA handles artifacts in viewspace, although this doesn't give colored shadows.)

Proper solution would be to follow path of light after it diverges from first hit to transparent surface and all changes on the way.. ;)
 
Last edited:

Laiza

Member
Oct 25, 2017
2,170
I just want to take a moment to note that this is what happens when a company is competently and humanely managed.

From everything I've heard Valve's workplace is pretty much a dream to work at, especially since you're not pressured into doing things you're not interested in or lack the headspace for. A developer doing something like this on a whim is only possible when they have the room to do things on their own time, rather than being shoved into the office 16 hours a day at the expense of their physical and mental well-being.

Now, folks can badmouth Valve's business practices and seeming lack of focus all they want to (and, honestly, I'm not in a position to disagree), but from a developer perspective they're doing things right.
 

Vash63

Member
Oct 28, 2017
1,681
That Booze shader is AMAZING, I wish it were part of DirectX libraries so that every game can have it.

Considering Valve is moving towards Vulkan (and in fact are largely responsible for Vulkan existing) and away from DirectX, that's very, very unlikely to happen.
 

Nekyrrev

Member
Oct 28, 2017
1,121
Great video thank you.
This guy made a similar shader for fun after seeing the one in Alyx, pretty good looking too:
 

FelixFFM

Member
Nov 7, 2017
345
Cubemapping can be an expensive process (what with rendering the environment six times)
Cubemapping doesn't mean rendering the environment six times. A cubemap is a single texture, and the reflection is done with a single lookup. Generating cubemaps is indeed expensive, but it's an offline process, reflection cubemaps are static and they aren't updated during runtime.
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
Cubemapping doesn't mean rendering the environment six times. A cubemap is a single texture, and the reflection is done with a single lookup. Generating cubemaps is indeed expensive, but it's an offline process, reflection cubemaps are static and they aren't updated during runtime.

While it is true that traditional static cubemaps are done offline and the end result functions much like you describe (though generating the necessary view for each face of the texture will still require a 90 degree frustum snapshot render for six different directions), that is not the case for real-time cubemaps that have to be generated on-the-fly. To be clear, it's not really the cubemap itself that renders a scene six times, it's the reflection probe that needs to capture the environment for each face of the texture.

For example, in Breath of the Wild, cubemap generation starts with the environment being rendered six different times in real-time (using a reflection probe that follows Link around). However, to improve performance, the reflected environment is significantly less detailed and only updates once every couple of seconds instead of on every frame. It also helps that the samples are mainly used for a crude global illumination solution via a process similar to convolving irradiance maps, so the resulting cube faces don't really need to be very detailed.

This is how reflection probes look in Unity:

RefProbeOrigin.svg


The probe's Type property determines how the reflection data is created and updated:

  • Baked probes store a static reflection cubemap generated by baking in the editor.
  • Custom probes store a static cubemap which can either be generated by baking or set manually by the user.
  • Realtime probes update the cubemap at runtime and can therefore react to dynamic objects in the scene.


And this is how it's handled in Unreal:

Reflections_1_6_Header.webp


Scene Capture Cubes capture a fully dynamic cube map from their location on every frame. This requires a Cubemap Render Target to actually capture to, and then that Render Target can be used as a texture within any Material.

Scene Capture Cubes are quite expensive in terms of performance and should be used only when they are absolutely required to achieve a given effect.

docs.unrealengine.com

Content Examples Sample Project for Unreal Engine

This sample project demonstrates specific concepts and techniques to use in Unreal Engine.


Even with caveats, real-time cubemap generation is still a very expensive process (in real-time), though it offers the benefit of dynamic reflections, so the trade-off is typically worth it. These days you can even get fancy with box projected cube environment mapping in order to produce local reflections that look accurate with proper parallax. Of course, that's an even more expensive option, haha
 

ILikeFeet

DF Deet Master
Banned
Oct 25, 2017
61,987
Great video thank you.
This guy made a similar shader for fun after seeing the one in Alyx, pretty good looking too:

we even had a whole thread on it

www.resetera.com

that impressive liquid shader from Half-Life: Alyx has seemingly inspired various devs to create their own versions

Somewhere late last month, Valve released an update for Half-Life: Alyx which set the benchmark of liquid shader for video game. Since the update, various youtubers has go in depth into the game to examine the effect, and needless to say it is rather impressive. The fluid shader includes foam...
 

Sacrilicious

Member
Oct 30, 2017
3,312
That's really cool, I love how well those tricks can give the illusion of something much more complex.

Bottles are a good shape to fake the dynamics for, it's mainly dealing with rotation (basically a flat line that fills a certain volume). The lighting and refraction look good (it doesn't need to be exact to be convincing), and the little extras like vibration and bubbles really sell it.

As much as I love seeing the real thing, it's sometimes more impressive to see people fake it so well with simpler tech.
 

Nekyrrev

Member
Oct 28, 2017
1,121
we even had a whole thread on it

www.resetera.com

that impressive liquid shader from Half-Life: Alyx has seemingly inspired various devs to create their own versions

Somewhere late last month, Valve released an update for Half-Life: Alyx which set the benchmark of liquid shader for video game. Since the update, various youtubers has go in depth into the game to examine the effect, and needless to say it is rather impressive. The fluid shader includes foam...
I missed it actually, thanks.
 

plagiarize

Eating crackers
Moderator
Oct 25, 2017
27,490
Cape Cod, MA
While it is true that traditional static cubemaps are done offline and the end result functions much like you describe (though generating the necessary view for each face of the texture will still require a 90 degree frustum snapshot render for six different directions), that is not the case for real-time cubemaps that have to be generated on-the-fly. To be clear, it's not really the cubemap itself that renders a scene six times, it's the reflection probe that needs to capture the environment for each face of the texture.

For example, in Breath of the Wild, cubemap generation starts with the environment being rendered six different times in real-time (using a reflection probe that follows Link around). However, to improve performance, the reflected environment is significantly less detailed and only updates once every couple of seconds instead of on every frame. It also helps that the samples are mainly used for a crude global illumination solution via a process similar to convolving irradiance maps, so the resulting cube faces don't really need to be very detailed.

This is how reflection probes look in Unity:

RefProbeOrigin.svg





And this is how it's handled in Unreal:

Reflections_1_6_Header.webp




docs.unrealengine.com

Content Examples Sample Project for Unreal Engine

This sample project demonstrates specific concepts and techniques to use in Unreal Engine.


Even with caveats, real-time cubemap generation is still a very expensive process (in real-time), though it offers the benefit of dynamic reflections, so the trade-off is typically worth it. These days you can even get fancy with box projected cube environment mapping in order to produce local reflections that look accurate with proper parallax. Of course, that's an even more expensive option, haha
Great explanation.

I like to point to racing games as a good example of this.

Most racing games handle real time reflections by generating cube maps on the fly (although sometimes they'll be generated every other frame). Due to the expense of them, they usually take the cube map generated from the player's car, and simply apply that to the other cars. It's a common optimization that is really hard to spot in real time, although if you pay close attention when driving under something, you can pick it out.
 

brainchild

Independent Developer
Verified
Nov 25, 2017
9,478
Great explanation.

I like to point to racing games as a good example of this.

Most racing games handle real time reflections by generating cube maps on the fly (although sometimes they'll be generated every other frame). Due to the expense of them, they usually take the cube map generated from the player's car, and simply apply that to the other cars. It's a common optimization that is really hard to spot in real time, although if you pay close attention when driving under something, you can pick it out.

Thanks.

Yeah, racing games are probably the one genre that has stayed consistent with incorporating real-time reflections over the years. I suppose having shiny cars as the main game agent kind of necessitates that, lol