Creating water in UE4: Waves

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
for the past few weeks i have been thinking hmm i want to make water something similar to the water in sea of thieves [Music] with a little bit of googling i quickly realized that that is gonna be much harder than i thought so for the last few days i have been learning about rendering and simulating ocean waves i went out some papers watched a few videos and i need to say that i found it fascinating how quickly you can create good looking water with a little bit of math now i am not some professional in oceanology and all of that stuff so don't expect the most valid information from me for that you have other sources i'm just gonna go throughout what i've learned and share that with you from the perspective of someone that is still new to this stuff okay so let's start with the most basic wave the sine wave now for this simple sine wave we're gonna use an equation that is from the gpu germs on nvidia site but first we'll gonna need the plane so load up a blender delete everything add a plane and subdivide it how many times you want obviously the more resolution the better quality of the wave then save it as an fbx and export it to a nickel engine okay so what we're gonna do is that we will translate this equation to nodes so let's first take a sine node we're gonna need to change the period of the default value of 1 to 2 pi because that is the natural period of the sign now 2 pi is 6.28 and so on so let's just copy that to the node [Music] next up we have an direction dot projected with the position of x and y now we can translate direction as in constant vector 2 and we also want to make it ascend parameter but if we change it to the parameter it will create constant vector 4. we only want the x and y from that so let's add in component mask and mask out the z [Music] now we can normalize it and what nokomolyze does it will shrink however long vector you have to the length of one but it's gonna leave the same direction so if you increase the number in our parameter to a greater number than one it will scale the waves which we don't want that's why we normalize it the x and y position we can get with an absolute world position note this will give us all three axes so we will again mask out the z position and now we can dot product these two together [Music] next up we need to multiply this with w now we can see here that the w equals 2 divided by l and l is a wavelength and wavelength is increased to crest distance between waves in world space so let's make a wavelength and divide it with two [Music] now this together is a w and we can multiply it with our dot product next up we need to add time multiplied with this phase constant and here we can see that phase equals speed times 2 divided by l which is also in w so let's add speed and we will multiply it with our w then let's create time and multiply it with our phase constant and now we can add it with everything else and plug that into sign okay so the last thing we need to do in this equation is to multiply an amplitude with sine and you can see that amplitude is in front of the sine so we'll also gonna put it in front of the sign in our shader graph so let's add amplitude and multiply and at the last we want to push this function up on the z axis so to visualize it if i increase amplitude i want the value to go up and if i would push it on let's say x-axis it would scale on x-axis and it would look squashed like this so add and make float3 node plug it into the z and then plug zero to the x and y and now we can plug this into the reveal position offset so we have a basic sine wave but this is still not a gerstner value so here is an equation for the girl's negative wave function now you don't need to be scared most of this is already done next up we need to add in cosine and multiply it with the direction of x and y so let's add in cosine now cosine has the same period of 2 pi so we'll need to change that [Music] now let's take the direction of x and y by using component mask [Music] and we're gonna multiply it with our cosine [Music] next up we need to take in q multiply it with an amplitude and then multiply it with what we have just made okay so first we need to know what the q is here we can see that q is a parameter that controls the steepness of the waves for a single wave q of 0 gives the usual rolling sine wave and q of 1 gives a sharp rest now here we can see that q equals q divided by w multiplied by amplitude multiplied by num waves and we can specify num waves as in parameter so first let's multiply w with an amplitude then create a num waves parameter and multiply that with what we have multiplied before [Music] next we need to create q which is steepness and divide it [Music] and with all of this we have an qi now we need to multiply it with an amplitude and then we can multiply it with everything forward [Music] we also need to plug this into the cosine and at the last we need to plug this x function into x and y into y okay so what we're gonna do now is that we will make a material function out of this basically replace all of the parameters for function inputs i'm going to set a direction as in vector 3 and everything else essence color next to make a proper grass neck waves we will copy them 4 times then we will make 3 different directions i'm gonna plug stiffness and num waves to every function now i will plug speed amplitude and wavelength to the first and second function then i will make the third and fourth function slightly different i am gonna multiply the direction with -1 to make it go into another direction this way we will get crushing waves into each other and then we will multiply the speed amplitude and wavelength with 0.5 to make them half smaller [Music] okay so this is it thank you so much if you watched this video until the end if you would like to support me you can do so by subscribing to the channel and liking the video and if you would want to support me one step further consider supporting me on patreon again thank you for watching and bye bye [Music] you
Info
Channel: Marpy
Views: 13,347
Rating: undefined out of 5
Keywords: Water, ue4, Material, Waves, gerstner waves, unreal engine
Id: F8Q25nIyKPk
Channel Id: undefined
Length: 10min 16sec (616 seconds)
Published: Sun Jan 16 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.