Welcome back.
In this section we're concerned with map entrances.
Really, map entrances and map exits are the same thing because they take you somewhere else.
Some other map.
What I'm interested in is creating some kind of actor that once we reach it, it'll take us into another
map.
Now this is going to involve several different things, but the most basic of these things is I'd like
to know when we're highlighting a certain actor, if I hover over a map entrance, I want to see it
highlighted.
It would be nice if we could highlight dungeon entrances the same way we could highlight enemies.
Now, if I highlight an enemy, then it becomes red.
But if I highlight, say, a dungeon entrance or another map entrance, I want to highlight it, but
not red.
I like it to be a different color.
So how do we get this functionality, this highlighting, but different colors depending on what we're
highlighting?
Well, first we have to go to the material that's giving us this highlight effect.
That's our post process material that we have in our post-process volume.
If we select our post-process volume and in the details panel, search for material.
Here's the array of post-process materials used in this post-process volume.
And if we browse to px highlight, here is our post-process material that's giving us the highlight
effect.
Now, we don't have to understand all of the inner workings of this material.
As you can see, there's kind of a lot going on here.
The important part is right here where we have these colors.
Now we're only using red.
And for that reason, this material only has the ability to highlight red.
And it's highlighting something if that particular thing is using the custom depth stencil render pass.
And if that thing has its custom stencil value set to 250.
Now this system takes in the scene and checks out the scene's custom stencil values.
And anywhere in the scene where a given texel is using the custom depth render pass that texel, think
of texels as pixels in material space has a numerical value.
So we're getting that numerical value here and for the surrounding texels of the enemy, as long as
it's rendering to custom depth stencil, then these texels around the enemy have the value of 250.
Now let's just say that this wire here carries that value of 250.
It passes it into an if node.
If takes in two inputs A and B scalar values, and if A is 250 and b is 250, then we have three other
nodes here.
That determine what gets returned from this.
If based on A and B's values compared to each other.
If A is greater than B, if A is equal to B, and if A is less than b, all give the same output here,
and that output is what we have passed into these pins, which is the color red.
So we can change this to be more conditional based on that custom depth stencil value.
So let's just say we'd like to have a different color if we're using the custom depth stencil value
251 for instance.
Well, if the value that we're checking here a is greater than 250, we should have a different color
passed in.
We could pass in, say, one of these other colors right into A is greater than B.
So let's do it for a second.
Let me take this blue color here and take its value and plug it in.
Right here to the.
If for A is greater than B, what happens when we do that?
Well, if we apply this material and we come back into the scene and select our goblin, for instance,
we can take this goblin and select its mesh in the details panel.
Here it is.
And for its mesh.
I can search for custom depth.
And here we have render custom depth pass.
Remember we enable or disable this to allow something to be highlighted.
If I enable it and change custom depth stencil value.
First of all before I change it, notice that it's highlighted red, right?
And that's because this if says if this value here is either equal to B which is 250 return red, but
also if it's less than B return red, well zero is the value.
See custom depth stencil value zero.
That's less than b.
So we get red.
But now let's try putting in 251.
Oh, and I it worked, but I was actually selecting this ground tile here.
Notice the ground tile is now outlined in blue, so I'm going to have to uncheck that for the ground
tile and select the enemy.
And with the enemies mesh selected now I can enter 251.
And now we see that the enemy is highlighted blue.
So now we have the capability of highlighting things blue if they're custom depth stencil value is 251.
Well let's say we'd like more colors than that.
Well we have this other if here and this other if is checking that custom depth stencil value against
251.
And it has a case for when A is greater than B.
So if we have a value greater than 251 we're passing in something else.
If it's equal to 251, we're passing in the color blue.
And if it's less than 251 we're passing in the color blue.
So what happens if we take this which could potentially be blue and hook this into A is greater than
B here.
Well, now we have the capability of read for 250 and blue for 251.
If we apply this and take our goblin with its mesh selected and change it back to 250, we get red and
changing it to 251 we get blue.
Now, going back to this material, what we have for A is greater than B is an if and this if.
Checks the value against 251 if it's equal or less than we get blue, but if it's greater, we get the
result of this other.
If here, which is checking the value against 252, and if it's greater than or equal to 252, we get
tan.
So for that reason, if we take our goblin and select its mesh and set the custom depth stencil value
to 252.
Well, now we get this tan color.
So we have three custom depth stencil values 250 which corresponds to red.
251 which corresponds to blue, and 252 which corresponds to tan.
So now that we've enhanced or upgraded this post-process highlight material, we can now use blue and
tan for anything we like.
So this is pretty cool.
And remember that in our IDE we went into aura dot h, our project header file, and we defined custom
depth red to be 250.
We can also define our blue and tan as well.
And I'd like to do that I'd like to pound define custom Depth blue as 251 and define custom depth tan
as 250.
And now with this we can set the custom depth stencil values to anything to 251 or 250.
As long as we enable that custom depth stencil pass render custom depth stencil pass this right here.
And by the way, I've mentioned this when we first did this highlight material way back at the beginning
of the course.
That's quite a long time ago.
So I'm going to refresh your memory on something we had to do to make this all work, because you may
add this to another project, and it's not going to work unless you go into project settings and you
search for custom depth, and you make sure that custom Depth stencil pass is enabled with stencil,
not just enabled by default, it just says enabled.
So you might check this and see enabled and think, well, we can use the custom depth stencil.
Well we have to use custom Depth stencil pass, which means we need this enabled with stencil to use
this feature.
So make sure that that is set there.
Otherwise you'll be very frustrated and not know why this isn't working for you.
Okay, so this is great.
Now I can leave this as tan.
It doesn't matter because if I come back and hover over the enemy, it'll set this back to red.
And in addition to that, if I unhighlight it sets that render custom depth pass boolean back to false.
So we're not actually rendering it anymore.
And this comes back to what we're doing when we cursor trace.
Now I'd like to be able to cursor trace over multiple types of objects, not just enemies.
And I'd like to be able to highlight multiple things.
Now our highlight code is an interface function.
We have an highlight and a Unhighlight interface function.
And we put that in the combat interface because thus far we've only needed to highlight enemies.
But now we need to highlight non enemies.
And for that reason I'd like to make a new interface a highlight interface specific to highlighting
that we can add to any actor and give it the ability to highlight.
So for that reason, we're going to make a new interface and we're going to do that in the next video.
I'll see you soon.