Sandbox game developed using C++ 14 & OpenGL 3.3 πΉ
Why Buy Minecraft When You Can Code it Yourself? πΉ
Supports Windows and Linux. (Should work on MacOS but not tested)
- SDL2
- SFML
- GLEW
- GLM
- Freetype
Use cmake with the flags BUILD_TARGET=<client|server>
and CMAKE_BUILD_TYPE=<Debug|Release>
.
Default is client / Release.
Run in build directory: cd <Client|Server>/App/<Debug|Release> && ./MonCraft
- Install and activate emscripten.
- Use the following commands, but replace stuff in
<>
with appropriate: mkdir build && cd build
emcmake cmake -DBUILD_TARGET=client -DCMAKE_BUILD_TYPE=<Debug|Release> -DBUILD_PLATFORM=wasm ..
make -j<N>
emrun --no_browser --serve_after_close --serve_root Client/Wasm/<Debug|Release>/ Client/Wasm/<Debug|Release>/MonCraft.html
β Please do refer to CONTRIBUTING.md
file.
- Moving Around --- WASD
- Look Around --- Move Mouse
- Detach Mouse --- Esc
- Block Placing --- RMB
- Selective Block Removal --- LMB
- Select Block --- Taget Block & Press Mouse Wheel Button
- Sprinting --- CTRL
- Filed of View (FOV) changes while sprinting β
- Chang View --- F5
- God Mode --- Double Space
- Ascend (In God Mode Only) --- Space
- Descend (In God Mode Only) --- Shift
- Crouch -- Coming Soon!
- Place on Edge -- Coming Soon!
MonCraft supports optimizations on both AMD and NVIDIA cards
β
Nvidia extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;}
β
AMD __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
MonCraft has a fully fledged shadow engine that makes the terrain look more beautiful and crisp. Shadows also give the terrain some realism and highlight its features.
Fog is very popular element in computer graphics, so popular that in fact we are always introduced to it early in textbooks or tutorials. However these textbooks, tutorials and even APIs only go as far as a simple distance based color blending, and stop there. Even advanced demos, interactive applications and games go no further that the simple color blending. -- Inigo Quilez.
But Not MonCraft. We implements fog in a way even OG Minecraft failed to do. The fog implementation augments the terrain features like depth and curve it also quickly helps us understand the distances and therefore scale of objects, and the world itself.
The fog density depends on the direction of the sun, and the amount of global illumination in the area. The areas with less lighting have a more dense fog.
Same place, different direction :
How does it workβ
float sunAmount = max( dot(vec3(m_view), lightDirection), 0.0 );
vec3 fogColor = mix( vec3(0.5,0.6,0.7), // bluish
vec3(1.0,0.9,0.7), // yellowish
pow(sunAmount,8.0) );
Fractal Brownian Motion
also makes the fog depend on the day/night cycle.
Fog moving :
Fractal Brownian Motion
was also implemented to give fog some procedurally generated animation.
This gives fog a crisp realistic effect.
Ambient occlusion is a shading and rendering method used for global background or indirect shading of objects. This method is used to add more realism to the render because it creates soft global shadows that contribute to the visual separation of objects. This is a global method, i.e., the brightness value of every point of the object depends on other objects in the scene. Shadows do not remain black, they dissipate, creating halftones and obscuring those places in space that get less light.
Unique artistic textures with vivid colors. Made-In-House by the one & only @PinoulMarcel Mojang don't DMCA us.
Simplex Noise
under src/noise/noise.cpp
is used to create the world map.
It's finely tuned to give different terrain heights and features, such as hills, mountains and oceans.
src/noise/voronoi.cpp
is used for a seamless biome blending β‘
Seven unique biomes with different features and characteristics.
High Definition skybox using cubemaps.
Moncraft implements transparent blocks such as Water_Block
& Leaf_Block
and more are to come!
How does it work β
Before each frame draw, we compute the position of the chunks in the camera space. that way, we can:
- check that they are visible in the frustum -> only render visible chunks
- compute their z-distance to the camera.
That way, we can sort the chunks back-to-front to render them in that order. The sort has a cost of nlogn : it would not be possible to sort each block ! but because blocks are grouped in chunks, and there are about 1000 chunks loaded at a time, the cost is not too high. inside each chunk, there is only one mesh. the EBO of the mesh is constructed that way :
- First, the solid blocks which require no sorting as long as they are rendered first
- Then, the transparent faces in Β±x direction, then n Β±y direction, then in Β±z direction. those faces are stored from negative to positive (more or less)
- Finally, the same transparent faces as before, but in reverse order.
That way, we render first solid blocks, then transparent blocks in the direction we are looking at, back to front (choosing if we draw using the normal or reverse indices).
It might look like a bug but it's definetly a feature.
Royalty-free high definition music that fits the game's atmosphere. π₯
Track Name | Artist Β© |
---|---|
A New Sleep | Arden Forest |
Mays | Van Sandano |
Reconstruct | Amaranth Cove |
Minecraft Happy Music |
Literal bovine excrement π πMemory leaks
Allows for huge performance gains by using multiple worker_threads
to generate the environment.
Under src/terrain/terrain.hpp
.
Uses worker threads to generate chunks and precompute the opengl data. Because opengl is single-threaded, the vbos need to be created on the main thread. The workers do as much work as possible to make the task easier for the poor main thread. This allows for huge performance upgrades and a better playing experience as chunks are generated in a faster and a seamless way. We are proud to say that our game is well optimized so far, on medium budget cards the engine can easily output over 200fps (the fps counter is accessed by pressing the F key to pay respect)
We made a custom normal map in blender and used the fact that blocks are aligned with the x/y/z axis to our advantage : we didnβt need to send the tangent and bitangent, we could guess them from the faces alignment. We havenβt found an effective way to calculate reflection as the water is not a plane but a block that can be placed anywhere in the world. So we couldnβt calculate a reflection on each block without raytrace light. We only calculate specular light on water blocks, so in order to differentiate it from a mesh, we put the alpha component to 0 for the other normals.
Name | GitHub | |
---|---|---|
Brossier Mathis | @k2d222 | mathis.brossier@universite-paris-saclay.fr |
Mahmoud Houssem | @OopsOverflow | houssemmahmoudswe@gmail.com |
Surer Pierre | @PignoulMarcel | pierre.surer@universite-paris-saclay.fr |