Houdini MaterialX - custom volume shader

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and in this lesson we're going to take a look at how to build your own custom volume Shader in material X the only limitation with this is uh it only works for karma CPU because xpu doesn't support all the base level material X nodes as yet so uh not restrictions but it is slow to render okay and it could also have some stability issues but beyond that if you want to do something really custom as far as volumes are concerned this is how you would approach it okay so this is a relatively Advanced lesson it's not really basic but someone wrote me an email yesterday and they were asking you know how would you go about rendering uh color volumes or colored volumes in karma and so I started to you know go down that rabbit hole and that's how we ended up here okay okay so uh this is not a basic pyro class so I'm just going to show you the Pyro setup that I have okay so what I have is uh I have my basic uh rubber toy and I used an attribute from map to transfer the texture to point level okay and then I have a pyro source which is said to initialize burn so it generates a burn in temperature and then I also want the color so I used an attribute transfer to call to transfer like you know this color data over to my points okay okay and then you do a volume rasterize I brought in the temperature and burn and also the color okay the CD okay now as far as the Pyro solver is concerned it's fairly simple I'm doing like if you come into Fields there's like I'm emitting smoke from flame okay and then uh shape wise I have like lower buoyancy and more turbulence and then I just cashed the whole thing out now one extra thing that I have done with this because I want the color data in there as well okay is if I come into the look and I get rid of the fire you'll see that I have colored smoke so what I've done is if you come into fields or sorry if you come into sourcing and you come down then you create a new source and you bring in the color okay so you say your Source volume is CD and the Target Field is CD and set it to Vector okay so that will make sure that your color data is stored as a volume okay of course like here it's showing you with this because when I cached it the you know the flame was the flame value was kept at 25. okay so that's as far as the basic you know uh smoke setup is concerned okay so let's come into lopnet just to show you what I have so I brought in my smoke and I have one dome light okay and I have uh one disk like like if I see it it should be there there you go okay so I have a disc light rating from here and I have a dome light in the middle there's no HDR or anything and then I just have my karma okay so to get started now this is as I said this is more customized okay like if you're doing a standard uh if if you're doing like a standard pyro render or a smoke render then you do get something called as if you type in pyro you'll get something called xpu pyro preview and this is the one that you want to use as far as you know like standard uh volume rendering is concerned with Karma XP or CPU and this is a very good node okay because it gives you like all the basic stuff you get your density and you know smoke color all of that you also get like if you're using the Pyro material node okay so you can you have your scatter value and fire and you know like all of that stuff but the issue with this is this is a hard-coded node okay and you can't connect anything into this so you have like four volumes that you can bring in but beyond that like if you want to multiply density with color or temperature with flame and you know like or anything weird you can't do that with this okay so instead we're going to build our own okay so what you want to do is uh first like type in volume and you'll get something called as material X volume material okay this is the base material that we need okay so if you I'll just call this as volume Shader and if you if we open up the Solaris scene graph then this is the material that you'll see so over here you'll get volume Shader okay and I can just assign this so assign like take the volume and take the volume Shader okay now right now it's empty so you won't really see much of anything but that's fine now the second thing you need is uh if you type in karma then you'll get something called as karma volume this is like a ready-made node that you get now with I believe it's with 19.5 because what you also get is you do get something called as a material X volume this is more base level okay like uh you need like more things to connect into this like you'll get like vdf nodes and then you'll get like PDF notes so vdf is volume and EDF is emission but that's like too much work okay so what the karma volume does is it gives you like all of that stuff you know in one node and it's also a little more faster to compile so this is the one that you want to use okay so this connects in here and if you try to render right now nothing is going to happen Okay like if I just set up Karma uh it's it doesn't have any data in there so it doesn't know what to do Okay so now what you want to do is we want to do a couple of things firstly we need to set up the absorption and scattering and they need to be controlled using the density value okay so start off with a geometry property value which is our way to bring in attributes and call it density okay and we bring in density over here okay now the absorption and scattering are both like vector values so take a constant so you'll take a material x constant and we'll call this as absorption and I'll call this as scattering and they both will be at color okay and we'll give it a white value for now now what we want to do is we want to take both these values and multiply it with the density but firstly I'll just take a power node so this will help me control the intensity of my or the density of my of my volume and then we will take two multiply nodes so 1 and 2 and the absorption and scattering they both go into input one because if you put the float value into input one then the output also becomes a float value and we want a vector and then this comes in here and this goes in there and let me just save this file and so if I plug this in over here and there and hit render now you will just restarted there you go now we have our basic you know volume and so now the scatter color becomes the color of the smoke okay so you can do this and the absorption is not it's like how light or dark the smoke should be like how much light it absorbs but you can also try to put in some color there which usually goes in the reverse Direction so yeah so if you have a color wheel like whatever color you pick it's picking the opposite I understand like why does that I can't really explain it okay so we don't want to do this like let's keep this to height that's fine okay but now we can start doing the fancier stuff so we do have a CD field with us because that's what we've generated okay so what I can do is I can type in uh geometry property value again let me just pause this and so I can come in here I'll call this color and I can bring in CD and let's do one thing before and so this will be set to color and we'll also take a color correct node so we will get a material X color correct so now so all of this stuff you can't do with the standard you know pyro node that you get and then plug this out over here okay and if we render it now so I'll press shift p it's not going to show anything so you'll always have to restart it but there you go so now you have color and you know I can do weird things with this if I want to so there you go you know like you can do fancy stuff with this okay now uh so this is as far as you know like the basic setup is concerned but now we can let's say uh we want to start setting up the emission okay so what I can do is I can take another geometry property value okay and this uh let's say we want to bring in flame so let me pause this and uh you know we'll bring in a color value here so let's call this as fire color and let's set this to like an orange and I can just pick up a multiply so let's say this should be let's say this is intensity okay so I'll keep this to around 10 and and let's just say for now if I just plug this in over here to emission okay and just do a restart see there you go so what I can do is now if I multiply this so if I take another multiply node and we need the color and the fire and plug that in and restart there you go so I make it around say 50. okay now uh let's say as a final thing you want to control the color of the fire or you know the based on the flame or you also want to control the intensity of the Fire based on the flame data okay or any other data that you want okay so what I can do is let's say instead of the fire color like this I can take a I can take a color ramp so I can take a color cubic ramp and this is the flame so you can bring in the flame or you can bring in the temperature like you know whatever you prefer and I'll take a range note so we have like a fit range so we have a material X range and I can plug this in over here and that goes out to you know this particular value and let's feed that in Okay so restart render and now what I can do is I can come in here and I can set this to let's try plasma and there you go so you can do you know more fancier stuff with this so what I can do here with the range is like if I start to adjust this see so I can you know kind of bring it up or down so I have a lot more control over it than I had before I mean similarly if you if you were to plug in though like the ramp with the density so you can also control the color of your smoke okay like if I just take instead of the color node let's say if I just uh you know I'll duplicate this and what I can do is I can plug in the density here and plug that out into my color so if I do a restart render it should be completely different from what we're getting right now see you know uh let me just I'll just turn off the flame value for now okay let me just make this zero so I can you know start to adjust this a bit let's just see what we get yeah there you go oh that's nice let's make it 50. and let's bring this up to 10. see so you can do like this kind of stuff which is a lot more customizable it's been relatively stable like I haven't had any crashes so you can use this if you want to but yeah just you know be careful because this is only CPU based so it is going to be a lot slower like if you're coming from redshift or octane or whatever it's going to feel a lot slower but it's also way more customizable like there is nothing in redshift or octane that allows you this level of customizability where you can like you know mix and match and do like a million different things with volumes okay okay as a final thing just for you know like fun purposes and I don't know how good this is going to be but you can also multiply this with like noise if you want to okay so I'm just going to pause this and let's say if I want to multiply the flame uh with a noise map okay so what I can do is uh let me just keep this here I'm going to take a let's type in noise and I'll get something called as fractal noise hold on let's just come to material X procedural 3D we'll get fractal material like fractal 3D okay and what I need is I need to do two things here so firstly I need a position data so material exposition and we'll put a we'll just put a multiply for uh you know frequency so this is the frequency okay and then uh I can just take a I'll just plug this into position and I can multiply it with this so let's just take a multiply here sorry uh okay and then let's multiply it with the flame value so we'll just take a multiply and put this through a clamp node okay because sometimes it generates values that are like over and above the range that we want let's put this through a range node as well so we'll get a little more control and then I can plug this into material clamp okay so plug that in and let's do a render and see what we get so shift p and then restart it and okay let's just see what we have this might not have been the best of things to do oh there you go okay okay so we're getting something okay let's take something let's do a 10. oh there you go that's weird enough and we can also take the out yeah that's not bad I mean it's weird but uh let's let's try something else because I was I was trying this before it looks weird but it looks it's it's fancy enough you can try to multiply this with the velocity okay so I'll just okay this does look strange but for our purposes right now it should be fine this is probably not the best way to work with this okay let's work with this this is fine okay okay what I can do is as a absolute final thing is uh let's pick up another geometry property value and I'm going to take the velocity let me just pause this so we'll type in well and this is a vector 3. we'll put a multiply and we're going to add it into our position so let's just put in a constant here so I can Define like how much the intensity of this should be this will be at one and this will add into the uh position data here so we'll put an add node so Multiplex add and this plugs in here okay let's just let's see what we get so restart render there you go see so it sort of distorts it based on the velocity okay so I'll just let this I'll let this render through and yeah don't do this but I think the rest of it is fine like if we if we just stop multiplying the flame with whatever I think the rest of it looks good okay but yeah it's it's an idea like you can multiply this with this with density as well like it looks fancy okay so I can just get rid of this and hit a restart there you go like this looks fine okay but anyways it gives you ideas of what you can do with this okay okay um if anybody wants I'll cover the basic pyro node as well I'll do that in in the next lesson but it's really simple like it's a five minute class okay but if you want I'll I'll do that in the next lesson okay and yeah that's pretty much it
Info
Channel: Rohan Dalvi
Views: 9,174
Rating: undefined out of 5
Keywords:
Id: KuI9B1MA6do
Channel Id: undefined
Length: 18min 45sec (1125 seconds)
Published: Mon Nov 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.