Search Unity

Overlapping indexes in Color-Map

Discussion in 'World Building' started by SeliusX, Jun 26, 2022.

  1. SeliusX

    SeliusX

    Joined:
    Jun 26, 2022
    Posts:
    1
    Hopefully you can explain a characteristic of Unity.
    I'm prety new to unity and trying to solve this amasing tutorial from Sebastian Lague "Procedural Landmass Generation".
    Following the tutorial I stumbled across the part where he converts the noiseMap to a colorMap, visible at 6:30.
    The indices are build with
    Code (C#):
    1.  
    2. for(int y = 0; y < height; y++) {
    3.     for(int x = 0; x < width; x++) {
    4.         colourMap[y * width + x] = ...
    5.     }
    6. }
    7.  
    Regarding to the math, the indices shoud overlaps themself. Because for example in a 3x3 grid the point (3|0) should collide with point (0|1) : 0 * 3 + 3 is the same as 1 * 3 + 0. But the pixels are kind of displaced if I fix this issue with an additional index counter like this:
    Code (C#):
    1.  
    2. for(int y = 0; y < height; y++) {
    3.     for(int x = 0; x < width; x++) {
    4.         colourMap[c++] = ...
    5.     }
    6. }
    7.  
    What's the part I'm missing here?
     

    Attached Files:

    Last edited: Jun 27, 2022