Coder Social home page Coder Social logo

oopsoverflow / moncraft Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 3.0 435.94 MB

Sandbox game developed using C++ 14 & OpenGL 3.3 πŸ•Ή

License: GNU Affero General Public License v3.0

HTML 0.64% CSS 0.20% C++ 90.64% CMake 4.32% GLSL 2.80% Python 0.31% JavaScript 0.97% Shell 0.11%
opengl fog minecraft-clone cpp shadows game-development

moncraft's Introduction

License: GPL v3 Language Release

Support Server

3d

3d

Sandbox game developed using C++ 14 & OpenGL 3.3 πŸ•Ή

Why Buy Minecraft When You Can Code it Yourself? πŸ’Ή


Compiling

Supports Windows and Linux. (Should work on MacOS but not tested)

Dependencies

  1. SDL2
  2. SFML
  3. GLEW
  4. GLM
  5. Freetype

App

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

WASM

  • 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

Contribute

βœ” Please do refer to CONTRIBUTING.md file.


World Interactions

  1. Moving Around --- WASD
  2. Look Around --- Move Mouse
  3. Detach Mouse --- Esc
  4. Block Placing --- RMB
  5. Selective Block Removal --- LMB
  6. Select Block --- Taget Block & Press Mouse Wheel Button
  7. Sprinting --- CTRL
  8. Filed of View (FOV) changes while sprinting βœ…
  9. Chang View --- F5
  10. God Mode --- Double Space
  11. Ascend (In God Mode Only) --- Space
  12. Descend (In God Mode Only) --- Shift
  13. Crouch -- Coming Soon!
  14. Place on Edge -- Coming Soon!

Features πŸ”₯

Solid Integration

MonCraft supports optimizations on both AMD and NVIDIA cards

βœ… Nvidia extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;}

http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf

βœ… AMD __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;


Frsutrum Culling


Shadow Engine πŸŒ‘

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.

shadows


3D Fog

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 :

fog

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 :

shadows

But Wait There's More πŸ’£

Fractal Brownian Motion was also implemented to give fog some procedurally generated animation.

fbm

$$f(p) = fbm( p + fbm( p + fbm( p ) ) )$$

This gives fog a crisp realistic effect.

Ambient Occlusion πŸŒ—

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.

aoc


Beautiful Terrain

High Definition texture pack 🎨

Unique artistic textures with vivid colors. Made-In-House by the one & only @PinoulMarcel Mojang don't DMCA us.

world

Procedurally Generated World 🌐

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.

noise

Superb Terrain Blending 🌲

src/noise/voronoi.cpp is used for a seamless biome blending ⚑

vor

Biomes 🌍

Seven unique biomes with different features and characteristics.


Dynamic Blocks


Wide Texture Atlas 🧭


SkyBox 🌌

High Definition skybox using cubemaps.


Transparency πŸ”Ž

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 :

  1. First, the solid blocks which require no sorting as long as they are rendered first
  2. 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)
  3. 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).


3D Chunks

It might look like a bug but it's definetly a feature.

3d


Eargasmic Music 🎢

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

Sound Effects

Literal bovine excrement πŸ™‚ πŸ’˜Memory leaks


Normal Map


Multithreading πŸ‘·β€β™‚οΈ

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)


No OS Specific dependencies 🐧


3D AABB Collision detection πŸ’₯


Player and World Animations

Block Breaking ⛏

3d

Player Movement Animations

wood

Water Surface Animation

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.

water


The Team Behid MonCraft

Name GitHub Email
Brossier Mathis @k2d222 [email protected]
Mahmoud Houssem @OopsOverflow [email protected]
Surer Pierre @PignoulMarcel [email protected]

Refrences

moncraft's People

Contributors

k2d222 avatar oopsoverflow avatar pierresurer avatar

Stargazers

 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

moncraft's Issues

Use loader in main

Too many bind don't use loader, we shall use it to make the code clearer.

Cmake TODO

Cmake is mandatory for the final rendering to the teacher

Camera can see through blocks in FPS

We can see throught blocks when the camera is tilted in FPS view. This is because the camera position is fixed to the player's head position. However, it is important to keep this system in TPS view.

Camera shifting

Camera slightly shifting after moving the cube ~e-6.
Maybe the difference between 2 mouse value is not set to null after releasing clic.

(tested on IceCube)

image

render only visible chunks

this is an easy fix which may help a lot with performance. All we have to do (roughly) is compare the angle between the camera forward direction and the chunk position and discard if greater than fov.

glsl core 430 or 330 ?

explicit uniform locations in glsl is supported since glsl 430. Do we use this feature which makes Shader code simpler, or do we rollback to 330 and reimplement shader.getUniformLocation as it was a case a while ago.

visual interferences when far away

The mipmaping seems to not be working.

MonCraft currently, debug texture instead of grass
MonCraft currently

Minecraft without mipmap
Minecraft without mipmap

Minecraft with mipmap
Minecraft with mipmap

Problem for far block rendering (only on windows)

Far blocks have issues on rendering. It is particularly visible on the trees with black spots that are strangely overlapped. Apparently, this seems to be related to frustum culling as the cutting is done parallel to the player.

Comment the code

We shall comment our code before the rendering of the project.

Make Application cleaner

We've had tested a lot in Application.cpp but we have to make a clear code. Terrain generation don't use the loader functions for exemple. We can keep the block but i guess he will disappear in the future.

lod for shadows ?

investigate the possibility to have multiple levels of details for the shadow casting.

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.