To people considering following the unity3d master course by Jason: there have been a lot of 'meh' sponsors on these videos but Jason is actually a great teacher. Seriously. This is 100% my opininion and not some ad.
For anyone wondering how to layer perlin noise (octaves) here is what I did!: float y = amplitude1 * Mathf.PerlinNoise(x * frequency1,z * frequency1) + amplitude2 * Mathf.PerlinNoise(x * frequency2, z * frequency2) + amplitude3 * Mathf.PerlinNoise(x * frequency3, z * frequency3) * noiseStrength;
Man, Brackeys was the best teacher by far. Everytime: clear, concise, full of energy, but a magical ingredient whereby everything he said MADE SENSE. What an incredible teacher. I will miss him.
***SHADER SHORTCUT*** Always come back to Brackeys because his tutorials are really the best. Unfortunately the final steps with the render pipeline and shader graph are a bit outdated. Rather than switching out the pipeline I asked ChatGPT to generate a simple Vertex Color shader, posting it here for anyone that wants it. Just save it as a ".shader" file in your project, create a material with it, and attach it to the mesh renderer. Essentially skips 10:00-11:30 Shader "Custom/VertexColor" { Properties { } SubShader { Tags { "Queue"="Geometry" "RenderType"="Opaque" } LOD 100 CGPROGRAM #pragma surface surf Lambert vertex:vert addshadow struct Input { float4 vertexColor : COLOR; }; void vert (inout appdata_full v, out Input o) { o.vertexColor = v.color; } void surf (Input IN, inout SurfaceOutput o) { o.Albedo = IN.vertexColor.rgb; o.Alpha = IN.vertexColor.a; } ENDCG } FallBack "Diffuse" }
@@lucemiserlohn Fair question; I've written shaders from scratch in OpenGL (though that was years ago), so I have a fundamental understanding of how they work. Generally I can read Unity shaders but I have not put in the time to learn how to write them from scratch. This shader is very simple, and I've thoroughly tested it.
1) Sebastian Lague has a long and detailled tutorial Serie about terrain generation 2) it's really easy : make three variables, number of octaves, persistance and amplitude ; then make as many noises as there are octaves, with a decreasing size proportional to the persistence, and add them with a decreasing weight proportional to the amplitude.
If the C# documentation works the same way in Unity, then float is initialized as 0.0f. In this case, the min and max height values (at 8:20) shoud be set before being evaluated to avoid unwanted effects when the terrain is moved around. Maybe set to max and min float values, respectively, or set to the terrain position.
I love these videos. They simplify things and make them easier than they initially appear. And you explain it in such an understandable way. Keep up the fantastic work.
As life gets more complicated after graduating, it's just hard to get back to the phase where, I could just simply learn something on UA-cam and play with it for a few hours, without worrying too much. I miss this 😭
For anyone who is getting the pink color issue, an alternative method that works is changing the terrain materials shader to Particles/Standard Surface. This fixes the pink color and allows the gradient colors to work.
its not the best fix, if you go to window > rendering > render pipeline converter then you click convert buio;t om tp 2d urp to built in to urp instead then click the 2 check boxes that say rendering settings and material upgrade then click initialize converters finally click convert assets and voila it fixes all your urp materials
WARNING TO OTHERS: I spent hours with this tutorial not working. I am in the habit of using the menu option File and Save to save the whole project. My problem was that this does NOT save your shader graph object. So when you try and test the shader graph nothing works. You are stuck with a pink terrain or a plain gray terrain. All your work in shader graph has no affect. You need to specifically click on the "SAVE ASSET" button on the shader graph tab. I used the "Universal RP" package and then did "Create" -> "Shader" -> "Universal Render Pipeline" -> "Lit Shader Graph". There is no master anymore and so I used the "Fragment" node and the "Base Colour" input. But the result was TRULY DREADFUL. The first problem is that the lowest points in the mesh are glowing as though they are being hit by a lot of light instead of being hit by the least amount of light. Next my terrain now looks really flat. So looks WAY worse than it did as a plain grey model. It is really strange how flat the terrain now looks. The terrain looks like a basic flat quad with an image texture. You have to look really carefully to see that it does have height variation. So prior to the shader graph the terrain looks like a 3D model with no material and after applying the shader graph it looks like a really bad PS1 game. [The previous tutorials did not set up the camera or mesh positions so in the game window you can't actually see your mesh properly and it's hard to position the camera in design mode to correctly view something you haven't created yet. So the glowing low parts of the model may be a glitch from having the light source in the wrong position. Overall this series has a lot of missing info and out of date info. So best to just watch for concepts. I have wasted 2 days on this series and can't believe how bad the results look. As an additional warning your other models which did look great now DON'T DISPLAY in the Universal Render Pipeline! You have to manually change every material in your project to use the new render pipeline. However, I still haven't got this to work properly as my models now appear in the game again but as a single colored plain model. They are missing the correct colors for the clothes and shoes. Maybe you need to change to the Universal Render Pipeline before you start any work on your project so that your models are imported with the right settings.
I might of found the answer (you might need to change the noise stuff for it to look good) I downloaded the Universal RP and the Shader Graph packages, created a pipeline asset by going to Create -> Rendering -> Universal Rendering pipeline -> pipeline asset (forward render) and put it in Project Settings -> graphics. Then I did Create -> Shader -> Universal Render Pipeline -> blank shader graft. In the shader editor I went to graph settings -> active targets -> universal. Next I connected a vertex color node to base color and changed the terrain material's shader to TerrainMaterial by going to shader grafts -> TerrainMaterial. (Again you might need to change the noise stuff or my method is bad and I need to use a different tutorial)
it’d be cool if it was like the far cry 5 engine, you should take a look at the video of procedurally generated terrain in far cry video if you haven’t seen it. it’s slightly long but defiantly worth a watch, very interesting.
@North America I think you should use it for y (float y = CalculateNoise(x, z) instead of float y = Mathf.PerlinNoise(....) ); amp1...3 and scale1...3 can be set as member variables.
@@DilkielGaming using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(MeshFilter))] public class TerrainGenerator : MonoBehaviour { Mesh mesh; Vector3[] vertices; int[] triangles; public int xSize = 20; public int zSize = 20; // Start is called before the first frame update void Start() { mesh = new Mesh(); GetComponent().mesh = mesh; CreatShape(); UpdateMesh(); } void CreatShape () { vertices = new Vector3[(xSize + 1) * (zSize + 1)]; for (int i = 0, z = 0; z
Really cool series about generating meshs/terrain. I guess we can add rules like "no green (grass) on steep curves" via the TerrainShader, or the Material? Or do we have to compute this ourselves, taking the y values of neighbouring vertices to decide if the slope is too steep for green?
I know this was a whiiiiile ago but what you can do is use the normals. mesh.normal returns a Vector3[]. This vector represents a vector perpendicular to either the face or vertex (not sure which one). If you normalize one of these, you get a y component from -1 to 1. This is your slope.
To anyone having issues with the shader just being plain to pink try attaching the vertex color to the base color and then clicking the save asset button in the top left corner. Sorry if this doesn't help but it worked for me.
@@Tjoldar Yeah No problem I am using 2021.3.16f1 so hopefully, it works! I created my project using the 3D (URP) template. I followed the tutorial until the shader graph needed to be made. I then made a shader graph as Create>Shader Graph>URP>Lit Shader Graph I created a vertex color node in the shader graph and linked it to the base color. I clicked the save asset button in the top left corner of the shader graph window I changed the shader on my material to the new one I made by searching for the name of the shader and it worked with the gradient with multiple colors for me. Hopefully, this is helpful and can help this tutorial still be useful for you!
Thanks for your answer. It didnt work for me. But I have to assume, that I didnt do the exact project Brackey is suggesting. I tried to combine his code with Sebastian Lagues code in EP05 of his series for landmass creation -> ua-cam.com/video/4RpVBYW1r5M/v-deo.html Also my project isnt setup as a 3D URP project, so I may run into further issues. I will take a short break and continue with Sebastians code. Maybe I retutrn here later. Of course, if you have any further suggestions: My ears are open to listen.
@@Tjoldar I haven't personally done that Sebastian tutorial but the coloring should work with it assuming you are generating a mesh in some way. I'm pretty sure the URP will necessarily for the color to work with the shader graph but there is for sure another way to color a mesh. Hopefully this helps and good luck on your game development!
I followed this tutorial and it finally worked. I'm going to have to work out some issues with the transfer to my project, but I think I can manage it. I'll report back when I get it done 🙂
@@coolboidoesstuff9828 Here's an example I've found and worked off of before. Loop for every octave and incrementally apply a decaying amount of perlin noise to the value. float total = 0; float frequency = 1; float amplitude = 1; float maxValue = 0; // Used for normalizing result to 0.0 - 1.0 for (int i = 0; i < octaves; i++) { total += Mathf.PerlinNoise(x * frequency, y * frequency) * amplitude; maxValue += amplitude; amplitude *= persistence; frequency *= 2; } return total / maxValue;
I downloaded and imported the pipeline renderer but I don't get the option he does at 10:12 to create a new pipeline renderer I only get universal render pipeline, and it doesn't work
He's been doing that with the 2d platformer, but it doesn't involve much coding. It just consists of him using a lot of different assets and dragging and dropping various things in the editor.
I don't think he's ever really going to go back to that format again. He talked a little bit about it on an interview on the game dev unchained podcast. IIRC it's just going to be specific topics that are around 10-20 minute mostly standalone videos now because each series is a ton a work and don't tend to get watched a huge amount past the first 2-3 videos and he was kinda going insane with crazy work hours without much to show for it
Just a note on the cool optical optical illusion in this vid (yep, I'm off topic, couldn't help myself). Stare at the blue terrain on the red background starting at about 9:30. Keep staring until he clears it from the screen...what color square do you see? I see a light brown square on a dark turquoise background. Pretty cool. Ok, carry on!
while the flat color vertex color is pretty useful on it's own, how would you go about applying textures based on the angle of the normal? like how some games have grass where you can walk, but anything at a steeper angle than that would show a rock texture. then with a combo of the normal angle and the vert height you blend them together to get a cool textured variant of what you had. but it's something like4+ textures deep.
Great video! Could you extend on this further and go through how to change terrain color based on steepness/slope? Would be cool to use green for flatter landscape and gray for steeper cliffs for example.
pick a triangle and get the height and remove from the one adjacent and set material for how much difference there is triangle1 = 0.3 height triangle2 = 0.5 height 0.5 - 0.3 = 0.2 set material to 0.2 steepness
Would be nice to extend this in another tutorial where you combine multiple textures like sand/grass/rock/snow and blend them via shader graph settings.
For easy maps, you could probably use a black and white gradient. Then you could use a function which gives every texture a value on the gradient. If that value is reached or very close, it will blend in the texture.
Awesome video Can you make a video or a playlist about best practices coding for performance improvement? such as how to avoid using update function to update high score and avoid using string as much as possible, since strings produce unnecessary garbage, heap allocation
Very cool, please continue this topic! Can we made more complex generator? For example with spawning monsters or NPC vilages and other stuff. Good luck, wait for a New videos! :)
I've looked and looked over this code mulitpule times and can't find a missing "," can someone help me find it. I got till 9:30 before i got stuck and stopped but everything else works just cant find the missing "," using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(MeshFilter))] public class MeshGenerator : MonoBehaviour { Mesh mesh; Vector3[] vertices; int[] triangles; Color[] colors; public int xSize = 20; public int zSize = 20; public int textureWidth = 1024; public int textureHeight = 1024; public float noise01Scale = 2f; public float noise01Amp = 2f; public float noise02Scale = 4f; public float noise02Amp = 4f; public float noise03Scale = 6f; public float noise03Amp = 6f; public Gradient gradient; float minTerrainHeight; float maxTerrainHeight; // Start is called before the first frame update void Start () { mesh = new Mesh(); GetComponent().mesh = mesh; } private void Update() { CreateShape(); UpdateMesh(); } // Update is called once per frame void CreateShape () { vertices = new Vector3[(xSize + 1) * (zSize + 1)]; for (int i = 0, z = 0; z
How challenging would it be to have it create vertex colours based upon the angle of the terrain too? So you could give a colour to the cliffs. Then could you connect these vertex colours to different textures. Like a tileable grass. Dirt etc? This is a mesh right now. But could it be turned into a terrain so you could paint trees on it?
You are one of the reasons I am able to keep motivated to learn to code and make my own games, but if Im not wrong, I think article 13 may stop me from watching your content in the future, I hope not. Anyways, I'd like to hear your opinion on the topic :)
I used Simplex Noise, but this is how you do it: //Calculate height for wide and high point in Noise float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50; //Calculate height for short and low point in Noise and add it on top of previous height y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
A tutorial for having multiple materials (or at least textures), best per vertex, for our own objects, that would help a lot more than just plain color! Thanks!
He is not doing tutorials anymore. Check out Sebastian Lague here on youtube for this. He has a playlist in which one of his videos is handleing this subject.
I used Simplex Noise, but this is how you do it: //Calculate height for wide and high point in Noise float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50; //Calculate height for short and low point in Noise and add it on top of previous height y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
Hey Brackey, Thank you for sharing awesome videos, Its fun to watch and learn!! But I'm a newbie to this so can you please share the code between line no. 102 and 119... That would be a great help. Thanks!
Hi, love you videos, lots of good info, but also fun and exciting to watch. can you make a video on "how to make a path predictor, like the BallPoll games. Draw a path that bouces off obstacles and shows where the ball is going to end up." much appreciated. thank you.
I used Simplex Noise, but this is how you do it: //Calculate height for wide and high point in Noise float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50; //Calculate height for short and low point in Noise and add it on top of previous height y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
Hey Brackeys Is it possible to do the vertex colours on a planet/sphere like object? So instead of a world height it uses the height from the centre of mass towards the surface of the sphere.
Hey Brackeys, just wondering if it would be possible to do this using the Lerp function in order to interpolate between the min and max values of your terrain height. Love the videos!
June 2022 - these courses simply do not work anymore. unity keeps on changing things around, renaming things, adding things and getting rid of things. brackeys was brilliant where he would cover new features all the time. however, as i said, unity keeps changing things. i tried to follow this but near the end things have simply changed SO MUCH. gradient simply does not work. that or i am doing it. if anyone can help me please please do.
Sensei alright then. Kinda disappointing tbh. Putting terrain in the title led me to expect some terrain system features and all that good stuff. But apparently not
What if I want a discontinuous texture? How do I avoid the problem of my UVs not aligning correctly? Do I need to duplicate points in the mesh or make multiple meshes? What if I want the side of an object to have absolutely no relationship with the top of that object?
last video i just recall making the simple first terrain draw... how the heck we do more layers on it? just pass another loop and instead of vertices = values, we use vertice += values?!
Really great video! Does anybody know how to color the mesh like the thumbnail? Only the edges of the squares? And also how to make this a continuously generated procedural mesh based on the player's position?
Hey Brackeys, Great video. Also, could you make a second channel were you make longer tutorials (like the FPS multiplayer, tower defense tutorial, etc), one game I really want to see you make is ball wars in a series, because it would seem like a really fun game to make. once again, loved the video.
Coloring anything through vertices is absolutely unsuitable for games - because the resolution depends on the mesh, it will be soapy and undetailed. On the other hand using a shader graph gives huge processing possibilities.
On my computer, I had to set the Occulusion setting in the shader to 5. Without doing so, the gradient colors were dark and I had to move far away from the mesh before it would light up.
Is 'uvs' a special keyword or something? I'm a little confused how the mesh generator recognises our array of Vector2 positons as information relevant to using the image supplied to the albedo field.
To people considering following the unity3d master course by Jason: there have been a lot of 'meh' sponsors on these videos but Jason is actually a great teacher. Seriously. This is 100% my opininion and not some ad.
Well, thanks for the advice! I'll check it out
Maybe you are getting paid for saying that :p
adception
Yeah probably is a very very good course, BBUUUTTT a fuck ton of money.
How much does it cost? unity3d.courses doesn't work
For anyone wondering how to layer perlin noise (octaves) here is what I did!:
float y =
amplitude1 * Mathf.PerlinNoise(x * frequency1,z * frequency1)
+ amplitude2 * Mathf.PerlinNoise(x * frequency2, z * frequency2)
+ amplitude3 * Mathf.PerlinNoise(x * frequency3, z * frequency3)
* noiseStrength;
could you give the whole script?
aaush1977 I would recommend that you Follow brackeys tutorial and then just add my script about octaves right in! GL
Jompan thanks! It actually worked.
aaush1977 Good!!! Glad that I could help!:)
Jompan i can’t get the extreme hills to work tho :(
Man, Brackeys was the best teacher by far. Everytime: clear, concise, full of energy, but a magical ingredient whereby everything he said MADE SENSE. What an incredible teacher. I will miss him.
***SHADER SHORTCUT*** Always come back to Brackeys because his tutorials are really the best. Unfortunately the final steps with the render pipeline and shader graph are a bit outdated. Rather than switching out the pipeline I asked ChatGPT to generate a simple Vertex Color shader, posting it here for anyone that wants it. Just save it as a ".shader" file in your project, create a material with it, and attach it to the mesh renderer. Essentially skips 10:00-11:30
Shader "Custom/VertexColor" {
Properties {
}
SubShader {
Tags { "Queue"="Geometry" "RenderType"="Opaque" }
LOD 100
CGPROGRAM
#pragma surface surf Lambert vertex:vert addshadow
struct Input {
float4 vertexColor : COLOR;
};
void vert (inout appdata_full v, out Input o) {
o.vertexColor = v.color;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = IN.vertexColor.rgb;
o.Alpha = IN.vertexColor.a;
}
ENDCG
}
FallBack "Diffuse"
}
And do you understand what the thing ChatGPT spat out for you does? Have you written a version of that by hand before?
@@lucemiserlohn Fair question; I've written shaders from scratch in OpenGL (though that was years ago), so I have a fundamental understanding of how they work. Generally I can read Unity shaders but I have not put in the time to learn how to write them from scratch. This shader is very simple, and I've thoroughly tested it.
Thank you, this code works perfect for me. I was stuck in this part.
Pls make a tutorial about octaves! it will be amazing :)
Watch Sebastian Lagues videos. They are easy to follow and really instructive
1) Sebastian Lague has a long and detailled tutorial Serie about terrain generation
2) it's really easy : make three variables, number of octaves, persistance and amplitude ; then make as many noises as there are octaves, with a decreasing size proportional to the persistence, and add them with a decreasing weight proportional to the amplitude.
@@asdfer1234 But how?
@@asdfer1234 So you basically just copy/paste the code that generates the arrays and gives them different heights?
@@asdfer1234 Ok, that makes sense, thank you.
If the C# documentation works the same way in Unity, then float is initialized as 0.0f.
In this case, the min and max height values (at 8:20) shoud be set before being evaluated to avoid unwanted effects when the terrain is moved around.
Maybe set to max and min float values, respectively, or set to the terrain position.
You beat me to it (by three years)!
I love these videos. They simplify things and make them easier than they initially appear. And you explain it in such an understandable way. Keep up the fantastic work.
A follow up video about doing the same but with blended textures depending on height would be amazing.
I've been waiting two weeks for this!
As life gets more complicated after graduating, it's just hard to get back to the phase where, I could just simply learn something on UA-cam and play with it for a few hours, without worrying too much.
I miss this 😭
For anyone who is getting the pink color issue, an alternative method that works is changing the terrain materials shader to Particles/Standard Surface.
This fixes the pink color and allows the gradient colors to work.
THANK YOU. I hope this shader won't cause me any future issues. You are a godsend man, I appreciate it
its not the best fix, if you go to window > rendering > render pipeline converter then you click convert buio;t om tp 2d urp to built in to urp instead then click the 2 check boxes that say rendering settings and material upgrade then click initialize converters finally click convert assets and voila it fixes all your urp materials
WARNING TO OTHERS: I spent hours with this tutorial not working. I am in the habit of using the menu option File and Save to save the whole project. My problem was that this does NOT save your shader graph object. So when you try and test the shader graph nothing works. You are stuck with a pink terrain or a plain gray terrain. All your work in shader graph has no affect. You need to specifically click on the "SAVE ASSET" button on the shader graph tab. I used the "Universal RP" package and then did "Create" -> "Shader" -> "Universal Render Pipeline" -> "Lit Shader Graph". There is no master anymore and so I used the "Fragment" node and the "Base Colour" input. But the result was TRULY DREADFUL. The first problem is that the lowest points in the mesh are glowing as though they are being hit by a lot of light instead of being hit by the least amount of light. Next my terrain now looks really flat. So looks WAY worse than it did as a plain grey model. It is really strange how flat the terrain now looks. The terrain looks like a basic flat quad with an image texture. You have to look really carefully to see that it does have height variation. So prior to the shader graph the terrain looks like a 3D model with no material and after applying the shader graph it looks like a really bad PS1 game. [The previous tutorials did not set up the camera or mesh positions so in the game window you can't actually see your mesh properly and it's hard to position the camera in design mode to correctly view something you haven't created yet. So the glowing low parts of the model may be a glitch from having the light source in the wrong position. Overall this series has a lot of missing info and out of date info. So best to just watch for concepts. I have wasted 2 days on this series and can't believe how bad the results look. As an additional warning your other models which did look great now DON'T DISPLAY in the Universal Render Pipeline! You have to manually change every material in your project to use the new render pipeline. However, I still haven't got this to work properly as my models now appear in the game again but as a single colored plain model. They are missing the correct colors for the clothes and shoes. Maybe you need to change to the Universal Render Pipeline before you start any work on your project so that your models are imported with the right settings.
I might of found the answer (you might need to change the noise stuff for it to look good)
I downloaded the Universal RP and the Shader Graph packages, created a pipeline asset by going to Create -> Rendering -> Universal Rendering pipeline -> pipeline asset (forward render) and put it in Project Settings -> graphics. Then I did Create -> Shader -> Universal Render Pipeline -> blank shader graft. In the shader editor I went to graph settings -> active targets -> universal. Next I connected a vertex color node to base color and changed the terrain material's shader to TerrainMaterial by going to shader grafts -> TerrainMaterial. (Again you might need to change the noise stuff or my method is bad and I need to use a different tutorial)
This is the most helpful comment in existance.
And u also spent hours to write this comment 😂😂😂
im not reading all that
Could you make a tutorial on procedurally adding terrain textures?
it’d be cool if it was like the far cry 5 engine, you should take a look at the video of procedurally generated terrain in far cry video if you haven’t seen it.
it’s slightly long but defiantly worth a watch, very interesting.
@@nuclearapples1412 Sweet, thx!
@@nuclearapples1412 Could you provide the link please? I'd love to check it out
Cinabutts yeah of course, ua-cam.com/video/NfizT369g60/v-deo.html
Can you make a tutorial how to create a realistic movement animation pls
for multi noise do this
private float CalculateNoise(float x, float z)
{
float noise;
noise = Mathf.PerlinNoise(x, z) * 5;
noise += Mathf.PerlinNoise(x * amp1, z * amp1) * scale1;
noise -= Mathf.PerlinNoise(x * amp2, z * amp2) * scale2;
noise += Mathf.PerlinNoise(x * amp3, z * amp3) * scale3 * 2;
return noise;
}
@North America I think you should use it for y (float y = CalculateNoise(x, z) instead of float y = Mathf.PerlinNoise(....) ); amp1...3 and scale1...3 can be set as member variables.
you are a godsend. thank you
i just get errors when i put it into my code.....is there like more that i have to add to it or is the code outdated or what???
@@IamJaieCarter paste your code here ill take a look
@@DilkielGaming using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
public class TerrainGenerator : MonoBehaviour
{
Mesh mesh;
Vector3[] vertices;
int[] triangles;
public int xSize = 20;
public int zSize = 20;
// Start is called before the first frame update
void Start()
{
mesh = new Mesh();
GetComponent().mesh = mesh;
CreatShape();
UpdateMesh();
}
void CreatShape ()
{
vertices = new Vector3[(xSize + 1) * (zSize + 1)];
for (int i = 0, z = 0; z
you're awesome ! each time i need a tutorial, you have the right one, at the best speech speed !!! please keep posting free vids !
Octaves tutorial or source code please!
if brackeys would have just shows how he did the layering of octaves , 6 hrs of my life would have been saved.
The only youtube where i am not annoyed when i listen to the sponsor at the beggining
Big thanks for this Shadergraph install tutorial!
This is so cool. I don'tr understand why some people are dislike this :(
just wanna say I really enjoy your videos BRACKEYS
Great video brackeys! as usual! best unity youtube channel ever!
Thank u for all these amazing tutorials!!
Really cool series about generating meshs/terrain.
I guess we can add rules like "no green (grass) on steep curves" via the TerrainShader, or the Material? Or do we have to compute this ourselves, taking the y values of neighbouring vertices to decide if the slope is too steep for green?
I know this was a whiiiiile ago but what you can do is use the normals. mesh.normal returns a Vector3[]. This vector represents a vector perpendicular to either the face or vertex (not sure which one). If you normalize one of these, you get a y component from -1 to 1. This is your slope.
To anyone having issues with the shader just being plain to pink try attaching the vertex color to the base color and then clicking the save asset button in the top left corner. Sorry if this doesn't help but it worked for me.
Could you explain what you did in a more detailed way? It doesnt work for me at all with Unity 2021.3.15f1
@@Tjoldar Yeah No problem I am using 2021.3.16f1 so hopefully, it works!
I created my project using the 3D (URP) template.
I followed the tutorial until the shader graph needed to be made.
I then made a shader graph as Create>Shader Graph>URP>Lit Shader Graph
I created a vertex color node in the shader graph and linked it to the base color.
I clicked the save asset button in the top left corner of the shader graph window
I changed the shader on my material to the new one I made by searching for the name of the shader and it worked with the gradient with multiple colors for me.
Hopefully, this is helpful and can help this tutorial still be useful for you!
Thanks for your answer. It didnt work for me. But I have to assume, that I didnt do the exact project Brackey is suggesting. I tried to combine his code with Sebastian Lagues code in EP05 of his series for landmass creation -> ua-cam.com/video/4RpVBYW1r5M/v-deo.html Also my project isnt setup as a 3D URP project, so I may run into further issues. I will take a short break and continue with Sebastians code. Maybe I retutrn here later. Of course, if you have any further suggestions: My ears are open to listen.
@@Tjoldar I haven't personally done that Sebastian tutorial but the coloring should work with it assuming you are generating a mesh in some way. I'm pretty sure the URP will necessarily for the color to work with the shader graph but there is for sure another way to color a mesh. Hopefully this helps and good luck on your game development!
I followed this tutorial and it finally worked. I'm going to have to work out some issues with the transfer to my project, but I think I can manage it. I'll report back when I get it done 🙂
Pls tell us how to do the octaves, I can’t find much online.
It's basically adding another noise with a different scale and height multipler.
@@DitzelGames But how do you implement the other value?
@@coolboidoesstuff9828
Here's an example I've found and worked off of before. Loop for every octave and incrementally apply a decaying amount of perlin noise to the value.
float total = 0;
float frequency = 1;
float amplitude = 1;
float maxValue = 0; // Used for normalizing result to 0.0 - 1.0
for (int i = 0; i < octaves; i++)
{
total += Mathf.PerlinNoise(x * frequency, y * frequency) * amplitude;
maxValue += amplitude;
amplitude *= persistence;
frequency *= 2;
}
return total / maxValue;
@@Bluequaz thanks so much but i am working on 2d unity now lol
@@coolboidoesstuff9828 sounds good lol figured I'd reply just in case and I figure others will come to the comment section with the same question
I downloaded and imported the pipeline renderer but I don't get the option he does at 10:12 to create a new pipeline renderer I only get universal render pipeline, and it doesn't work
Awesome content as usual. Brackeys never ceases to Impress
You should do another series on how to make a basic game.
God he has a million of all
Vlad Chira but updated using all the new stuff and stuff he hasn’t touched on.
He's been doing that with the 2d platformer, but it doesn't involve much coding. It just consists of him using a lot of different assets and dragging and dropping various things in the editor.
I don't think he's ever really going to go back to that format again. He talked a little bit about it on an interview on the game dev unchained podcast.
IIRC it's just going to be specific topics that are around 10-20 minute mostly standalone videos now because each series is a ton a work and don't tend to get watched a huge amount past the first 2-3 videos and he was kinda going insane with crazy work hours without much to show for it
... including the new workflow that Unity added - with ECS and nested Prefabs
Your hand game is on point today 👐
What about 3D Perlin Noise ? It's so interesting to make more complicated maps with voxels
unity doesnt have 3d perlin noise, if u want 3d perlin noise ur gonna have to write it yourself or code the in unity perlin noise so its 3d
I have no idea of this topic but I´m glad to watch it :)
YES PLEASE MAKE A VID ON OCTAVES!
Terrain tools is a free plug that allows doing this with materials on a traditional terrain object, really handy.
Or on the marching cubes algorithm, and 3D perlin noise? That would be AMAZING.
Just a note on the cool optical optical illusion in this vid (yep, I'm off topic, couldn't help myself). Stare at the blue terrain on the red background starting at about 9:30. Keep staring until he clears it from the screen...what color square do you see? I see a light brown square on a dark turquoise background. Pretty cool. Ok, carry on!
This is not in tomorrow's test but fuck it, i learned how to do terrain generation today and i don't regret it.
That's exactly what I was searching for. Thank you
It would be amazing if you could make a video on octaves.
Great video again. Thank you. Can’t wait for more
Make a video about octaves!
Holy smokes, these are so interesting, I want another video on these topics
Awsome that you continued this :D
while the flat color vertex color is pretty useful on it's own, how would you go about applying textures based on the angle of the normal? like how some games have grass where you can walk, but anything at a steeper angle than that would show a rock texture. then with a combo of the normal angle and the vert height you blend them together to get a cool textured variant of what you had. but it's something like4+ textures deep.
Definitely gonna bookmark this one!
Great video! Could you extend on this further and go through how to change terrain color based on steepness/slope? Would be cool to use green for flatter landscape and gray for steeper cliffs for example.
pick a triangle and get the height and remove from the one adjacent and set material for how much difference there is
triangle1 = 0.3 height
triangle2 = 0.5 height
0.5 - 0.3 = 0.2
set material to 0.2 steepness
Could you Share file for this Tutorial ? or do video about Octaves ? Tutorial by Sebastian Lague
was not clear for me.
thanks a lot
Would be nice to extend this in another tutorial where you combine multiple textures like sand/grass/rock/snow and blend them via shader graph settings.
For easy maps, you could probably use a black and white gradient.
Then you could use a function which gives every texture a value on the gradient.
If that value is reached or very close, it will blend in the texture.
props i didn't know about gradients
Awesome video
Can you make a video or a playlist about best practices coding for performance improvement? such as how to avoid using update function to update high score and avoid using string as much as possible, since strings produce unnecessary garbage, heap allocation
Thank you! I have been wondering how to do this for so long!
Octaves would be an epic video!!
Please do a video on animating the mesh, like a sin wave altering the height values!
fantastic tutorial, learnt so much thank you
Next video => Terrain texture by terrain height
check out Sebastian Lague's terrain generation series!
This is absolutely amazing
Very cool, please continue this topic! Can we made more complex generator? For example with spawning monsters or NPC vilages and other stuff. Good luck, wait for a New videos! :)
Yes finally a new video
This is awesome 😎 Thank you so much !
Can you do some future videos showing off a game and then going over the code? I wouldn't mind if you have already made them.
what is the method " float GetNoiseSample(int x,int z)" please
same i want to know
It pinpoints a value on a 2d perlin noise map at x and z and returns a float which contains a number between 0 and 1.
I've looked and looked over this code mulitpule times and can't find a missing "," can someone help me find it. I got till 9:30 before i got stuck and stopped but everything else works just cant find the missing ","
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
public class MeshGenerator : MonoBehaviour
{
Mesh mesh;
Vector3[] vertices;
int[] triangles;
Color[] colors;
public int xSize = 20;
public int zSize = 20;
public int textureWidth = 1024;
public int textureHeight = 1024;
public float noise01Scale = 2f;
public float noise01Amp = 2f;
public float noise02Scale = 4f;
public float noise02Amp = 4f;
public float noise03Scale = 6f;
public float noise03Amp = 6f;
public Gradient gradient;
float minTerrainHeight;
float maxTerrainHeight;
// Start is called before the first frame update
void Start ()
{
mesh = new Mesh();
GetComponent().mesh = mesh;
}
private void Update()
{
CreateShape();
UpdateMesh();
}
// Update is called once per frame
void CreateShape ()
{
vertices = new Vector3[(xSize + 1) * (zSize + 1)];
for (int i = 0, z = 0; z
How challenging would it be to have it create vertex colours based upon the angle of the terrain too? So you could give a colour to the cliffs. Then could you connect these vertex colours to different textures. Like a tileable grass. Dirt etc? This is a mesh right now. But could it be turned into a terrain so you could paint trees on it?
You are one of the reasons I am able to keep motivated to learn to code and make my own games, but if Im not wrong, I think article 13 may stop me from watching your content in the future, I hope not. Anyways, I'd like to hear your opinion on the topic :)
need help with octaves and how to apply multiple different textures
check out Sebastian Lague's terrain generation series!
I used Simplex Noise, but this is how you do it:
//Calculate height for wide and high point in Noise
float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50;
//Calculate height for short and low point in Noise and add it on top of previous height
y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
"Gradient" could lead to a lot of confusion, between the Unity color thing and the mathematical concept which Perlin noise in based on.
I would love to learn about octaves
I dont have the pbr Graph i import all things but its not in there
A tutorial for having multiple materials (or at least textures), best per vertex, for our own objects, that would help a lot more than just plain color! Thanks!
He is not doing tutorials anymore. Check out Sebastian Lague here on youtube for this. He has a playlist in which one of his videos is handleing this subject.
To do that you can Lerp between two texture based on some height values. should do the trick.
Will you ever cover compute shaders?
New video from the Danish king :)
How did you do the layering of the noise. What did you do inside of the function?
I used Simplex Noise, but this is how you do it:
//Calculate height for wide and high point in Noise
float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50;
//Calculate height for short and low point in Noise and add it on top of previous height
y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
I followed this exactly, but my terrain is coming up black?
Hey Brackey, Thank you for sharing awesome videos, Its fun to watch and learn!!
But I'm a newbie to this so can you please share the code between line no. 102 and 119... That would be a great help. Thanks!
Anyone know how to do this in Unity 2020? LWPR is no longer a thing, and I just get everything to be the base colour of my material
its URP now not LWPR sorry im a year late i hope you found out already or on a new project
Hi,
love you videos, lots of good info, but also fun and exciting to watch.
can you make a video on "how to make a path predictor, like the BallPoll games. Draw a path that bouces off obstacles and shows where the ball is going to end up."
much appreciated.
thank you.
man after 3 years, no likes and no replies
@@codyfabulousyt4920 4 years now
Please create something like a Terrain Grid System for Highlighted Territory Borders in an RTS Game. I wanna learn more about that!
I can't seem to find the video where he talks about adding layers of noise to the terrain? can someone reply and send the link if they find it please?
I used Simplex Noise, but this is how you do it:
//Calculate height for wide and high point in Noise
float y = SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.05f) / 50;
//Calculate height for short and low point in Noise and add it on top of previous height
y += SimplexNoise.SimplexNoise.CalcPixel2D(x, z, 0.5f) / 1000 * y;
Hey Brackeys
Is it possible to do the vertex colours on a planet/sphere like object? So instead of a world height it uses the height from the centre of mass towards the surface of the sphere.
always like the video before watching.
Hey Brackeys, just wondering if it would be possible to do this using the Lerp function in order to interpolate between the min and max values of your terrain height. Love the videos!
I hope that Unity's Gradient System as versatile as Unity's Particle System.
June 2022 - these courses simply do not work anymore. unity keeps on changing things around, renaming things, adding things and getting rid of things. brackeys was brilliant where he would cover new features all the time. however, as i said, unity keeps changing things. i tried to follow this but near the end things have simply changed SO MUCH. gradient simply does not work. that or i am doing it. if anyone can help me please please do.
But is this now using the new terrain system? Or is it just a subdivided plane mesh whose vertices are offsettes?
It's a self-generated mesh
Sensei alright then.
Kinda disappointing tbh. Putting terrain in the title led me to expect some terrain system features and all that good stuff. But apparently not
What if I want a discontinuous texture? How do I avoid the problem of my UVs not aligning correctly? Do I need to duplicate points in the mesh or make multiple meshes? What if I want the side of an object to have absolutely no relationship with the top of that object?
First! It was a Private video when I opened it. :D He posted the tweet first, and then he made the video public. :P
Hi, Ferret!
@@insideman7501 Ohh, hey! :)
Good to see you around here Ferret.
@@masondotnet Good to see you too! I always wait for Brackeys Sunday night video before calling it a night.
last video i just recall making the simple first terrain draw... how the heck we do more layers on it? just pass another loop and instead of vertices = values, we use vertice += values?!
Really great video! Does anybody know how to color the mesh like the thumbnail? Only the edges of the squares? And also how to make this a continuously generated procedural mesh based on the player's position?
make a test if the player moves to a new area and then move the meshgen to the player. then re-run the generation script and repeat the check
dont know exact code but
Hey, i'm using the version 2018.3.9f1 personal and there is no lightweight render , anybody can help me what should i do?
there is a small button named: "Advanced" click it and enable: "Show preview Packages", than you can just search for "Lightweight RP" :)
Hey Brackeys, Great video.
Also, could you make a second channel were you make longer tutorials (like the FPS multiplayer, tower defense tutorial, etc), one game I really want to see you make is ball wars in a series, because it would seem like a really fun game to make. once again, loved the video.
Super! More videos like that!
This look AMAZING
Coloring anything through vertices is absolutely unsuitable for games - because the resolution depends on the mesh, it will be soapy and undetailed.
On the other hand using a shader graph gives huge processing possibilities.
Could u do it with textures the next video? Love ur vids!
I can't find the lightweight pipeline, I did exactly what he said, but it's not there, in my package manager! Can someone help me?
Great video. can you please do a video on how to create background like the stack mobile game
On my computer, I had to set the Occulusion setting in the shader to 5. Without doing so, the gradient colors were dark and I had to move far away from the mesh before it would light up.
Is 'uvs' a special keyword or something? I'm a little confused how the mesh generator recognises our array of Vector2 positons as information relevant to using the image supplied to the albedo field.
Can we build a random terrain?
I mean it should be like a new terrain every time we load the scene or play the game.
I missed some video? there are changes from the second to this