Skip to content

Commit

Permalink
Improvement, cleanup and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
voldien committed Oct 26, 2024
1 parent b3d31ee commit 554cac5
Show file tree
Hide file tree
Showing 54 changed files with 429 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.3.204.0
vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Tools, SPIRV-Cross
vulkan-components: Glslang, SPIRV-Tools, SPIRV-Cross
vulkan-use-cache: true

- name: Create Build Environment
Expand Down
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common)
# ###################################
# OpenGL Samples
# ###################################
############### Finished ############
############### Finished ###############
########################################
# Basic Samples
# ###################################
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/StartupWindow)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Triangle)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Texture)
Expand All @@ -76,7 +79,9 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Normal)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/MipMapVisual)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/ShadowMapping)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/ShadowPointLight)

# ###################################
# Advanced Samples
# ###################################
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/GameOfLife)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Fog)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/MultiPass)
Expand Down Expand Up @@ -126,13 +131,13 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Mandelbrot)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/ReactionDiffusion)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/ComputeGroupVisual)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/MarchingCube)

############## Work In Progress ####################
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/VectorField)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/VectorField2D)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/OpticalFlow)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/MarchingCube)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/InfinateWorld)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/RayTracing)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Sort)
Expand Down Expand Up @@ -165,20 +170,27 @@ FIND_PROGRAM(GLSLC glslc)
FOREACH(GLSL ${GLSL_SOURCE_FILES})
GET_FILENAME_COMPONENT(FILE_NAME ${GLSL} ABSOLUTE)

