tutorial

Baby Dragon - Tutorial on Materials and Giveaway!

Hey there! In this tutorial I am going to show you how to get your characters to the next level by making custom materials inside Unreal Engine 4 using Quixel in our texturing workflow. By the end of this tutorial you should be able to create unlimited variations to your characters!

You will learn how to use Material Functions to your advantage and how can you apply them to anything you make.

You can get the project and all the files including the model for free herehttps://gumroad.com/l/lOezd

This is what we will accomplish by the end of this tutorial, unlimited variations for our baby dragon!

First, we need to export our maps from Quixel, I use the UE4 RMA Packaged to get my Base color, Normal and Reflection map which it contains the Roughness, Metallic and Ambient Occlusion.

At this point we are exporting our maps with the colours we may think they work for our character. So we will import an Static Mesh to Unreal Engine to test the model and the maps!

After that, we need to import our maps, we need to take into account that the Reflection map we get form Quixel should be used as a mask (no sRGB) which means no colour correction. This is good for our Base Color maps but we want the exact values for our Roughness, Metalness (which we don't use in this model) and Ambient Occlusion.

We have 3 materials for this little dragon, but we will only work on the body for this example. You can create your basic Material as you would probably do in most cases. You will use the Base color, Reflection and Normal map inputs.

There is nothing from the other world at the moment, many people use this kind of setup for their games and it works really well. We can have our little dragon looking good inside the Engine!

But we have a problem with this kind of Material, what if we want to make different variations for our game? Let's say you don't want to model again another creature, just by changing colours you could tell to the player this is a different creature! So the first thing we want to change just to make our Material more flexible is to modify the normal map.

We've just modified the intensity of our normal map by separating the first 2 channels (red and green) and by multiplying them by an scalar value. After that, we can just use the Append node to combine them again. Let's check how can this dramatically change the look of our model without the need of rebaking the maps or modifying the sculpt!

Now we can change the normal intensity of our dragon! Didn't sculpt hard enough? Don't worry, we can handle it inside UE4. This is a powerful technique so why not save it for everything we make? Lets create a Material Function!

We have just replicated what we made inside the other Material but translated it into a Material Function. Many artists don't know where to start if they want to create functions. The truth is that is easier to create functions from something you already created. Do you think you will do it again? Then create a function! Let's now test inside our Body Material how the function can help us.

We've just made our life easier by eliminating all those nodes and replacing them with a single one. And not just that, need another Material? You can just right click and search for your function! In this case I've created a tag with the name "Unforgiven" so if I type that i get right away what i need.

Let's now change the roughness values of our model!

I've just separated our Mask texture into 3 parts, you can duplicate it by pressing Ctrl + W. Don't get scared, it references the same texture so you are not really increasing the number of textures you can use in your Material, this is just for organization purposes.

There are two things happening here. The first one is that i created a Lerp node to interpolate between 2 values, those will blend with my roughness map (red channel) and create a new MIN and Max value to change the reflections. The second thing is, I've right clicked my node and set it as a Preview to check if what I am doing is going in the right direction, you should always use this feature to test little by little how your Materials are going to work. It's hard to create a big network of nodes without testing it first.

I always forget what is the MIN and Max values and sometimes i want the MIN to be the new Max and the Max to be the new MIN. To solve this I recreated the same setup changing the inputs of A and B in the new Lerp node. Now we only need to create something to let us choose which one we want to use.

Two things are happening here. The first one is that I created an Static Bool Parameter, this allows me to ask myself: "Do i want to invert the roughness values?" If so, it will use the right MIN and MAX values I need. The second is, I used a Switch node. This is the way i can tell the Material which network i want to use and my boolean will decide if it is True or False.

The last thing we need to do is to create an Statich Switch Parameter to decide if we really want to change our roughness values or not, you never know if you will use one feature or another so it's better to think ahead from the start, let's see how this affects our model!

Let's create a Material Instance and apply it to the body material to see the changes in real time. Just right click on the Material you've just created and select Create Material Instance.

The changes are small, but can make a difference depending on your needs. There's nothing more tedious than going into the Painting App again just to change the roughness values if you can do it inside the Engine. Besides, if you want multiple characters you can give them more variation. Now that we've just tested it works, let's create a function so we can use it whenever we want!

Same as before, we are just replicating the old network into a function. Let's see how it looks in our main Material.

Much better! The "Invert Max And MIN is grayed out because we don't always need to invert the values. It would be a waste of time to create a bool each time we want to use this function. So if you need to create them is fine, but otherwise it will still work! Let's now get deeper and change the colours of our little dragon!

The first thing we want to do is to create a way to not give a solid colour to our mesh. So what we will do in this case is to split the 3 different channels of our base color map and multiply them by 3 different colours. Those colours are Vector parameters so we can change their value in the Material Instance, if you hold V you will create them automatically! Let's get into the next step.

 

We have just interpolated 2 different values using the Green channel as a mask. This will make sure we make a nice blending between the two, it will be subtle but it can make your piece stand out.

Now we have just Interpolated the last result we got and the third colour value using the Blue Channel as the Blending Alpha. Now... 3 colours is a little too much, so let's create something to let us decide if we want to use 3 colours or just 2.

We've just used the same technique as before. Created a Boolean to let us decide if we want two colours or the three of them. Then we used our switch parameter to decide which one we want to use!

Finally, we just need to create our Static Switch Parameter to decide if we want to change the colours or not. If It's true we will use the network we've just created, if not we will use our default Base color map we got from Quixel. Let's now test our results!

It works! We changed the colour of our baby dragon completely, but something is wrong here. Everything is just one colour! If i want the shell to be different i wouldn't be able to do it because we are changing all the parts. The good news is that it works, so we can create a function for it so we can use it later.

Same as before, we've just created the same network using a Material Function. At this point you should feel pretty familiar with the workflow. Notice that in order to get our individual channels from our Base color texture I've used the BreakoutFloat3Components node to be able to do that, Its a very useful node!

We now need to find a way to separate the colours from our mesh, for example I want the shell to have a different colour. So we'll use Quixel's features to make this happen.

Quixel allows us to export the masks we create inside it and combining them into their respective channels. Without this feature you would need to combine those mask in Photoshop and create your texture. Luckily for us, we can just select all the masks we want to export and let Quixel do the manual tasks.

We can just select all the layers we want to use (up to 3), right click and select Export Mask(s)

Then we select the destination we want to save the file and we are done! You should end up with a texture looking like this:

In my case I wanted one texture to have the Shell, some Skin areas and other Shell areas to make some differences. The other texture has the tongue, gum and mouth area. I didn't export the body since i could just invert the value inside the Material and get my body texture. Let's now import our texture to UE4!

Like before, we need to turn off sRGB so we can get the exact values of our masks. Now remember the function we create to change the colour of our mesh? Let's make some adjustments to make it only work where we want.

We just added our texture mask and use it as an Alpha to interpolate between the new color and the old one. Let's check if this works with our Material Instance.

It works! We can now change the shell colour. We can now proceed to colour the other parts of the model by repeating the same steps. First I want to add comments to our network, if you take vacations and come back to work later and you want to remember quickly what you did then this is the way to go.

Let's now recreate the same Network, we can just select all nodes and press Ctrl + W to duplicate them with all the connections made. We now need to change the name of the parameters and group them so we can find them in the Material Instance more easily.

To select the body parts, I used the same channel of the Shell and used a OneMinus node to invert the selection. Notice that the function we created is helping us tremendously to stay organized. Now we need to Lerp between the two colours.

Now that we are blending the Shell and the Body, let's check if it works on our Material Instance.

Now we are talking, you could say that we are getting there but we are missing some colour variation. This is were the masks will be useful to avoid losing the quality we got from texturing from Quixel.

Now we are using the Blue Channel to extract the part of the body we want to colour differently. Again, same setup and we are repeating the same step. Let's check how it looks in our model.

Now we can have a different colour on the body of our baby dragon. It's starting to look better! Let's continue to texture the rest of the model.

Now we have some variation on our Shell. Let's check how it looks.

Let's now finish this by completing the rest of the model using the other Mask.

Now we have combined all the colours, It's an easy step but it can get somewhat repetitive. Remember that if something get's repetitive, it's telling you that you can create a function from it. So i will leave it to you as a challenge! You could leave it as it is and create a Master Material for all the characters you want to put in your game, The more functions you have, the easier your life will be and you will be able to finish your games faster!

I hope this will be useful to you and your future projects!

Unforgiven Team

Mauriccio

 

 

 

 

.

Tutorial: How to make Spinning blade using Blueprint


Hey! I'm Ram, Unforgiven's programmer. Today, I wanted to share a little tutorial with you guys, because it shows some interesting concepts that you might use while working in the unreal engine. This blueprint is a part of the new Customizable Deadly Traps, which is coming up soon for Unreal's Marketplace.

Here, I'll talk about timelines, events and instanced static meshes. First, lets see what we are going to accomplish :

Normal spinning blade trap

Any number of blades

Initial Setup

Lets start by finding the meshes that we will use. We need the base of the trap and the blade that will be spinning. You can use the meshes that I used as placeholder when making this blueprint. ->Blade mesh<- and ->trap mesh<- (Click to download)

Now that we are ready to create the blueprint, we will create an actor blueprint with a static mesh component and an instanced static mesh inside.

Change the static mesh in both components.

Change the static mesh in both components.

Also let's set the z location of the blades to 153.

Construction Blueprint

Here's the picture of the construction blueprint

Click image to see it in full size

It won't work properly, but you can use this pastebin as an starting point of the construction blueprint if you don't want to start from scratch, just click on download raw and then copy and paste it in the blueprint.

In the construction blueprint, what we want to do is set the blades up, and also the collisions, so we can do something when a pawn overlaps any of the blades. To start with it, we are going to create a integer variable with the name NumberOfBlades that will be used by the for loop to help us add as much instances of the blades as we need. Set the default value of this variable to 1. Also create a vector variable with the name ModifyBoxExtentBy and a default value of (0;0;0) just in case we are not satisfied with the box collision extent.

Spawning the blades is easy!

What we need to keep in mind is the rotation and location that we are going to use to spawn each blade, since our blade has the pivot at the side we will only worry about the location. Using simple math we take 360 and divide it by the number of blades we have. (ex. 1 blade -> 1 blade with 360 rotation, 2 blades -> 1st blade with 90 rotation and 2nd with 360, etc).

After spawning the blade it is necessary to attach to it a box collision component so we can do something when the blade hits a pawn. Now that we set that up we find ourselves in this problem.

If we use the same transform for the collision boxes it generates a problem, because the pivot for the collision box is in the center.

To solve this problem, we are going to use polar coordinates.

θ is the angle in the image

θ is the angle in the image

With that settled all we need to do is the conversion from polar coordinates to Cartesian coordinates.
That marks the end of the construction script!

Event Graph

In the event graph, the first thing we are going to do is to create some variables that we'll be using for our next step:

  • Bool IsOn | default value = true | If true the trap will start active.
  • Bool IsSpinning | default value = false | If the blades are spinning at full velocity this will be true.
  • Float RevsPerSeconds | default value = 1 | Revolutions per seconds.
  • Float TransitionRate | default value = 1 | Play rate of the transition. Greater number = faster transitions between on and off.
  • Bool UseIntervals | default value = false | If checked the trap will be in the on state for an interval of time before switching off. This behaviour is used for the on and off states.
  • Float StateTimeinterval | default value = 3 | Time in seconds that the trap will be on or off.

Now lets take care of the event that is going to fire every time a pawn begins to overlap a box component created in the construction script.

Event BeginPlay

Click image to see it in full size

What we are doing in the event BeginPlay is going through the CollisionBoxes array and binding an event to OnComponentBeginOverlap, then renaming that event to HittedSomething. When fired, the event HittedSomething will cast the actor to a pawn and if the cast is successful it will execute anything we want.
After the loop is completed we will check if a boolean called IsOn is true and if it is, we will call a custom event named TurnOn.

Event Tick

Click image to see it in full size

In the tick event, we will apply the rotation to the blade(s). With a branch node we check if the trap is On and if it's spinning. Then we proceed to add the relative rotation to the blades in Z. Multiplying the RevPerSeconds by 360 gives us how much rotation should we add in a second and multiplying that value by the delta seconds gives us how much rotation should we add every tick.

Custom Events TurnOn and TurnOff

Right now we have a working blueprint that spins if it is on and when it hits something an event fires but there is no smooth transition between the states on and off. So these events are going to help us in that task and also provide us with a way to easily change the states during execution.

Click image to see it in full size

Let's look at the event TurnOn first. This event sets the isOn variable to true and then uses a for each loop to activate the collision of all the collision boxes. When this loop is completed the timeline named TurningOn will play from start.

One point at time 0 and value 0 and the other at time 2 and value 1.

In each update of the timeline we will add relative rotation to the blade and when it is finished the direction is going to be checked. If the direction is forward it means that the blade was in a off state, is turning on and now its at full speed so IsSpinning should be true. Also we should disablethe collision of the blades because if they collide with something they are going to cut it and not bump it.
Finally, we check if we are going to use intervals, if we are using intervals the time will be set through a delay node that will call the TurnOff event when time is right.

The TurnOff event will be similar to the TurnOn event but with minor changes. instead of playing from start the timeline will reverse form end and when it finishes we will set the variable IsSpinning to false, enable the collision of the blades and disable the collisions of the boxes.

And that's it!


Now you have everything you need to make your own Spinning Blades using Blueprints.

If you liked this tutorial, give us a like, share it with your friends and let us know what would you like to see in the future for more tutorials!

:D

Unforgiven Team
Ramanand