Runtime virtual texture RVT in unreal engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi I'm nanar and in this video we're going to talk about rvt or runtime virtual texture so what is rvt so for showing you what is rvt let's just jump into Unreal Engine and you can see in here we have this log and if you zoom in here a little bit you can see it's not blending good together why because this landscape has a material and if you click on our landscape go down you can see it it is using mrock sandstone and if you click on our login here you can see it's using a material for itself right so these two material doesn't have any idea that other Mater material exist so they can't blend together good so you can see it's not blending too good together now if we use rvt can see if you bring bring it down again they will blend together and we can customize this so in this video I wanted I want to show you how you can do this so without any further Ado let's begin so in here I did create a simple landcape and if I find it here the landscape uh does have a material that is called emro sandstone and this mro sand Stone comes with a starter content you can have it as well so first thing to do in here for using virtual texture runtime virtual texture we should go to edit go to Project setting and in here search for virtual texture and in here enable virtual texture support and after you after you enable it restart the onreal engine and it will be enabled first thing to do let's just add a mega scan 3D object to our project so let's just go to Mega scan so in here I did download this one of the high quality right and we can add it to our project so now it is added let's just go to content draw in mega scan in 3D asset and put this log in our scene and let's just decrease the camera speed here and knowing here you can see it's not blending good with our landscape so what we can do now with this first of all we should tell oural engine to sample this area around it right so for doing that we should go here and in volumes go down in runtime virtual texture volume and create that runtime virtual texture in here let's just bring it up a little bit so we can see it clearly hit F on your keyboard so you can see these C in here so the size of this right now it's not sampling sampling nothing why because it's too small so let's just increase that by 500 for example for X and Y and Z okay so now it is big enough I think for our for to for it to sample around our log so let's just bring it here and bring it down so it will example this area in Z direction we don't need this much of a space so let's just decrease that by 200 okay and now if you go down you can see it is sampling our landscape right in this area it will sample this area that you can see right so now that we sample this area we want to save it in a texture and in this case virtual texture so let's just go to our content drawer and in here go to content I want to create a new folder and I want to call it rv2 or whatever you want to call it and now let's just right C go to textures and in here create a runtime virtual textures okay and in here I want to call this rvt or whatever you want to call it uh for example base color so with this we want to store the base color of this area that that we decide with the runtime virtual texture volume right so now with this we can tell it to save it in here right so if we click on our runtime virtual texture volume go down and in Virtual texture we should choose our rvt base color that we just create so what it means it means we create a runtime virtual texture volume and in this volume that we specify in here it will sample the base color of this landscape and save it in our virtual texture right so this virtual texture that we just create will have base color of this but before moving on you should double click on this texture and change some value in here for example the size of over texture I want to increase it like this crazy big right I want to increase it and in Virtual texture content I can tell it to just sample base color but I think it's a good idea to sample base color normal roughness and a specular right it will be cool so let's just save that now with that we are sampling this area inside our runtime V virtual texture volume and save it in rvt base color virtual texture right but we need another thing we need to save the height of this landscape as well because some landscape may have some height right so again in here in this virtual texture we can right click on it and go to edit and duplicate it okay I want both of them on same location so let's just copy this location and paste it for this location so both of them will be at the same lo location and in this virtual texture again we want to sample the height of this area right so let's just again create another virtual texture in here runtime virtual texture and this time I want to call it rvt height okay because we want to save the height of this landscape inside it right so let's just click on runtime virtual texture number two in here and in Virtual texture in here tell it to save it in the height but we should go to here and tell it make it bigger so we have more detail and in here in the virtual texture content we want to get a sample of the W height of these landscape so click on V height so now we are finished with that now with that setup Arial engine knows that we want to sample this area the base color roughness normal and W height and save it in some virtual texture okay now with that done we should go go to our landscape until it allow this uh virtual texture to use the materials right so let's just go down in here and find the virtual texture in here click add in here twice because we want to sample height and base color roughness and all of that no clicking here first base color and next the height okay these two virtual texture um we need it to be allowed to H create sample of this area that we specify right we are not finished yet why because if you go here you can see both of these textures are black what is the problem if you click on our landscape and go to our material let me go here in our material now in the material of our landscape we should tell it to what we want a sample right now these samp this Sandstone material this landscape material has base color roughness and normal and we want to sample those and we should tell onreal engine that we want to sample those right so for doing that we should right click in here and search for runtime virtual texture output okay and with this output we can um really store those um those detail like base color like normal like roughness inside our virtual texture no this is the base color let's just drag and drop from here to the base color we have the roughness let's just connect the roughness as well we have the normals in here in here I can just in here head middle most twice to create a brake node in here and connect it to the normal but this normal is in um tangent space and we should converted to word space why because this virtual texture need a word space word space normal right so for doing that we can again drag and drop from the normals and in here tell it to transform to w space and by default it is tangent space to w space okay so it will transform the normal to the word space so let's just connect that next thing we need need the word height and for getting the word height it's easy we can right click and search for word position okay just search for word position and it will give us absolute word position now with this absolute word position we can get the X Y and Z of each pixel but we need just word height that in Arial engine the Z is the word height right so let's just drag and drop from from here and search for component mask okay component mask and in this component mask we need the Z value you can see there is rgba it's like X Y and Z so the b is z so we don't need XY but we need Z for the W height right so let's just connect that to the W height and now with that setup we are sampling that area and Save it inside our virtual textures now let's just save this because we are working on the uh shaders and materials it will take little bit bit time to compile the shaders just wait until all the shaders is compiled and after that you can make some other changes now you can see that um the base color is really saving and storing the Bas color of our landscape and the rvt height the texture the virtual texture for height it's is storing the height okay now we can use this texture like a normal texture that we use in materials okay so we can use it in whatever material that we have so for example if you go to the log click on this log and open up the material for this log by opening the instance of that and after that go to parent the Master material for um our log okay and in here we can use those texture like a normal textures we can use that first of all we know that our virtual texture need normal to be in a word space so first of all click on your output this one this is our material node okay and we can change some setting in here if you don't know about the material just watch my playlist of video about materials okay it's easy to find just go to playlist I have just like uh seven playlist and all of those playlist is mine and you can find it fast first thing to do in here I want to change the shading model to default lit okay and after that make sure that you are using a material attribute because we want to combine or blend our landscape material with the log material we want to blend both of them so we need use material attribute because it's easier next thing because our virtual texture use word word space for its normals we should tell this uh material that we we want to use word space so we in here we can search for tangent okay tangent space normal and uncheck this by checking this we tell our real engine that the in this material we want to use w space not the T tangent space normal right so now with that finished we can blend two material we can blend the material for landscape and the material for the log we open the master material for our log right so this is the material for the log everything in here is is the material for overlog and if we just connected just like this in here it will be just overlog and there won't be any blending but we can get the material of our landscape with a virtual texture in here we can just right click and search for runtime uh virtual texture sample and in this virtual texture sample we can tell it that we want the base color of our landscape that we create right it's exactly like any texture it's just called virtual texture click on your rvt base color and know what it will give us it will give us these texture that we sample from our landscape right so now with that if we for example make a make material attribute in here okay and connect the base color to base color specular to uh specular roughness to roughness and just with that if we connect that material attribute to the output in here and save it and by just doing this we are applying the landscape material that we saved in Virtual our virtual texture to our LS right so if you go to our scene now you can see a l is getting the texture of our landscape and if you change the position of that you can see the effect on it it's just getting the material that we sample here so now with that we want to use a landscape material that we sample and some of these areas and other areas should have just the log material so let's just do that with these two we know that we have the landscape material and with this we have the log material so let's just blend them together with blend material attribute and with this blend material attribute let me connect this to here we can blend the landscape material and the log material together so let's just connect the the landscape material to a and the log material to the B and with the alpha we should decide how much of this log should use material of or l escape and how much of this log should use material of the actual log right so for example in here until this area we want to use the material of the landscape and after that to the top we want to use the material of our log right so no for calculating this Alpha what I'm going to do let's just drag and drop here so we can have some room in here so first thing to do I want to get the word position in here okay and with that word position I want to get just the Z because we need the word height right so in here I want to search for component mask and in this component mask I want to get just the Z value R XY Z so we need the Z value and again you remember in this in this rvt height we sample the height of our landscape so let's just get that search for runtime virtual texture sample and this time I want to get the height okay I want to get the word height of or landcape and in here I want to sub subtract this absolute word position by the word height of our virtual texture now I want to add this by add no mode to the bones of over log so we can manage it uh easily right so in here we can search for object bound okay and it will give us the bonds of our log X Y and Z but we need again the Z value so we can search for component mask and again we need the just the Z value and now with that we can add it to local W height in here right so with that I want to have more control of these Heights so for example from this to this I want it to be landscape material and after that b the um log material but I I want to have some control about it right so we can always control that and I want to create a scalar parameter in here by holding s and hit the leftmost button and in here I want to change the name of this parameter to the height okay so with this parameter I can multiply it like this multiply by the object bound so we have some control how much of the boundary of these LS should be landscape material and how much of it we want it to be logs material and now with that we can sub subtract subtract this value by this value right so now we have some control over the height right the height of the landscape how much landscape should come up of the log now I want to have more control of the distance that we want to uh blend these two together BL blend these two material together so I can divide this by just a scolar parameter hit s and in here I want to change its name to distance okay and let's just connect this to the B next thing to do I want to saturated because this value can get uh more than one and you know that material and shaders need just a value between zero and one and if a value is more than one it won't work as you want so we want to saturate it or clamp it to zero and one we can do it by just saturating note add it in here and we will be fine so next thing to do I want to get the vertex normals because normals in is important in all log so we can get the normals okay the position of the normals and get the height value of that that is z so we can search for component mask again and get the Z value in here okay and with this Z value we can get saturated so it will be a value between 0er and one always in material everything should be between 0er and one and this Alpha needs a value between zero and one and it shouldn't be more than one no I have I want to have some control over this with a power node so I can add a power node in here and I want to power it with a scalar parameter by hting holding s on our keyboard and left most button in here and I want to call this power okay and with this I have some control over over the normals and now with that we can add these two okay these and these together and with that we can decide the alpha of the blend material attribute no everything is finished here but there is a problem in here the material for the log is using tangent space and we should convert it to the word space because we are using a virtual texture and our virtual texture need a w space to blend with right so for doing that we can just drag and drop from here and search for get material attribute and in this get material attribute I want to get the normal just clicking this plus and tell it to give us the normal and with that normal I want to set material attribute okay H the normal of this material again we should choose the normal so we can transform this normal transform from the tangent space toward the space you can see it in here and we need others parameters on this material to be exactly the same but the normal we want it to be in W the space so we change it like this and after that we can just connected to the B of our blend material attribute now everything is finished let's just save our material so now if we go to our scene you can see our log is in here and there is no uh blending happen in here right but if you go to our material instance open it and change some value because all of the values right now is zero so let's just change those value to see the difference for example the power I want to put it on 1,000 and now you can see the color of our logs is perfect now we can change the height you can see it in here as well let's just increase it so you can see it's blending now and now with the distance we can we can blend it better like this okay and know with all of those options okay let's just save it and know in here if we change the position of over logs it will blend into over scene very cool you can see it it's really cool it's like a part of our landscape and we can change the position of that we can bring it up bring it down and you can see it's really blending into a landscape and if you go out you can see it's just like this is a part of our landscape so that was it guys for this video this video take like uh I I recorded for four times one time for I think one hour of recording and I did delete it because it wasn't cool enough so please please please if you want to help me and you like this video hit that like button and subscribe to my channel it's my honor to have you here thank you thank you thank you very much for watching [Music] bye
Info
Channel: unreal magic
Views: 14,761
Rating: undefined out of 5
Keywords: unreal engine 5, unreal engine 5 tutorial, unreal engine 5 basics, unreal engine 5 beginner, ue 5, ue 5 tutorial, ue 5 basics, ue 5 beginner, unreal engine
Id: mQHetMALRRw
Channel Id: undefined
Length: 25min 10sec (1510 seconds)
Published: Tue Nov 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.