WEBVTT

00:07.200 --> 00:08.340
Welcome back.

00:08.850 --> 00:12.630
In this section we're concerned with map entrances.

00:12.900 --> 00:18.030
Really, map entrances and map exits are the same thing because they take you somewhere else.

00:18.030 --> 00:19.230
Some other map.

00:19.560 --> 00:25.260
What I'm interested in is creating some kind of actor that once we reach it, it'll take us into another

00:25.260 --> 00:25.920
map.

00:26.280 --> 00:32.790
Now this is going to involve several different things, but the most basic of these things is I'd like

00:32.790 --> 00:38.790
to know when we're highlighting a certain actor, if I hover over a map entrance, I want to see it

00:38.790 --> 00:39.750
highlighted.

00:40.640 --> 00:45.680
It would be nice if we could highlight dungeon entrances the same way we could highlight enemies.

00:46.250 --> 00:49.730
Now, if I highlight an enemy, then it becomes red.

00:49.730 --> 00:55.280
But if I highlight, say, a dungeon entrance or another map entrance, I want to highlight it, but

00:55.280 --> 00:56.060
not red.

00:56.090 --> 00:57.980
I like it to be a different color.

00:57.980 --> 01:03.920
So how do we get this functionality, this highlighting, but different colors depending on what we're

01:03.920 --> 01:04.730
highlighting?

01:05.090 --> 01:10.640
Well, first we have to go to the material that's giving us this highlight effect.

01:11.270 --> 01:15.950
That's our post process material that we have in our post-process volume.

01:15.950 --> 01:21.770
If we select our post-process volume and in the details panel, search for material.

01:21.800 --> 01:26.600
Here's the array of post-process materials used in this post-process volume.

01:26.600 --> 01:33.230
And if we browse to px highlight, here is our post-process material that's giving us the highlight

01:33.230 --> 01:33.980
effect.

01:35.100 --> 01:39.030
Now, we don't have to understand all of the inner workings of this material.

01:39.030 --> 01:42.120
As you can see, there's kind of a lot going on here.

01:42.480 --> 01:46.170
The important part is right here where we have these colors.

01:46.200 --> 01:48.420
Now we're only using red.

01:48.420 --> 01:53.370
And for that reason, this material only has the ability to highlight red.

01:53.370 --> 02:01.320
And it's highlighting something if that particular thing is using the custom depth stencil render pass.

02:01.320 --> 02:07.560
And if that thing has its custom stencil value set to 250.

02:07.830 --> 02:14.460
Now this system takes in the scene and checks out the scene's custom stencil values.

02:14.460 --> 02:23.520
And anywhere in the scene where a given texel is using the custom depth render pass that texel, think

02:23.520 --> 02:28.740
of texels as pixels in material space has a numerical value.

02:29.070 --> 02:36.060
So we're getting that numerical value here and for the surrounding texels of the enemy, as long as

02:36.060 --> 02:43.080
it's rendering to custom depth stencil, then these texels around the enemy have the value of 250.

02:43.110 --> 02:48.030
Now let's just say that this wire here carries that value of 250.

02:48.030 --> 02:50.280
It passes it into an if node.

02:50.280 --> 02:59.700
If takes in two inputs A and B scalar values, and if A is 250 and b is 250, then we have three other

02:59.700 --> 03:00.810
nodes here.

03:01.550 --> 03:04.460
That determine what gets returned from this.

03:04.490 --> 03:08.000
If based on A and B's values compared to each other.

03:08.300 --> 03:16.040
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,

03:16.340 --> 03:20.930
and that output is what we have passed into these pins, which is the color red.

03:21.470 --> 03:27.800
So we can change this to be more conditional based on that custom depth stencil value.

03:28.220 --> 03:33.950
So let's just say we'd like to have a different color if we're using the custom depth stencil value

03:33.950 --> 03:35.720
251 for instance.

03:36.260 --> 03:43.460
Well, if the value that we're checking here a is greater than 250, we should have a different color

03:43.460 --> 03:44.360
passed in.

03:45.080 --> 03:50.270
We could pass in, say, one of these other colors right into A is greater than B.

03:51.240 --> 03:53.100
So let's do it for a second.

03:53.100 --> 03:57.780
Let me take this blue color here and take its value and plug it in.

03:58.670 --> 03:59.630
Right here to the.

03:59.630 --> 04:03.560
If for A is greater than B, what happens when we do that?

04:03.560 --> 04:09.980
Well, if we apply this material and we come back into the scene and select our goblin, for instance,

04:09.980 --> 04:14.150
we can take this goblin and select its mesh in the details panel.

04:16.400 --> 04:17.450
Here it is.

04:17.450 --> 04:19.160
And for its mesh.

04:20.220 --> 04:22.950
I can search for custom depth.

04:23.890 --> 04:26.230
And here we have render custom depth pass.

04:26.260 --> 04:30.820
Remember we enable or disable this to allow something to be highlighted.

04:30.820 --> 04:34.420
If I enable it and change custom depth stencil value.

04:34.420 --> 04:38.500
First of all before I change it, notice that it's highlighted red, right?

04:38.500 --> 04:47.650
And that's because this if says if this value here is either equal to B which is 250 return red, but

04:47.650 --> 04:51.760
also if it's less than B return red, well zero is the value.

04:51.790 --> 04:54.310
See custom depth stencil value zero.

04:54.340 --> 04:55.450
That's less than b.

04:55.450 --> 04:56.470
So we get red.

04:56.470 --> 04:59.560
But now let's try putting in 251.

05:01.100 --> 05:05.360
Oh, and I it worked, but I was actually selecting this ground tile here.

