Adding World Shader

10 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€95.85
List Price:  €134.19
You save:  €38.34
£79.54
List Price:  £111.35
You save:  £31.81
CA$143.73
List Price:  CA$201.23
You save:  CA$57.50
A$159.93
List Price:  A$223.91
You save:  A$63.97
S$135.54
List Price:  S$189.77
You save:  S$54.22
HK$777.83
List Price:  HK$1,089
You save:  HK$311.16
CHF 89.34
List Price:  CHF 125.09
You save:  CHF 35.74
NOK kr1,131.88
List Price:  NOK kr1,584.68
You save:  NOK kr452.80
DKK kr715.08
List Price:  DKK kr1,001.15
You save:  DKK kr286.06
NZ$176.75
List Price:  NZ$247.46
You save:  NZ$70.70
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,945.33
List Price:  ৳16,723.94
You save:  ৳4,778.61
₹8,493.77
List Price:  ₹11,891.62
You save:  ₹3,397.85
RM450.75
List Price:  RM631.07
You save:  RM180.32
₦154,938.50
List Price:  ₦216,920.10
You save:  ₦61,981.60
₨27,824.38
List Price:  ₨38,955.25
You save:  ₨11,130.86
฿3,419.79
List Price:  ฿4,787.84
You save:  ฿1,368.05
₺3,519.01
List Price:  ₺4,926.76
You save:  ₺1,407.74
B$608.53
List Price:  B$851.97
You save:  B$243.44
R1,830.80
List Price:  R2,563.19
You save:  R732.39
Лв187.32
List Price:  Лв262.25
You save:  Лв74.93
₩144,627.53
List Price:  ₩202,484.33
You save:  ₩57,856.80
₪365.39
List Price:  ₪511.57
You save:  ₪146.17
₱5,882.91
List Price:  ₱8,236.31
You save:  ₱2,353.40
¥15,643.93
List Price:  ¥21,902.13
You save:  ¥6,258.20
MX$2,007.58
List Price:  MX$2,810.70
You save:  MX$803.11
QR364.41
List Price:  QR510.19
You save:  QR145.78
P1,381.63
List Price:  P1,934.33
You save:  P552.70
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£5,087.81
List Price:  E£7,123.14
You save:  E£2,035.32
ብር12,764.56
List Price:  ብር17,870.89
You save:  ብር5,106.33
Kz91,790.82
List Price:  Kz128,510.82
You save:  Kz36,720
CLP$98,905.10
List Price:  CLP$138,471.10
You save:  CLP$39,566
CN¥729.56
List Price:  CN¥1,021.42
You save:  CN¥291.85
RD$6,087.13
List Price:  RD$8,522.23
You save:  RD$2,435.09
DA13,485.25
List Price:  DA18,879.89
You save:  DA5,394.64
FJ$231.62
List Price:  FJ$324.28
You save:  FJ$92.66
Q770.23
List Price:  Q1,078.35
You save:  Q308.12
GY$20,913.67
List Price:  GY$29,279.97
You save:  GY$8,366.30
ISK kr13,911.60
List Price:  ISK kr19,476.80
You save:  ISK kr5,565.20
DH1,006.07
List Price:  DH1,408.53
You save:  DH402.46
L1,836.70
List Price:  L2,571.46
You save:  L734.75
ден5,900.06
List Price:  ден8,260.33
You save:  ден2,360.26
MOP$800.26
List Price:  MOP$1,120.39
You save:  MOP$320.13
N$1,840.36
List Price:  N$2,576.58
You save:  N$736.22
C$3,678.42
List Price:  C$5,149.94
You save:  C$1,471.51
रु13,597.49
List Price:  रु19,037.04
You save:  रु5,439.54
S/372.23
List Price:  S/521.13
You save:  S/148.90
K405.36
List Price:  K567.52
You save:  K162.16
SAR375.62
List Price:  SAR525.88
You save:  SAR150.26
ZK2,766.46
List Price:  ZK3,873.15
You save:  ZK1,106.69
L477.10
List Price:  L667.96
You save:  L190.86
Kč2,408.98
List Price:  Kč3,372.68
You save:  Kč963.69
Ft39,689.03
List Price:  Ft55,566.23
You save:  Ft15,877.20
SEK kr1,103.13
List Price:  SEK kr1,544.43
You save:  SEK kr441.30
ARS$102,160.40
List Price:  ARS$143,028.65
You save:  ARS$40,868.24
Bs690.76
List Price:  Bs967.10
You save:  Bs276.33
COP$435,928.80
List Price:  COP$610,317.76
You save:  COP$174,388.96
₡50,434.81
List Price:  ₡70,610.75
You save:  ₡20,175.94
L2,537.51
List Price:  L3,552.62
You save:  L1,015.10
₲779,455.88
List Price:  ₲1,091,269.42
You save:  ₲311,813.53
$U4,474.38
List Price:  $U6,264.31
You save:  $U1,789.93
zł408.66
List Price:  zł572.14
You save:  zł163.48
Already have an account? Log In

Transcript

Okay, so let's stop polishing this game. So right now when we press play, you'll notice that the game is really really, really fast. That was a joke. It's really slow and boring. So first thing we want to do probably is speed up a player. I think it's at 500.

Let's try 1500. Press play. Oh, yeah, that feels a little bit more a little bit better. I'm actually feeling is some sort of a challenge. Cool. And because we liked that, let's open up the script and changed the default to 1500.

