Skip to content

Commit

Permalink
Improved frustum culling, code cleanup and other minor changes and im…
Browse files Browse the repository at this point in the history
…provements
  • Loading branch information
voldien committed Dec 8, 2024
1 parent 4d163b5 commit 31284f1
Show file tree
Hide file tree
Showing 77 changed files with 718 additions and 694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Configure dependencies
run: |
sudo apt-get update
sudo apt-get install pkg-config libsdl2-dev libfreeimage-dev libfreetype6-dev libfmt-dev libglm-dev libglew-dev libgtest-dev googletest mesa-common-dev mesa-utils libopenal-dev libalut-dev
sudo apt-get install pkg-config libsdl2-dev libfreeimage-dev libfmt-dev libglm-dev libglew-dev libgtest-dev googletest mesa-common-dev mesa-utils libopenal-dev libalut-dev
sudo apt-get install glslang-tools libassimp-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libglfw3-dev binutils-dev libeigen3-dev libglu1-mesa-dev libbz2-dev \
libzip-dev libogg-dev libopus-dev libvorbis-dev
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)

FIND_PACKAGE(PkgConfig QUIET)
SET(OpenGL_GL_PREFERENCE "GLVND")
FIND_PACKAGE(OpenGL REQUIRED)

FIND_PACKAGE(OpenMP QUIET)

#
Expand Down Expand Up @@ -50,6 +47,9 @@ ENDIF()
# Backend libraries
# ###########################################
SET(MIMI_VULKAN_SUPPORT OFF)
SET(MIMI_TERMINAL_SUPPORT OFF)
SET(MIMI_OPENGL_SUPPORT ON)
SET(MIMI_WINDOW_SDL2_SUPPORT ON)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/extern/nekomimi EXCLUDE_FROM_ALL)
# Fragcore specific libraries
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/extern/nekomimi/extern/fragcore/modules/image/imageloader EXCLUDE_FROM_ALL)
Expand Down
104 changes: 52 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,144 +29,144 @@ Usage:

## Samples

- [**Triangle**](Samples/Triangle)
### [**Triangle**](Samples/Triangle)