05:05.390 --> 05:11.870
Notice the ground tile is now outlined in blue, so I'm going to have to uncheck that for the ground

05:11.870 --> 05:14.690
tile and select the enemy.

05:14.690 --> 05:19.010
And with the enemies mesh selected now I can enter 251.

05:19.010 --> 05:22.190
And now we see that the enemy is highlighted blue.

05:23.030 --> 05:29.570
So now we have the capability of highlighting things blue if they're custom depth stencil value is 251.

05:29.870 --> 05:32.330
Well let's say we'd like more colors than that.

05:32.420 --> 05:40.160
Well we have this other if here and this other if is checking that custom depth stencil value against

05:40.160 --> 05:41.330
251.

05:41.330 --> 05:45.320
And it has a case for when A is greater than B.

05:45.320 --> 05:50.150
So if we have a value greater than 251 we're passing in something else.

05:50.150 --> 05:53.810
If it's equal to 251, we're passing in the color blue.

05:53.840 --> 05:58.250
And if it's less than 251 we're passing in the color blue.

05:58.250 --> 06:04.070
So what happens if we take this which could potentially be blue and hook this into A is greater than

06:04.100 --> 06:04.850
B here.

06:05.830 --> 06:11.470
Well, now we have the capability of read for 250 and blue for 251.

06:11.470 --> 06:19.330
If we apply this and take our goblin with its mesh selected and change it back to 250, we get red and

06:19.330 --> 06:22.090
changing it to 251 we get blue.

06:22.090 --> 06:29.020
Now, going back to this material, what we have for A is greater than B is an if and this if.

06:29.570 --> 06:36.140
Checks the value against 251 if it's equal or less than we get blue, but if it's greater, we get the

06:36.140 --> 06:37.160
result of this other.

06:37.160 --> 06:43.970
If here, which is checking the value against 252, and if it's greater than or equal to 252, we get

06:43.970 --> 06:44.690
tan.

06:44.690 --> 06:51.140
So for that reason, if we take our goblin and select its mesh and set the custom depth stencil value

06:51.140 --> 06:52.520
to 252.

06:53.410 --> 06:56.200
Well, now we get this tan color.

06:56.590 --> 07:01.480
So we have three custom depth stencil values 250 which corresponds to red.

07:01.510 --> 07:07.630
251 which corresponds to blue, and 252 which corresponds to tan.

07:07.930 --> 07:15.880
So now that we've enhanced or upgraded this post-process highlight material, we can now use blue and

07:15.880 --> 07:17.860
tan for anything we like.

07:18.310 --> 07:19.990
So this is pretty cool.

07:20.290 --> 07:29.560
And remember that in our IDE we went into aura dot h, our project header file, and we defined custom

07:29.560 --> 07:31.360
depth red to be 250.

07:31.600 --> 07:35.470
We can also define our blue and tan as well.

07:35.470 --> 07:51.310
And I'd like to do that I'd like to pound define custom Depth blue as 251 and define custom depth tan

07:52.720 --> 07:54.340
as 250.

07:56.500 --> 08:04.090
And now with this we can set the custom depth stencil values to anything to 251 or 250.

08:04.090 --> 08:11.230
As long as we enable that custom depth stencil pass render custom depth stencil pass this right here.

08:11.230 --> 08:18.370
And by the way, I've mentioned this when we first did this highlight material way back at the beginning

08:18.370 --> 08:18.970
of the course.

08:18.970 --> 08:21.220
That's quite a long time ago.

08:21.220 --> 08:26.830
So I'm going to refresh your memory on something we had to do to make this all work, because you may

08:26.830 --> 08:32.800
add this to another project, and it's not going to work unless you go into project settings and you

08:32.800 --> 08:39.580
search for custom depth, and you make sure that custom Depth stencil pass is enabled with stencil,

08:39.580 --> 08:42.850
not just enabled by default, it just says enabled.

08:42.850 --> 08:47.380
So you might check this and see enabled and think, well, we can use the custom depth stencil.

08:47.380 --> 08:54.160
Well we have to use custom Depth stencil pass, which means we need this enabled with stencil to use

08:54.160 --> 08:55.180
this feature.

08:55.180 --> 08:57.490
So make sure that that is set there.

08:57.490 --> 09:02.380
Otherwise you'll be very frustrated and not know why this isn't working for you.

09:03.030 --> 09:04.620
Okay, so this is great.

09:04.650 --> 09:08.190
Now I can leave this as tan.

09:08.190 --> 09:13.470
It doesn't matter because if I come back and hover over the enemy, it'll set this back to red.

09:13.950 --> 09:20.820
And in addition to that, if I unhighlight it sets that render custom depth pass boolean back to false.

09:20.820 --> 09:23.340
So we're not actually rendering it anymore.

09:23.490 --> 09:27.270
And this comes back to what we're doing when we cursor trace.

09:27.870 --> 09:33.240
Now I'd like to be able to cursor trace over multiple types of objects, not just enemies.

09:33.240 --> 09:36.120
And I'd like to be able to highlight multiple things.

09:36.450 --> 09:40.590
Now our highlight code is an interface function.

09:40.590 --> 09:44.040
We have an highlight and a Unhighlight interface function.

09:44.040 --> 09:49.800
And we put that in the combat interface because thus far we've only needed to highlight enemies.

09:49.800 --> 09:52.410
But now we need to highlight non enemies.

09:52.410 --> 09:59.040
And for that reason I'd like to make a new interface a highlight interface specific to highlighting

09:59.040 --> 10:03.180
that we can add to any actor and give it the ability to highlight.

10:03.180 --> 10:08.640
So for that reason, we're going to make a new interface and we're going to do that in the next video.

10:08.820 --> 10:09.900
I'll see you soon.
