How to create Voxel Terrain Generation in Unity
up vote
1
down vote
favorite
That is the code that I am using for generating the terrain. But I can't manage to use the 2D Perlin Noise, it is creating a lot of no-needed blocks and does not look quite quadratic.
As a GrassCube I am using the default unity 3D Cube. I Will add texture later
Terrain picture
public GameObject GrassCube;
public GameObject RockCube;
public GameObject DirtCube;
void Start ()
CreateCube(16, 16, 16);
public void CreateCube(int sizeX, int sizeY, int sizeZ)
for (int x = 0; x < sizeX; x++)
for (int y = 0; y < sizeY; y++)
for (int z = 0; z < sizeZ; z++)
float PerlinNoise = Mathf.PerlinNoise(x * 0.2f, z * 0.2f) * 3;
GrassCube = Instantiate(GrassCube, new Vector3(x, PerlinNoise, z), Quaternion.identity);
GrassCube.name = "Cube:" + x + ", " + y + ", " + z;
c# unity3d terrain perlin-noise voxel
add a comment |
up vote
1
down vote
favorite
That is the code that I am using for generating the terrain. But I can't manage to use the 2D Perlin Noise, it is creating a lot of no-needed blocks and does not look quite quadratic.
As a GrassCube I am using the default unity 3D Cube. I Will add texture later
Terrain picture
public GameObject GrassCube;
public GameObject RockCube;
public GameObject DirtCube;
void Start ()
CreateCube(16, 16, 16);
public void CreateCube(int sizeX, int sizeY, int sizeZ)
for (int x = 0; x < sizeX; x++)
for (int y = 0; y < sizeY; y++)
for (int z = 0; z < sizeZ; z++)
float PerlinNoise = Mathf.PerlinNoise(x * 0.2f, z * 0.2f) * 3;
GrassCube = Instantiate(GrassCube, new Vector3(x, PerlinNoise, z), Quaternion.identity);
GrassCube.name = "Cube:" + x + ", " + y + ", " + z;
c# unity3d terrain perlin-noise voxel
1
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
That is the code that I am using for generating the terrain. But I can't manage to use the 2D Perlin Noise, it is creating a lot of no-needed blocks and does not look quite quadratic.
As a GrassCube I am using the default unity 3D Cube. I Will add texture later
Terrain picture
public GameObject GrassCube;
public GameObject RockCube;
public GameObject DirtCube;
void Start ()
CreateCube(16, 16, 16);
public void CreateCube(int sizeX, int sizeY, int sizeZ)
for (int x = 0; x < sizeX; x++)
for (int y = 0; y < sizeY; y++)
for (int z = 0; z < sizeZ; z++)
float PerlinNoise = Mathf.PerlinNoise(x * 0.2f, z * 0.2f) * 3;
GrassCube = Instantiate(GrassCube, new Vector3(x, PerlinNoise, z), Quaternion.identity);
GrassCube.name = "Cube:" + x + ", " + y + ", " + z;
c# unity3d terrain perlin-noise voxel
That is the code that I am using for generating the terrain. But I can't manage to use the 2D Perlin Noise, it is creating a lot of no-needed blocks and does not look quite quadratic.
As a GrassCube I am using the default unity 3D Cube. I Will add texture later
Terrain picture
public GameObject GrassCube;
public GameObject RockCube;
public GameObject DirtCube;
void Start ()
CreateCube(16, 16, 16);
public void CreateCube(int sizeX, int sizeY, int sizeZ)
for (int x = 0; x < sizeX; x++)
for (int y = 0; y < sizeY; y++)
for (int z = 0; z < sizeZ; z++)
float PerlinNoise = Mathf.PerlinNoise(x * 0.2f, z * 0.2f) * 3;
GrassCube = Instantiate(GrassCube, new Vector3(x, PerlinNoise, z), Quaternion.identity);
GrassCube.name = "Cube:" + x + ", " + y + ", " + z;
c# unity3d terrain perlin-noise voxel
c# unity3d terrain perlin-noise voxel
edited Nov 11 at 15:59
Loofer
4,51854490
4,51854490
asked Nov 10 at 22:36
MadForLife
63
63
1
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55
add a comment |
1
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55
1
1
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244112%2fhow-to-create-voxel-terrain-generation-in-unity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244112%2fhow-to-create-voxel-terrain-generation-in-unity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Hi, I am afraid I am not clear what problem you are trying to solve, can you expand on what issues you are having?
– Loofer
Nov 11 at 15:43
I mean you are looping 3 dimensionally for what appears to be a 2 dimension problem, and since your "y" of your cubes comes from perlin noise I think it is safe to remove that loop.
– Eddge
Nov 11 at 17:38
I want to create voxel world like this one using 2D Perlin Noise Voxel world
– MadForLife
Nov 11 at 19:26
Nevermind I managed to fix it now I need to add more depth and mountains to the world WorldGen
– MadForLife
Nov 12 at 6:55