{"id":19605733,"url":"https://github.com/grakepch/octacubic","last_synced_at":"2026-05-13T18:39:22.441Z","repository":{"id":65019809,"uuid":"575770958","full_name":"GrakePch/OctaCubic","owner":"GrakePch","description":"A Minecraft-style world in C++","archived":false,"fork":false,"pushed_at":"2024-01-15T01:05:01.000Z","size":7733,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T08:55:17.146Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrakePch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-08T09:03:06.000Z","updated_at":"2024-01-14T17:16:35.000Z","dependencies_parsed_at":"2024-01-14T18:45:25.787Z","dependency_job_id":"e5fdfd7b-69c0-4f86-856c-d6dcea14e035","html_url":"https://github.com/GrakePch/OctaCubic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrakePch%2FOctaCubic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrakePch%2FOctaCubic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrakePch%2FOctaCubic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrakePch%2FOctaCubic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrakePch","download_url":"https://codeload.github.com/GrakePch/OctaCubic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240890426,"owners_count":19873997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T09:46:05.556Z","updated_at":"2026-05-13T18:39:22.429Z","avatar_url":"https://github.com/GrakePch.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MinecraftAlter\n\n## Intro\nThis is a project made in C++ with OpenGL. The goal is to create a small scene that mimics the Minecraft world.\n\nMain Features:\n- **[New] Chunk-based** Terrain Generation\n-\tBlinn-Phone lighting model\n-   Shadow Mapping\n-\tSimple wave simulation\n-   Player Movement\n-   Player Collision\n- **[New] Block placing \u0026 destroying**\n-\tControllable Sunlight position\n-\tControllable Orbiting Camera\n\nUsed libraries: GLFW, Glad, glm, stb.\n\n![Current Progress](./images/230116.png?raw=true)\n*Fig: Current Progress*\n\n## Controls\n\n### Universal\n\n| Key   | Operation                           |\n|-------|-------------------------------------|\n| Q / E | Sun orbit to West / East            |\n| F1    | Default rendering                   |\n| F2    | Show wireframes                     |\n| F3    | Show normal (camera view)           |\n| F4    | Show shadow map                     |\n| F5    | Toggle Observer / First Person view |\n| F10   | Toggle Player Floating              |\n| F11   | Toggle full screen                  |\n| F12   | Randomize terrain                   |\n| Esc   | Exit                                |\n\n### Observer View\n\n| Mouse            | Operation                 |\n|------------------|---------------------------|\n| Hold LMB \u0026 Move  | Orbit camera around world |\n| Scroll Up / Down | Zoom in / out             |\n\n### First Person View\n\n| Mouse | Operation                      |\n|-------|--------------------------------|\n| Move  | Look around                    |\n| LMB   | Destroy block                  |\n| RMB   | Place block at the aiming face |\n\n| Key           | Operation                            |\n|---------------|--------------------------------------|\n| W / S         | move forward / backward              |\n| A / D         | move to left / right                 |\n| LShift        | sprinting                            |\n| Space         | Jump                                 |\n| Space / LCtrl | Floating Mode: Player move up / down |\n\n## To-do\n\n- [ ] Rework sun\n- [ ] Light intensity changes with sun position\n- [x] A bigger world (procedurally loaded and unloaded chunks)\n- [ ] Screen-space reflection (for the water)\n- [ ] Ambient occlusion\n- [ ] Anti-aliasing\n- [x] Controllable player\n  - [x] Movements\n  - [x] Collision\n  - [x] Block placing \u0026 destroying\n  - [x] Block placing on the block face\n- [x] Performance improvement\n- [x] Shadow Mapping (use depth map)\n- [x] Sky color changes with sun position\n- [x] Texturing\n  - [x] Basic\n  - [x] Multiple textures for one block\n\n## Libraries\n- [GLFW](https://www.glfw.org/) - Window management and input handling\n- [Glad](https://github.com/Dav1dde/glad) - OpenGL function loader\n- [glm](https://github.com/g-truc/glm) - Mathematics library for OpenGL\n- [stb_image](https://github.com/nothings/stb) (included) - Image loader\n- [ImGui](https://github.com/ocornut/imgui) (included) - GUI library for debugging\n\n## Implementation\n\n### Terrain Generation\n\nThe information of the world is stored in a 256\\*256\\*256 int multi-dimensional array. The int is the id of different types of blocks. Currently, the id only determines the color of the cubes. A map from int to vec3 tells the program how to color the cubes.\n\nAs the program start, a terrain generation code is run. The program loop over the x-z plane (the horizontal plane) and do Perlin noise calculation to get the altitude of the ground surface. \n\nThen, assign the color of cubes to make it looks like terrain. If the Altitude ≤ 25, color the surface as sand, if 25 \u003c Altitude \u003c 35, color the surface as grass, above that, color the surface as snow. Above each surface, if the y ≤ 23, filled with water blocks, else filled with air (not rendered later).\n\n### Rendering (outdated)\n\nWhen rendering each frame, it updates the background color according to the light source position, which mimics the sky. Then, it calculates the camera transform based on the global variables that store the camera position. The variable is influenced by keyboard input (with functions provided by GLFW). Similarly, light position transform is also handled here.\n\nAfter linking the variable to the shader uniforms, the function drawWorldCubes() is called to loop over the world info and render each cube. In every iteration, it first checks if the block is air, or if the 6 sides of the block are all covered by other blocks, then skip the render. After excluding the unnecessary blocks, it creates a translation matrix, to transform the unit cube vertices (centered at the origin, with the length = 1) to their proper coordinates, and pass that matrix to the shader. If the block is a water surface, it does a shrinking scale to make the water surface a bit lower than the shore, and also passes some variables to the shader for the specular lighting and wave simulation. Finally, it passes the preset cube color as the diffuse color to the shader.\n\n![Wireframes of the scene](./images/221221_wireframes.png?raw=true)\n*Fig: Wireframe of the scene. The cubes and faces that are fully covered by other opaque cubes are not rendered to save performance. Face culling is also enabled.*\n\nThe shader is relatively simple. Most of the cubes use diffuse lighting, while the water cube uses the Blinn-Phone model to add a specular light. In addition, multiple sine wave rotations are applied to the fragment normal of the water surface, to create a simple wave simulation for the water.\n\n![Normals of the scene](./images/221221_normals.png?raw=true)\n*Fig: Normals of the scene (Camera space).*\n\n![Showcase of wave simulation](./images/221221_waves.png?raw=true)\n*Fig: Showcase of wave simulation.*\n\n### References\n\n- OpenGL basics\n  - https://learnopengl.com/\n- Perlin Noise\n  - https://en.wikipedia.org/wiki/Perlin_noise\n  - https://rtouti.github.io/graphics/perlin-noise-algorithm\n  - https://www.bilibili.com/video/BV11V4y1M7N6\n- Rotation Transformation about an arbitrary axis\n  - https://www.neilmendoza.com/glsl-rotation-about-an-arbitrary-axis/\n- Single header image loading lib\n  - https://github.com/nothings/stb/blob/master/stb_image.h\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrakepch%2Foctacubic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrakepch%2Foctacubic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrakepch%2Foctacubic/lists"}