MESH COLOR in Unity - Terrain Generation

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 369

  • @beaujanssen6243
    @beaujanssen6243 6 років тому +162

    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.

    • @RegahP
      @RegahP 6 років тому +8

      Well, thanks for the advice! I'll check it out

    • @galaxylps4287
      @galaxylps4287 6 років тому +6

      Maybe you are getting paid for saying that :p

    • @RegahP
      @RegahP 6 років тому +3

      adception

    • @Cinabutts
      @Cinabutts 6 років тому +11

      Yeah probably is a very very good course, BBUUUTTT a fuck ton of money.

    • @kira7683
      @kira7683 6 років тому

      How much does it cost? unity3d.courses doesn't work

  • @jompan7612
    @jompan7612 4 роки тому +27

    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;

    • @aaush_
      @aaush_ 4 роки тому +1

      could you give the whole script?

    • @jompan7612
      @jompan7612 4 роки тому +2

      aaush1977 I would recommend that you Follow brackeys tutorial and then just add my script about octaves right in! GL

    • @aaush_
      @aaush_ 4 роки тому +1

      Jompan thanks! It actually worked.

    • @jompan7612
      @jompan7612 4 роки тому +1

      aaush1977 Good!!! Glad that I could help!:)

    • @aaush_
      @aaush_ 4 роки тому +1

      Jompan i can’t get the extreme hills to work tho :(

  • @alyssafaden9443
    @alyssafaden9443 2 роки тому +7

    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.

  • @rabidbeavergames
    @rabidbeavergames Рік тому +10

    ***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
      @lucemiserlohn Рік тому

      And do you understand what the thing ChatGPT spat out for you does? Have you written a version of that by hand before?

    • @rabidbeavergames
      @rabidbeavergames Рік тому

      @@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.

    • @EPaganix
      @EPaganix Рік тому

      Thank you, this code works perfect for me. I was stuck in this part.

  • @daydrim1694
    @daydrim1694 6 років тому +129

    Pls make a tutorial about octaves! it will be amazing :)

    • @blaccy5991
      @blaccy5991 4 роки тому +10

      Watch Sebastian Lagues videos. They are easy to follow and really instructive

    • @moimoi9995
      @moimoi9995 3 роки тому +3

      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.

    • @advancex_87
      @advancex_87 3 роки тому

      @@asdfer1234 But how?

    • @advancex_87
      @advancex_87 3 роки тому

      @@asdfer1234 So you basically just copy/paste the code that generates the arrays and gives them different heights?

    • @advancex_87
      @advancex_87 3 роки тому

      @@asdfer1234 Ok, that makes sense, thank you.

  • @WagnerGFX
    @WagnerGFX 6 років тому +2

    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.

    • @PaulJonesy
      @PaulJonesy 3 роки тому

      You beat me to it (by three years)!

  • @_MrMen_
    @_MrMen_ 6 років тому +4

    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.

  • @stm91
    @stm91 6 років тому +13

    A follow up video about doing the same but with blended textures depending on height would be amazing.

  • @insideman7501
    @insideman7501 6 років тому +8

    I've been waiting two weeks for this!

  • @edwardraymondhe4445
    @edwardraymondhe4445 Рік тому +3

    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 😭

  • @jarred_tye
    @jarred_tye 3 роки тому +4

    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.

    • @microman502
      @microman502 3 роки тому +1

      THANK YOU. I hope this shader won't cause me any future issues. You are a godsend man, I appreciate it

    • @SpaceKebab
      @SpaceKebab 2 роки тому +1

      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

  • @cargorunnerUK
    @cargorunnerUK 3 роки тому +28

    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.

    • @goodusername4901
      @goodusername4901 3 роки тому +6

      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)

    • @The.Adaptoid404
      @The.Adaptoid404 Рік тому +3

      This is the most helpful comment in existance.

    • @Gamoplane
      @Gamoplane Рік тому +2

      And u also spent hours to write this comment 😂😂😂

    • @TRR523
      @TRR523 8 місяців тому +1

      im not reading all that

  • @claydixon223
    @claydixon223 6 років тому +32

    Could you make a tutorial on procedurally adding terrain textures?

    • @nuclearapples1412
      @nuclearapples1412 6 років тому +2

      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.

    • @claydixon223
      @claydixon223 6 років тому +1

      @@nuclearapples1412 Sweet, thx!

    • @Cinabutts
      @Cinabutts 6 років тому +1

      @@nuclearapples1412 Could you provide the link please? I'd love to check it out

    • @nuclearapples1412
      @nuclearapples1412 6 років тому +1

      Cinabutts yeah of course, ua-cam.com/video/NfizT369g60/v-deo.html

    • @rudigerloloma1250
      @rudigerloloma1250 6 років тому

      Can you make a tutorial how to create a realistic movement animation pls

  • @DilkielGaming
    @DilkielGaming 4 роки тому +26

    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;
    }

    • @supersample
      @supersample 4 роки тому +1

      ​@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.

    • @FionaAnimatesBagels
      @FionaAnimatesBagels 4 роки тому +2

      you are a godsend. thank you

    • @IamJaieCarter
      @IamJaieCarter 4 роки тому +2

      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???

    • @DilkielGaming
      @DilkielGaming 4 роки тому

      @@IamJaieCarter paste your code here ill take a look

    • @IamJaieCarter
      @IamJaieCarter 4 роки тому +4

      @@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

  • @cyrianox
    @cyrianox 4 роки тому +1

    you're awesome ! each time i need a tutorial, you have the right one, at the best speech speed !!! please keep posting free vids !

  • @teacherofthings902
    @teacherofthings902 5 років тому +29

    Octaves tutorial or source code please!

  • @shashanktambe6341
    @shashanktambe6341 Рік тому +1

    if brackeys would have just shows how he did the layering of octaves , 6 hrs of my life would have been saved.

  • @alanrubinoff5217
    @alanrubinoff5217 5 років тому +1

    The only youtube where i am not annoyed when i listen to the sponsor at the beggining

  • @zeiksz
    @zeiksz 6 років тому +2

    Big thanks for this Shadergraph install tutorial!

  • @onezerodev1756
    @onezerodev1756 6 років тому +1

    This is so cool. I don'tr understand why some people are dislike this :(

  • @kmanL3G3N3D
    @kmanL3G3N3D 5 років тому

    just wanna say I really enjoy your videos BRACKEYS

  • @UnityExpert
    @UnityExpert 6 років тому

    Great video brackeys! as usual! best unity youtube channel ever!

  • @SebaneseTheLebanese
    @SebaneseTheLebanese 6 років тому

    Thank u for all these amazing tutorials!!

  • @TimbavatiLion
    @TimbavatiLion 6 років тому +1

    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?

    • @linus3662
      @linus3662 2 роки тому

      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.

  • @chuckwhitecotton4251
    @chuckwhitecotton4251 Рік тому +1

    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
      @Tjoldar Рік тому +1

      Could you explain what you did in a more detailed way? It doesnt work for me at all with Unity 2021.3.15f1

    • @chuckwhitecotton4251
      @chuckwhitecotton4251 Рік тому +1

      @@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!

    • @Tjoldar
      @Tjoldar Рік тому +1

      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.

    • @chuckwhitecotton4251
      @chuckwhitecotton4251 Рік тому +1

      @@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!

    • @Tjoldar
      @Tjoldar Рік тому +1

      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 🙂

  • @enterthecosmos7769
    @enterthecosmos7769 6 років тому +30

    Pls tell us how to do the octaves, I can’t find much online.

    • @DitzelGames
      @DitzelGames 6 років тому

      It's basically adding another noise with a different scale and height multipler.

    • @coolboidoesstuff9828
      @coolboidoesstuff9828 5 років тому +1

      @@DitzelGames But how do you implement the other value?

    • @Bluequaz
      @Bluequaz 5 років тому +6

      @@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;

    • @coolboidoesstuff9828
      @coolboidoesstuff9828 5 років тому +1

      @@Bluequaz thanks so much but i am working on 2d unity now lol

    • @Bluequaz
      @Bluequaz 5 років тому +6

      @@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

  • @elirockenbeck6922
    @elirockenbeck6922 4 роки тому +1

    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

  • @abhisheksuper20
    @abhisheksuper20 6 років тому +1

    Awesome content as usual. Brackeys never ceases to Impress

  • @wolvessuck1807
    @wolvessuck1807 6 років тому +69

    You should do another series on how to make a basic game.

    • @vladchira521
      @vladchira521 6 років тому +5

      God he has a million of all

    • @wolvessuck1807
      @wolvessuck1807 6 років тому +3

      Vlad Chira but updated using all the new stuff and stuff he hasn’t touched on.

    • @In-N-Out333
      @In-N-Out333 6 років тому +1

      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.

    • @rossdrummond2333
      @rossdrummond2333 6 років тому

      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

    • @wett1988
      @wett1988 6 років тому

      ... including the new workflow that Unity added - with ECS and nested Prefabs

  • @AkshayKumarX
    @AkshayKumarX 6 років тому

    Your hand game is on point today 👐

  • @the_yashe
    @the_yashe 6 років тому +8

    What about 3D Perlin Noise ? It's so interesting to make more complicated maps with voxels

    • @NielsRenkema
      @NielsRenkema 6 років тому +1

      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

  • @Gers217
    @Gers217 6 років тому

    I have no idea of this topic but I´m glad to watch it :)

  • @coolboidoesstuff9828
    @coolboidoesstuff9828 5 років тому +2

    YES PLEASE MAKE A VID ON OCTAVES!

  • @AtticusDragon
    @AtticusDragon 6 років тому

    Terrain tools is a free plug that allows doing this with materials on a traditional terrain object, really handy.

  • @coatsoup
    @coatsoup 6 років тому +1

    Or on the marching cubes algorithm, and 3D perlin noise? That would be AMAZING.

  • @lisarmia
    @lisarmia 5 років тому

    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!

  • @GoronTico
    @GoronTico 6 років тому

    This is not in tomorrow's test but fuck it, i learned how to do terrain generation today and i don't regret it.

  • @maureengotza530
    @maureengotza530 5 років тому

    That's exactly what I was searching for. Thank you

  • @charmingluck596
    @charmingluck596 4 роки тому +2

    It would be amazing if you could make a video on octaves.

  • @neuvedeno1
    @neuvedeno1 6 років тому

    Great video again. Thank you. Can’t wait for more

  • @Sharpshark136
    @Sharpshark136 6 років тому +5

    Make a video about octaves!

  • @TheProProgrammer
    @TheProProgrammer 6 років тому

    Holy smokes, these are so interesting, I want another video on these topics

  • @StigDesign
    @StigDesign 6 років тому

    Awsome that you continued this :D

  • @etopsirhc
    @etopsirhc 6 років тому +1

    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.

  • @Bearbones
    @Bearbones 6 років тому

    Definitely gonna bookmark this one!

  • @olefritsch2881
    @olefritsch2881 6 років тому

    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.

    • @rdex2840
      @rdex2840 3 роки тому

      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

  • @MrExelCZ
    @MrExelCZ 5 років тому +17

    Could you Share file for this Tutorial ? or do video about Octaves ? Tutorial by Sebastian Lague
    was not clear for me.
    thanks a lot

  • @GameDev1
    @GameDev1 6 років тому +1

    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.

    • @ihavecreatism9776
      @ihavecreatism9776 3 роки тому

      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.

  • @EqualToBen
    @EqualToBen 6 років тому +1

    props i didn't know about gradients

  • @ClashWithHsen
    @ClashWithHsen 6 років тому

    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

  • @angusmccall3400
    @angusmccall3400 6 років тому

    Thank you! I have been wondering how to do this for so long!

  • @NPOCrushader
    @NPOCrushader 6 років тому

    Octaves would be an epic video!!

  • @davecancode
    @davecancode 6 років тому

    Please do a video on animating the mesh, like a sin wave altering the height values!

  • @djyork8634
    @djyork8634 7 місяців тому

    fantastic tutorial, learnt so much thank you

  • @kosta1570
    @kosta1570 6 років тому +5

    Next video => Terrain texture by terrain height

    • @GoldenMoments100
      @GoldenMoments100 4 роки тому

      check out Sebastian Lague's terrain generation series!

  • @chunyinkwan7756
    @chunyinkwan7756 5 років тому

    This is absolutely amazing

  • @alicewithalex
    @alicewithalex 6 років тому +2

    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! :)

  • @sevvas8926
    @sevvas8926 6 років тому

    Yes finally a new video

  • @svetasemenova8679
    @svetasemenova8679 3 роки тому

    This is awesome 😎 Thank you so much !

  • @sethhorban3789
    @sethhorban3789 6 років тому +2

    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.

  • @CarlosAlberto-px8so
    @CarlosAlberto-px8so 4 роки тому +5

    what is the method " float GetNoiseSample(int x,int z)" please

    • @acces2020
      @acces2020 4 роки тому +1

      same i want to know

    • @ihavecreatism9776
      @ihavecreatism9776 3 роки тому

      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.

  • @memelord6356
    @memelord6356 Рік тому

    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

  • @whidzee
    @whidzee 6 років тому

    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?

  • @gamalalejandroabdulsalam904
    @gamalalejandroabdulsalam904 6 років тому +1

    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 :)

  • @gamingapocalypse1604
    @gamingapocalypse1604 5 років тому +5

    need help with octaves and how to apply multiple different textures

    • @GoldenMoments100
      @GoldenMoments100 4 роки тому +2

      check out Sebastian Lague's terrain generation series!

    • @ihavecreatism9776
      @ihavecreatism9776 3 роки тому

      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;

  • @BlackJar72
    @BlackJar72 3 роки тому

    "Gradient" could lead to a lot of confusion, between the Unity color thing and the mathematical concept which Perlin noise in based on.

  • @bgunev
    @bgunev 6 років тому +2

    I would love to learn about octaves

  • @finger-tourist
    @finger-tourist 2 роки тому +2

    I dont have the pbr Graph i import all things but its not in there

  • @stefans6557
    @stefans6557 4 роки тому

    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!

    • @mnnm1989
      @mnnm1989 4 роки тому +1

      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.

    • @pixsaoul1494
      @pixsaoul1494 2 роки тому

      To do that you can Lerp between two texture based on some height values. should do the trick.

  • @atrumluminarium
    @atrumluminarium 6 років тому

    Will you ever cover compute shaders?

  • @CoReeYe
    @CoReeYe 6 років тому

    New video from the Danish king :)

  • @themunchchannel1477
    @themunchchannel1477 6 років тому +1

    How did you do the layering of the noise. What did you do inside of the function?

    • @ihavecreatism9776
      @ihavecreatism9776 3 роки тому

      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;

  • @martingrof1685
    @martingrof1685 5 років тому +3

    I followed this exactly, but my terrain is coming up black?

  • @utkarshanand6828
    @utkarshanand6828 6 років тому +6

    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!

  • @Redblock
    @Redblock 4 роки тому +1

    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

    • @SpaceKebab
      @SpaceKebab 2 роки тому

      its URP now not LWPR sorry im a year late i hope you found out already or on a new project

  • @abdelp-haq8860
    @abdelp-haq8860 6 років тому

    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.

  • @benaffeyofficial
    @benaffeyofficial 4 роки тому

    Please create something like a Terrain Grid System for Highlighted Territory Borders in an RTS Game. I wanna learn more about that!

  • @DIBLIC
    @DIBLIC 4 роки тому +1

    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?

    • @ihavecreatism9776
      @ihavecreatism9776 3 роки тому

      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;

  • @duanvanstaden8334
    @duanvanstaden8334 6 років тому

    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.

  • @tanliyoung
    @tanliyoung 6 років тому

    always like the video before watching.

  • @ryanwoodworth3941
    @ryanwoodworth3941 6 років тому

    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!

  • @cubee4108
    @cubee4108 4 роки тому

    I hope that Unity's Gradient System as versatile as Unity's Particle System.

  • @donalodomhnaill
    @donalodomhnaill 2 роки тому +3

    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.

  • @toreole2993
    @toreole2993 6 років тому +1

    But is this now using the new terrain system? Or is it just a subdivided plane mesh whose vertices are offsettes?

    • @sensei9767
      @sensei9767 6 років тому

      It's a self-generated mesh

    • @toreole2993
      @toreole2993 6 років тому +1

      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

  • @petersmythe6462
    @petersmythe6462 3 роки тому

    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?

  • @CouchFerretmakesGames
    @CouchFerretmakesGames 6 років тому +9

    First! It was a Private video when I opened it. :D He posted the tweet first, and then he made the video public. :P

    • @insideman7501
      @insideman7501 6 років тому +2

      Hi, Ferret!

    • @CouchFerretmakesGames
      @CouchFerretmakesGames 6 років тому +1

      @@insideman7501 Ohh, hey! :)

    • @masondotnet
      @masondotnet 6 років тому +2

      Good to see you around here Ferret.

    • @CouchFerretmakesGames
      @CouchFerretmakesGames 6 років тому +1

      @@masondotnet Good to see you too! I always wait for Brackeys Sunday night video before calling it a night.

  • @ViniTheCrazzy
    @ViniTheCrazzy 4 роки тому

    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?!

  • @alexlucaxxxxxxxxxxxx
    @alexlucaxxxxxxxxxxxx 5 років тому +1

    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?

    • @icantth1nkofanam40
      @icantth1nkofanam40 4 роки тому +2

      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

    • @icantth1nkofanam40
      @icantth1nkofanam40 4 роки тому +2

      dont know exact code but

  • @trinandarizqitarausyanfiqr4141
    @trinandarizqitarausyanfiqr4141 5 років тому +2

    Hey, i'm using the version 2018.3.9f1 personal and there is no lightweight render , anybody can help me what should i do?

    • @jitsetenhove
      @jitsetenhove 5 років тому +4

      there is a small button named: "Advanced" click it and enable: "Show preview Packages", than you can just search for "Lightweight RP" :)

  • @samueldovbenyuk2137
    @samueldovbenyuk2137 6 років тому

    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.

  • @WerIstWieJesus
    @WerIstWieJesus 4 роки тому

    Super! More videos like that!

  • @yousefnashwan3366
    @yousefnashwan3366 6 років тому

    This look AMAZING

  • @71Arlekino
    @71Arlekino 4 місяці тому

    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.

  • @phantomz8803
    @phantomz8803 6 років тому

    Could u do it with textures the next video? Love ur vids!

  • @iliasdeschuyter5807
    @iliasdeschuyter5807 6 років тому +1

    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?

  • @ritasharon4061
    @ritasharon4061 6 років тому

    Great video. can you please do a video on how to create background like the stack mobile game

  • @kentsarikaya9475
    @kentsarikaya9475 5 років тому

    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.

  • @gregoryfenn1462
    @gregoryfenn1462 6 років тому

    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.

  • @Dev.K.Patel_19-June
    @Dev.K.Patel_19-June 2 роки тому

    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.

  • @gokufanmaxus1
    @gokufanmaxus1 6 років тому +1

    I missed some video? there are changes from the second to this