Code Monkey home page Code Monkey logo

ue5voxeltutorial's Introduction

Unreal Engine 5 Voxel Tutorial

video tutorial series - https://youtube.com/playlist?list=PLgji-9GMuqkK7EwUCVCuc2w3En1bPo5rA

A Collection of voxel mesh generation algorithms

  • Naive Blocky Generation (Minecraft like)
  • Greedy Meshing Blocky Generation (Probably what minecraft actually uses)
  • Marching Cubes (Blocky & Smooth)

Features

  • Simple World system to spawn multiple chunks
  • Vertex Colors

Notice

This project does not aim to be a production ready voxel engine. it's developed for educational purposes. However this project can be used as a starting point to develop a production ready voxel engine.

ue5voxeltutorial's People

Contributors

blazekill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ue5voxeltutorial's Issues

Materials are rotated on some faces.

This only occurs in the GreedyMesh chunk type. The applied material is rotated by 90 degrees on some faces. I have included a screenshot of both a Greedy Chunk and a Naive Chunk.
Greedy Chunk
Naive Chunk

It appears that only one chunk is editable

I haven't been able to locate the root cause of the issue but it appears that only a single chunk is able to have blocks added or removed from it, one coordinate from that chunk is: 24, 6, 24 for reference.

Every other chunk will simply appear to ignore any attempts at modifying the chunk data.

AMarchingChunk::Generate2DHeightMap strange terrain

Using Generate2DHeightMap instead of Generate3DHeightMap leads to strange terrain.

The Xpos/Ypos calculation should probably changed from:
const float Xpos = x * Position.X;
const float Ypos = y * Position.Y;
To:
const float Xpos = x + Position.X;
const float Ypos = y + Position.Y;

Unable to pull Project (and rebuild)

The sln file is not here so pulling and testing it does not work since i cant open the solution? not sure if you did that on purpose or just forgot to upload that 2

Caves?

Hi again,

Thank you for this repository. Can you do caves? The chunks are empty inside and only generates top area like hills, mountains.

[Suggestion] Chunk Materials

Here's an implementation I found working you can add to your tutorial:

  • ChunkBase.h:
    image
    (A blueprint-accessible array for materials, plus arrays for the material struct and vertices instead of single values)

  • ChunkBase.cpp:
    image
    (On clearing, empty the arrays then refresh using the total amount of materials, not blocks)

  • NaiveChunk.cpp, in GenerateMesh():
    image
    (Get the material for the current block's face, minus 2 to skip null and air enums, clamp as a safety, then pass it to CreateFace() )

  • NaiveChunk.cpp, in CreateFace():
    image
    (Switch all mesh structs and the vertex int to the new arrays)

  • GreedyChunk.cpp, GenerateMesh():
    image
    (Same as NaiveChunk, but using CurrentMask.Block for the face's material)

  • ApplyMesh():
    image
    (First clear all previous sections, then generate a new one for each material on the chunk)

Basically the same code as before, but generates one unique section for each different block material. Straightforward to scale-up (just add materials to the array) and supports both naive/greedy meshing. Maybe you had something in mind too of the like.

Unable to edit terrain using marching cubes

Using BP_MarchingBlocks and attempting to edit results in:
\UE5VoxelTutorial\Private\Voxel\Chunk\ChunkBase.h] [Line: 44] Pure virtual not implemented (AChunkBase::RemoveVoxelData)

Crash trying to implement Greedy Meshing in UE4 (Array index out of bounds)

Hello!
THANK YOU FOR YOUR TUTORIAL, it's really amazing.

I'm having an issue trying to implement the greedy meshing shown in your episode 4. I've copied completely identically the code shown in the video (not the one in the UE5 github), with the necessary modifications to use the noise plugin. There's no UE4 greedy example provided unfortunately!

It generates the chunk normally but crashes when the size is set beyond 16 or with multiple chunks being spawned, with an error "Array index out of bounds". It's always from ChunkGreedy.cpp, but the lines often changes (24, 36, 94, 143), usually corresponding to "if (Mask[N].Normal != 0) {" or "Mesh->CreateMeshSection". The array size also changes, ex. on the provided crash "4096 from an array of size 4096", sometimes 512, etc. Maybe related to how TArrays work in UE4 versus UE5?

Here's the crash and sources I'm using:
Crash.log
Private.zip
(Using UE 4.25 in a clean C++ project with nothing else)

It does greedy meshing exactly as expected otherwise.

Width is Actually Height and Height is Width

I was setting up some UVs to do something other than terrain with the greedy mesh code and I noticed the Width and Height are reversed.
By changing Width -> Height and Height -> Width the UVs work as Expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.