IF(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(SPIRV_BUILD_SETTINGS -O)
ELSE()
SET(SPIRV_BUILD_SETTINGS -g -Od)
ENDIF()

#glslangValidator
SET(SPIRV "${FILE_NAME}.spv")
IF(GLSLLANGVALIDATOR)
IF(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(SPIRV_BUILD_SETTINGS "")
ELSE()
SET(SPIRV_BUILD_SETTINGS -g -Od)
ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${EXECUTABLE_OUTPUT_PATH}/Shaders/"
COMMAND ${GLSLLANGVALIDATOR} -Dgl_InstanceID=gl_InstanceIndex -Dgl_VertexID=gl_VertexIndex -I${CMAKE_CURRENT_SOURCE_DIR}/Shaders/common --target-env vulkan1.1 ${SPIRV_BUILD_SETTINGS} -o ${SPIRV} ${GLSL}
DEPENDS ${GLSL})
ELSEIF(GLSLC)
IF(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(SPIRV_BUILD_SETTINGS -O)
ELSE()
SET(SPIRV_BUILD_SETTINGS -g -Od)
ENDIF()

ADD_CUSTOM_COMMAND(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${EXECUTABLE_OUTPUT_PATH}/Shaders/"
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ Usage:
- [**Point Lights**](Samples/PointLight)
- ![PointLights](https://github.com/voldien/OpenGL-Samples/assets/9608088/dcd67197-4dc9-4333-ae6f-9fff9f7eb317)

- **Area Lights**

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

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

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

- **Refrection**

- **Simple Reflection**

- [**Instance**](Samples/Instance)
Expand All @@ -68,8 +65,6 @@ Usage:
![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)

- **Fog**

- **Terrain**

- **Shadow Map**
Expand All @@ -84,39 +79,50 @@ Usage:
- **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 Volume**


- **Cascading Shadow**


- **Contact Shadow**


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


- **Grass**


- **MipMap Visual**

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

- **Multipass**

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

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

- [**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**

- **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)

Expand All @@ -132,24 +138,29 @@ Usage:
- **Ray Tracing**

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

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


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

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

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

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

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

- **Support Vector Machine**

- **Compute Group Visual**

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


- **Rigidbody**

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


Expand Down
21 changes: 10 additions & 11 deletions Samples/AmbientOcclusion/AmbientOcclusion.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "GLUIComponent.h"
#include "Scene.h"
#include "imgui.h"
#include <GL/glew.h>
Expand All @@ -23,8 +24,7 @@ namespace glsample {
this->setTitle("ScreenSpace AmbientOcclusion");

/* Setting Window. */
this->ambientOcclusionSettingComponent =
std::make_shared<AmbientOcclusionSettingComponent>(this->uniformStageBlockSSAO);
this->ambientOcclusionSettingComponent = std::make_shared<AmbientOcclusionSettingComponent>(*this);
this->addUIComponent(this->ambientOcclusionSettingComponent);

/* Default camera position and orientation. */
Expand Down Expand Up @@ -103,19 +103,18 @@ namespace glsample {

CameraController camera;

class AmbientOcclusionSettingComponent : public nekomimi::UIComponent {
class AmbientOcclusionSettingComponent : public GLUIComponent<ScreenSpaceAmbientOcclusion> {
public:
AmbientOcclusionSettingComponent(struct UniformSSAOBufferBlock &uniform) : uniform(uniform) {
this->setName("Ambient Occlusion Settings");
}
AmbientOcclusionSettingComponent(ScreenSpaceAmbientOcclusion &base)
: GLUIComponent<ScreenSpaceAmbientOcclusion>(base, "Ambient Occlusion Settings") {}

void draw() override {

ImGui::TextUnformatted("Ambient Occlusion Settings");
ImGui::DragFloat("Intensity", &this->uniform.intensity, 0.1f, 0.0f);
ImGui::DragFloat("Radius", &this->uniform.radius, 0.35f, 0.0f);
ImGui::DragInt("Sample", &this->uniform.samples, 1, 0);
ImGui::DragFloat("Bias", &this->uniform.bias, 0.01f, 0, 1);
ImGui::DragFloat("Intensity", &this->getRefSample().uniformStageBlockSSAO.intensity, 0.1f, 0.0f);
ImGui::DragFloat("Radius", &this->getRefSample().uniformStageBlockSSAO.radius, 0.35f, 0.0f);
ImGui::DragInt("Sample", &this->getRefSample().uniformStageBlockSSAO.samples, 1, 0);
ImGui::DragFloat("Bias", &this->getRefSample().uniformStageBlockSSAO.bias, 0.01f, 0, 1);
ImGui::Checkbox("DownSample", &this->downScale);
ImGui::Checkbox("Use Depth Only", &this->useDepthOnly);

Expand All @@ -134,7 +133,7 @@ namespace glsample {
bool useAO = true;

private:
struct UniformSSAOBufferBlock &uniform;
//struct UniformSSAOBufferBlock &uniform;
};
std::shared_ptr<AmbientOcclusionSettingComponent> ambientOcclusionSettingComponent;

Expand Down
19 changes: 10 additions & 9 deletions Samples/BillBoarding/BillBoarding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ namespace glsample {
glm::mat4 ViewProj;
glm::mat4 modelViewProjection;

glm::vec4 tintColor = glm::vec4(1, 1, 1, 0.8f);

/* light source. */
glm::vec4 direction = glm::vec4(1.0f / sqrt(2.0f), -1.0f / sqrt(2.0f), 0.0f, 0.0f);
glm::vec4 lightColor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glm::vec4 ambientLight = glm::vec4(0.4, 0.4, 0.4, 1.0f);

/* */
glm::vec4 tintColor = glm::vec4(1, 1, 1, 0.8f);

/* */
glm::vec4 cameraPosition;
Expand Down Expand Up @@ -79,13 +79,14 @@ namespace glsample {
}

void draw() override {
ImGui::ColorEdit4("Tint", &this->uniform.tintColor[0],
ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_Float);

ImGui::TextUnformatted("Light Setting");
ImGui::ColorEdit4("Light", &this->uniform.lightColor[0],
ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_Float);
ImGui::DragFloat3("Direction", &this->uniform.direction[0]);
ImGui::ColorEdit4("Ambient", &this->uniform.ambientLight[0],

ImGui::TextUnformatted("Material Setting");
ImGui::ColorEdit4("Tint", &this->uniform.tintColor[0],
ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_Float);

ImGui::TextUnformatted("BillBoarding Setting");
Expand Down Expand Up @@ -244,6 +245,8 @@ namespace glsample {
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(ProceduralGeometry::Vertex), vertices.data(),
GL_STATIC_DRAW);

this->billboard.nrVertices = vertices.size();

/* Vertex. */
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ProceduralGeometry::Vertex), nullptr);
Expand Down Expand Up @@ -322,7 +325,7 @@ namespace glsample {

/* Draw triangle. */
glBindVertexArray(this->billboard.vao);
glDrawElements(GL_POINTS, this->billboard.nrIndicesElements, GL_UNSIGNED_INT, nullptr);
glDrawArrays(GL_POINTS, 0, this->billboard.nrVertices);
glBindVertexArray(0);
}

Expand All @@ -338,8 +341,6 @@ namespace glsample {
/* */
this->uniformStageBuffer.proj = this->camera.getProjectionMatrix();
this->uniformStageBuffer.model = glm::mat4(1.0f);
this->uniformStageBuffer.model =
glm::rotate(this->uniformStageBuffer.model, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
this->uniformStageBuffer.model = glm::scale(this->uniformStageBuffer.model, glm::vec3(0.95f));
this->uniformStageBuffer.view = this->camera.getViewMatrix();
this->uniformStageBuffer.modelViewProjection =
Expand Down
Loading

0 comments on commit 554cac5

Please sign in to comment.