Just so it doesn't step up and instead run if we adjust something. Cool. So the next thing we want to do is right now we've got a pretty boring plain ground and we want to change that. So to do that, let's turn off our ground and let's turn off our water. Just for the time being, and let's drag in now, let's go to models and let's drag in our ground. Awesome.

Okay, so right now it's easy to slip behind. Let's just reduce that by negative point five. Well, that looks perfect. And let's call this just ground. Cool. And let's just see what that looks like.

We'll press play. Yep, things are looking tasty. So you can see the little edges here, make it look a little bit like you can tell your players moving a little bit better. And now we want to implement our shader. So our shader is what's going to make the world look warp. So what a shader does is it doesn't actually affect anything in the like, doesn't affect real world coordinates per se it more more tells the compiler how things are going to appear on the screen.

We aren't going to go into how shaders are coded in tutorial, because there are a lot more complex and not really a thing that beginners can really touch on. But it is something that you're really kicks up the look of your game to a whole new level. So luckily, we've got a shader script already here called curved world. So if we just First of all, go over to a model, click on that ground, open that up, you'll see we have three different textures that are already imported here. So let's click on that ground first, and we're going to say extract materials. And it's going to ask us where to extract these materials.

We want to choose the material folder, select that folder. Awesome. So it's extracted those materials. Let's go over to our materials. And we'll see we've got grass mat, sand mat and water mat. So we probably don't need these other ones grass, grass and water and delete them.

They're the old ones. So we got what a man's Sandman in grass map and right now they're using the shader standard. If we change this, we could change To talk that just looks horrible, I'm going to leave it as standard. And we're going to, what we're going to do is going to grab the water, we're gonna grab the brass material, and we're going to have the same material, I'm going to change them all to curved shader. Awesome. So if we press play now, nothing happens.

And the reason nothing happens is because we need to actually pass in some variables to the shader and say, Well, how much we want the shader to curve our actual world. So to do that, let's go over to our Scripts folder, I'm going to create a new script called app inish. She'll realize the script will handle things like like frame rates, and just like little settings that we may have. And so it's just common practice to call the app initialize. And let's just drag that straight away on to the scene manager. So scene manager has that script and let's open up that script.

So normally inside scripts, void star is the first first method that is called straightaway when the script loads, but there's actually a method that gets called right before start. So if you want something done before start, you can use void awake. So we'll be using that to void awake. So if you want something to happen before start, this is where you'd put it. Make sure it's capitalized and everything looks exactly like that. And then we just need to run shader dot set global float, progress parentheses, open speech marks, underscore, curvature.

Comma, and we're gonna start at 2.0 F. Awesome and the next laminate ride is shader dot set globe flight underscore Tring. 0.1 f. So these are settings that I've tested out that work the best, but feel free to adjust these numbers to adjust the look and the curvature of your game. You can also create a variables up here that you could then and you know like you could have curvature and trimming, you create these variables here and you can make them public. And then you could change that the variables to this to these numbers here. And then as we've done before, you can then adjust them inside of the editor and you'd see things adjust in real time when you're playing the game if you wanted to test out things, but I found these two numbers to work pretty good. So if we press play now you'll know Straight away, we'll get some crazy looking graphics ready, press play.

Okay, so first of all the world curves, which is what we want, and these don't curve. Okay? So first things first let's grab the camera and let's just drop the rotation down to about there. Don't worry, we'll fix up this ugliness up here in a second. So let's just drop it to say 24 whatever looks good on your game. And right now if I press play, I want to show you something that's pretty cool.

So this is the edge of the material. Okay, now I want to point out something. Hang on a sec. This doesn't look right. The further we go back, the further this rolls off and these the edge Here is actually at the level zero where players are at zero and this is on the ground. So it's at zero.

So what's actually going on here? Well, what's going on is, this is not actually moving. The verse is not actually moving the model and changing the models direction. It's just appearing that way where the shader is basically tricking the graphics to render it in a certain way, if that makes sense. If that's an easy way to understand it, it's it's adjusting how it appears on screen, even though it's not actually, we're not actually going over a hump. That makes sense not going around the world.

So what we can do that so what's happening here is there's a little bit of a problem though, because right now, these are hovering up in the air. And that doesn't really make sense. Well, actually, no does actually make sense. And the reason that makes sense is if we go into our materials will notice our triangle has the standard shader, and the standard shader isn't being affected by anything else. So if we just change the shader to code world, all of a sudden they plop right where they need to be. So if we unclick play and you'll see that things just the way they're supposed to be.

Now, our player is still at zero and all these items are still at the height of zero, but it appears as if they're not. That's the awesome power of shaders. So the last thing we want to do to make our game look a little bit better is we want to fix this ugly background. So what we can do in our materials is we can create a new material here create new material. And we're going to call this to the skybox and we're going to set this the skybox to a skybox or no to a mobile sorry, mobile skybox and we're going to set our z texture to our texture the skybox We're going to go to our main camera and we're going to add a skybox. And then we're going to just drag in our custom skybox.

And you'll see background is fixed up. Well it looks better anyway, but it's still not perfect. We need to adjust the offset a little bit. So if we just drag this up and down, you can just get something that you think looks good. Four, maybe 5665 that that looks good to me. 0.05 So now if we play the game, we have curved world and things look pretty cool.

Might need to adjust the camera a little bit. Just give us a little bit more room. So maybe 23 press play cool. So you can adjust things to your liking and you can muck around with some of the settings. You can even drag the camera and I'll see you in the next episode, where we will focus on, leave that as five. I'll see you in the next episode where we will focus on making the world Go.

Go forward infinitely. So I'll see you there.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.