![Triangle](https://github.com/voldien/OpenGL-Samples/assets/9608088/d85a24d2-97fb-4faa-a7ef-e71bdd979444)

- [**Texture**](Samples/Texture)
### [**Texture**](Samples/Texture)

![Texture](https://github.com/voldien/OpenGL-Samples/assets/9608088/a87834cc-452e-41e0-8ea2-3de881780823)
![Texture](https://github.com/voldien/OpenGL-Samples/assets/9608088/7bdcaa6f-c0de-4030-b344-d6f180dc6e7b)

### [**Point Lights**](Samples/PointLight)

### ![PointLights](https://github.com/voldien/OpenGL-Samples/assets/9608088/dcd67197-4dc9-4333-ae6f-9fff9f7eb317)

- [**Point Lights**](Samples/PointLight)
- ![PointLights](https://github.com/voldien/OpenGL-Samples/assets/9608088/dcd67197-4dc9-4333-ae6f-9fff9f7eb317)
### [**Normal Mapping**](Samples/NormalMap)

- [**Normal Mapping**](Samples/NormalMap)
### [**SkyBox Cubemap**](Samples/Skybox)

- [**SkyBox Cubemap**](Samples/Skybox)
![SkyboxPanoramic](https://github.com/voldien/OpenGL-Samples/assets/9608088/41cacd12-5782-46bd-b06b-dc3725f21b3d)

- [**SkyBox Panoramic**](Samples/Skybox)
### [**SkyBox Panoramic**](Samples/Skybox)

![SkyboxPanoramic](https://github.com/voldien/OpenGL-Samples/assets/9608088/41cacd12-5782-46bd-b06b-dc3725f21b3d)

- [**Fog**](Samples/Fog)
### [**Fog**](Samples/Fog)

![Fog](https://github.com/user-attachments/assets/28e60ff4-7579-430d-acee-89e19e1f527a)

- **Simple Reflection**
### **Simple Reflection**

### [**Instance**](Samples/Instance)

- [**Instance**](Samples/Instance)
![Instance](https://github.com/voldien/OpenGL-Samples/assets/9608088/8fb4adca-cd99-45c9-9811-38e727b6685b)

- [**SubSurface Scattering**](Samples/SubSurfaceScattering)
### [**SubSurface Scattering**](Samples/SubSurfaceScattering)

![Subsurface Scattering](https://github.com/voldien/OpenGL-Samples/assets/9608088/062f5af0-898e-4c1b-91ab-38975b898e0c)
![Subsurface Scattering](https://github.com/voldien/OpenGL-Samples/assets/9608088/ac752bfc-cc72-49ae-a9d6-2c729cd07c2d)

- [**Normal**] (Samples/Normal)

### [**Normal**](Samples/Normal)

![Normal](https://github.com/user-attachments/assets/d06d37ca-71d3-4346-91ef-266bc043a4f9)

### [**Blinn - Phong**](Samples/PhongBlinn/)

- **Blinn - Phong**
![PhongBlinn](https://github.com/voldien/OpenGL-Samples/assets/9608088/e14e4035-1639-4532-a316-65c8c879abf9)
![PhongBlinn](https://github.com/voldien/OpenGL-Samples/assets/9608088/02ae2bac-974e-4270-b80f-a59dba260160)

- **Terrain**

- **Shadow Map**
### [**Shadow Map**](Samples/ShadowMapping/)

![BasicShadowMapp](https://github.com/user-attachments/assets/f4596f70-1f89-4595-912c-dd3848c0788c)

### [**Shadow Map PCF**](Samples/ShadowMapping/)

- **Shadow Map PCF**
![BasicShadowMap PCF](https://github.com/user-attachments/assets/1097b804-c8d5-46df-b032-b4e29df7ae58)
![BasicShadowMap PCF](https://github.com/user-attachments/assets/cae348e3-9c2a-4443-8119-02f018fc0109)

### **Point Shadow Light**

- **Point Shadow Light**
![PointLightShadow](https://github.com/user-attachments/assets/daaf91b3-b0ee-4b55-a182-ad326b0e2634)

### [**Shadow Projection**](Samples/ProjectedShadow/)

- [**Shadow Projection**](Samples/ProjectedShadow/)
![ProjectedShadow](https://github.com/user-attachments/assets/d1a17f8e-21c5-42e3-8e4a-094bbe3d8a0b)

### **Shadow Map Variance**

- **Shadow Map Variance**

### **Shadow Volume**

- **Shadow Volume**
### **Cascading Shadow**

### **Contact Shadow**

- **Cascading Shadow**
### [**Tessellation Basic**](Samples/Tessellation/)


- **Contact Shadow**


- [**Tessellation Basic**](Samples/Tessellation/)


- **MipMap Visual**
### [**MipMap Visual**](Samples/MipMapVisual/)

![MipMapVisual](https://github.com/voldien/OpenGL-Samples/assets/9608088/ea0714f4-4971-42ad-80db-4d567dc29b03)

- **Multipass**
### [**Multipass**](Samples/MultiPass/)

![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/6c156319-7617-43aa-af08-93d709bc07e9)

- [**Deferred Rendering**](Samples/Deferred/)
### [**Deferred Rendering**](Samples/Deferred/)

- [**Ambient Occlusion**](Samples/AmbientOcclusion/)
### [**Ambient Occlusion**](Samples/AmbientOcclusion/)

![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/91691104-4c70-4d25-91c0-17cb4bcf38af)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/4e8f9d85-b48d-4fc4-816d-632a9bbfd37f)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/4df33593-64f3-4a03-87b5-5e9d205642c5)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/8ed5a638-2432-4800-8ead-2c5f4881fffc)

- **Physical Based Rendering**
### **Physical Based Rendering**

- **Panoramic**(Samples/Panoramic/)
### [**Panoramic**](Samples/Panoramic/)

![Panoramic](https://github.com/user-attachments/assets/3431b44d-0932-49cb-a96e-7cc6b4bbd8f2)
![Panoramic](https://github.com/user-attachments/assets/dd618200-ea77-4844-a56f-7b863878864f)

### [**Skinned Mesh**](Samples/SkinnedMesh/)

- [**Skinned Mesh**](Samples/SkinnedMesh/)
### [**Simple Ocean**](Samples/SimpleOcean/)

- [**Simple Ocean**](Samples/SimpleOcean/)
### **Ocean**

- **Ocean**
### [**Video Playback**](Samples/VideoPlayback/)

- [**Video Playback**](Samples/VideoPlayback/)
### **Ray Tracing**

- **Ray Tracing**

- [**Game Of Life**](Samples/GameOfLife)
### [**Game Of Life**](Samples/GameOfLife)

![GameOfLife](https://github.com/voldien/OpenGL-Samples/assets/9608088/5617752d-cd6d-4ceb-9918-f5015565489f)


- [**Mandelbrot**](Samples/Mandelbrot/)
### [**Mandelbrot**](Samples/Mandelbrot/)

![MandelBrot](https://github.com/voldien/OpenGL-Samples/assets/9608088/cae86eb2-b5f5-4c20-ad13-aed2c154d5d1)

- [**ReactionDiffusion**](Samples/ReactionDiffusion)
### [**ReactionDiffusion**](Samples/ReactionDiffusion)

- [**Vector Field 2D**](Samples/VectorField2D/)
### [**Vector Field 2D**](Samples/VectorField2D/)

![VectorField2D](https://github.com/user-attachments/assets/43b3da51-83d6-4b51-ae06-792b01493c2a)

- **Support Vector Machine**
### **Support Vector Machine**

- **Compute Group Visual**
### **Compute Group Visual**

![ComputeGroup](https://github.com/user-attachments/assets/a06d9256-05fa-4e16-9621-e2f7b473c9c5)

- **Marching Cube**
![MarchingCube](https://github.com/user-attachments/assets/f748e312-737c-4106-877b-93b59a9778d5)
### **Marching Cube**

![MarchingCube](https://github.com/user-attachments/assets/f748e312-737c-4106-877b-93b59a9778d5)

- **Rigidbody**
### **Rigidbody**

![RigidBody](https://github.com/user-attachments/assets/74e55eea-8f19-4a80-82b1-e88952334db0)


## Build Instruction

```bash
Expand Down
4 changes: 2 additions & 2 deletions Samples/AlphaClipping/AlphaClipping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace glsample {
this->diffuse_texture = textureImporter.loadImage2D(texturePath, ColorSpace::SRGB);

/* Align the uniform buffer size to hardware specific. */
GLint minMapBufferSize;
GLint minMapBufferSize = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &minMapBufferSize);
this->uniformSize = Math::align<size_t>(this->uniformSize, (size_t)minMapBufferSize);

Expand All @@ -149,7 +149,7 @@ namespace glsample {

void draw() override {

int width, height;
int width = 0, height = 0;
this->getSize(&width, &height);

/* */
Expand Down
32 changes: 16 additions & 16 deletions Samples/AmbientOcclusion/AmbientOcclusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,31 @@ namespace glsample {
Scene scene;

/* G-Buffer */
unsigned int multipass_framebuffer;
unsigned int multipass_texture_width;
unsigned int multipass_texture_height;
unsigned int multipass_framebuffer{};
unsigned int multipass_texture_width{};
unsigned int multipass_texture_height{};
std::vector<unsigned int> multipass_textures;
unsigned int depthTexture;
unsigned int depthTexture{};

unsigned int ssao_framebuffer;
unsigned int ssaoTexture;
unsigned int ssao_framebuffer{};
unsigned int ssaoTexture{};

/* White texture for each object. */
unsigned int white_texture;
unsigned int white_texture{};
/* Random direction texture. */
unsigned int random_texture;
unsigned int random_texture{};

/* */
unsigned int multipass_program;
unsigned int ssao_world_program;
unsigned int ssao_depth_program;
unsigned int texture_program;
unsigned int multipass_program{};
unsigned int ssao_world_program{};
unsigned int ssao_depth_program{};
unsigned int texture_program{};

/* Uniform buffer. */
unsigned int uniform_buffer_binding = 0;
unsigned int uniform_ssao_buffer_binding = 1;
unsigned int uniform_buffer;
unsigned int uniform_ssao_buffer;
unsigned int uniform_buffer{};
unsigned int uniform_ssao_buffer{};
const size_t nrUniformBuffer = 3;

/* */
Expand Down Expand Up @@ -280,7 +280,7 @@ namespace glsample {
glUseProgram(0);

/* Align uniform buffer in respect to driver requirement. */
GLint minMapBufferSize;
GLint minMapBufferSize = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &minMapBufferSize);
this->uniformBufferAlignedSize =
fragcore::Math::align<size_t>(this->uniformBufferAlignedSize, (size_t)minMapBufferSize);
Expand Down Expand Up @@ -505,7 +505,7 @@ namespace glsample {
void draw() override {

this->update();
int width, height;
int width = 0, height = 0;
this->getSize(&width, &height);

/* */
Expand Down
4 changes: 2 additions & 2 deletions Samples/Blending/Blending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace glsample {
this->ground_diffuse_texture = textureImporter.loadImage2D(diffuseGroundTexturePath);

/* Align uniform buffer in respect to driver requirement. */
GLint minMapBufferSize;
GLint minMapBufferSize = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &minMapBufferSize);
this->uniformAlignBufferSize = Math::align<size_t>(this->uniformAlignBufferSize, (size_t)minMapBufferSize);

Expand Down Expand Up @@ -186,7 +186,7 @@ namespace glsample {

void draw() override {

int width, height;
int width = 0, height = 0;
this->getSize(&width, &height);

// TODO draw multiple instance with various position and color to show the blending.
Expand Down
10 changes: 5 additions & 5 deletions Samples/CirclePacking/CirclePacking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace glsample {
} Circle;

struct uniform_buffer_block {
alignas(16) glm::mat4 model;
alignas(16) glm::mat4 view;
alignas(16) glm::mat4 proj;
alignas(16) glm::mat4 modelView;
alignas(16) glm::mat4 modelViewProjection;
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
glm::mat4 modelViewProjection;
glm::vec4 color = glm::vec4(1);

/* */
Expand Down
10 changes: 5 additions & 5 deletions Samples/ComputeGroupVisual/ComputeGroupVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ namespace glsample {
} InstanceData;

struct uniform_buffer_block {
alignas(16) glm::mat4 model;
alignas(16) glm::mat4 view;
alignas(16) glm::mat4 proj;
alignas(16) glm::mat4 modelView;
alignas(16) glm::mat4 modelViewProjection;
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
glm::mat4 modelViewProjection;

/* light source. */
glm::vec4 direction = glm::vec4(1.0f / sqrt(2.0f), -1.0f / sqrt(2.0f), 0, 0.0f);
Expand Down
8 changes: 4 additions & 4 deletions Samples/Deferred/Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace glsample {
glUseProgram(0);

/* Align uniform buffer in respect to driver requirement. */
GLint minMapBufferSize;
GLint minMapBufferSize = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &minMapBufferSize);
this->uniformAlignBufferSize =
fragcore::Math::align<size_t>(this->uniformAlignBufferSize, (size_t)minMapBufferSize);
Expand Down Expand Up @@ -430,7 +430,7 @@ namespace glsample {
this->pointLights[i].qudratic_attenuation = 0.19f;
this->pointLights[i].intensity = 1.5f;
}
this->directionalLights.push_back(DirectionalLight());
this->directionalLights.emplace_back();
}

void onResize(int width, int height) override {
Expand Down Expand Up @@ -468,7 +468,7 @@ namespace glsample {
/* Depth/Stencil. */
glBindTexture(GL_TEXTURE_2D, this->depthstencil_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, this->deferred_texture_width,
this->deferred_texture_height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
this->deferred_texture_height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
this->depthstencil_texture, 0);
Expand All @@ -493,7 +493,7 @@ namespace glsample {
void draw() override {

/* */
int width, height;
int width = 0, height = 0;
this->getSize(&width, &height);

/* */
Expand Down
Loading

0 comments on commit 31284f1

Please sign in to comment.