Skip to content

Commit

Permalink
Added color space converter, improvement and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
voldien committed Jan 1, 2025
1 parent dff27f5 commit 9f47c2c
Show file tree
Hide file tree
Showing 115 changed files with 1,960 additions and 692 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/PhysicalBasedRendering)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Subgroup)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/ShadowVolume)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/SimpleOcean)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/SimpleReflection)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/SimpleOcean)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Ocean)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/Terrain)

ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/Samples/SkinnedMesh)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Valdemar Lindberg
Copyright (c) 2024 Valdemar Lindberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 11 additions & 11 deletions Samples/Instance/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ namespace glsample {
}

struct uniform_buffer_block {
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
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.0f, 0.0f);
glm::vec4 lightColor = glm::vec4(1.0f);

glm::vec4 ambientColor = glm::vec4(0.15f, 0.15f, 0.15f, 1.0f);
glm::vec4 specularColor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glm::vec4 viewPos;
glm::vec4 viewPos{};

float shininess = 16.0f;
} uniformData;
Expand All @@ -53,18 +53,18 @@ namespace glsample {
MeshObject instanceGeometry;

/* */
unsigned int diffuse_texture;
unsigned int diffuse_texture{};
/* */
unsigned int instance_program;
unsigned int instance_program{};

/* Instance buffer model matrix. */
unsigned int instance_model_buffer;
unsigned int instance_model_buffer{};

/* */
unsigned int uniform_buffer_binding = 0;
unsigned int uniform_instance_buffer_binding = 1;
unsigned int uniform_mvp_buffer;
unsigned int uniform_instance_buffer;
unsigned int uniform_mvp_buffer{};
unsigned int uniform_instance_buffer{};
const size_t nrUniformBuffers = 3;

size_t uniformSharedBufferSize = sizeof(uniform_buffer_block);
Expand Down
18 changes: 3 additions & 15 deletions Samples/ModelViewer/ModelViewer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ModelViewer.h"
#include "ImageImport.h"
#include "ModelImporter.h"
#include "Skybox.h"
#include <GL/glew.h>
#include <GLSample.h>
#include <GLSampleWindow.h>
Expand Down Expand Up @@ -40,11 +41,6 @@ namespace glsample {
const std::vector<uint32_t> pbr_evolution_binary =
IOUtil::readFileData<uint32_t>(this->PBREvoluationShaderPath, this->getFileSystem());

const std::vector<uint32_t> vertex_skybox_binary =
IOUtil::readFileData<uint32_t>(this->vertexSkyboxPanoramicShaderPath, this->getFileSystem());
const std::vector<uint32_t> fragment_skybox_binary =
IOUtil::readFileData<uint32_t>(this->fragmentSkyboxPanoramicShaderPath, this->getFileSystem());

/* Setup compiler convert options. */
fragcore::ShaderCompiler::CompilerConvertOption compilerOptions;
compilerOptions.target = fragcore::ShaderLanguage::GLSL;
Expand All @@ -56,20 +52,12 @@ namespace glsample {
&pbr_control_binary, &pbr_evolution_binary);

/* Create skybox graphic pipeline program. */
this->skybox_program =
ShaderLoader::loadGraphicProgram(compilerOptions, &vertex_skybox_binary, &fragment_skybox_binary);
this->skybox_program = Skybox::loadDefaultProgram(this->getFileSystem());
}

/* Setup graphic pipeline. */
glUseProgram(this->skybox_program);
int uniform_buffer_index = glGetUniformBlockIndex(this->skybox_program, "UniformBufferBlock");
glUniformBlockBinding(this->skybox_program, uniform_buffer_index, 0);
glUniform1i(glGetUniformLocation(this->skybox_program, "PanoramaTexture"), 0);
glUseProgram(0);

/* Setup graphic pipeline. */
glUseProgram(this->physical_based_rendering_program);
uniform_buffer_index = glGetUniformBlockIndex(this->physical_based_rendering_program, "UniformBufferBlock");
int uniform_buffer_index = glGetUniformBlockIndex(this->physical_based_rendering_program, "UniformBufferBlock");

glUniform1i(glGetUniformLocation(this->physical_based_rendering_program, "albedoMap"), 0);
glUniform1i(glGetUniformLocation(this->physical_based_rendering_program, "normalMap"), 1);
Expand Down
54 changes: 17 additions & 37 deletions Samples/ModelViewer/ModelViewer.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "SampleHelper.h"
#include "Scene.h"
#include "Skybox.h"
#include "Util/CameraController.h"
#include <GL/glew.h>
#include <GLSample.h>
#include <GLSampleWindow.h>
#include <ShaderLoader.h>
#include <Util/CameraController.h>

namespace glsample {

Expand All @@ -16,26 +16,11 @@ namespace glsample {
public:
ModelViewer();

struct point_light {
glm::vec3 position;
float range;
glm::vec4 color;
float intensity;
float constant_attenuation;
float linear_attenuation;
float quadratic_attenuation;
};

struct light_settings {
glm::vec4 ambientColor;
glm::vec4 specularColor;
glm::vec4 direction;
glm::vec4 lightColor;
/* */
struct point_light pointLights[4];

float gamma;
float exposure;
DirectionalLight directionalLight;
/* */
PointLightInstance pointLights[4];
};
struct camera_settings {
glm::vec4 gEyeWorldPos;
Expand All @@ -47,17 +32,17 @@ namespace glsample {
};

struct uniform_buffer_block {
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
glm::mat4 viewProjection;
glm::mat4 modelViewProjection;
glm::mat4 model{};
glm::mat4 view{};
glm::mat4 proj{};
glm::mat4 modelView{};
glm::mat4 viewProjection{};
glm::mat4 modelViewProjection{};

struct light_settings lightsettings;
struct tessellation_settings tessellation;
/* Camera settings. */
struct camera_settings camera;
struct camera_settings camera{};

} uniformStageBuffer;

Expand All @@ -74,10 +59,6 @@ namespace glsample {
const size_t nrUniformBuffer = 3;
size_t uniformAlignBufferSize = sizeof(uniform_buffer_block);

/* Skybox. */
const std::string vertexSkyboxPanoramicShaderPath = "Shaders/skybox/skybox.vert.spv";
const std::string fragmentSkyboxPanoramicShaderPath = "Shaders/skybox/panoramic.frag.spv";

/* Advanced. */
const std::string PBRvertexShaderPath = "Shaders/pbr/physicalbasedrendering.vert.spv";
const std::string PBRfragmentShaderPath = "Shaders/pbr/physicalbasedrendering.frag.spv";
Expand All @@ -98,6 +79,7 @@ namespace glsample {
// ImGui::ColorEdit4("Ambient", &this->uniform.ambientColor[0],
// ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_Float);
// ImGui::DragFloat3("Direction", &this->uniform.direction[0]);

ImGui::TextUnformatted("Light Settings");
for (size_t i = 0;
i < sizeof(uniform.lightsettings.pointLights) / sizeof(uniform.lightsettings.pointLights[0]);
Expand All @@ -118,13 +100,11 @@ namespace glsample {
}

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

ImGui::DragFloat("Exposure", &this->uniform.lightsettings.exposure);
ImGui::DragFloat("Gamma", &this->uniform.lightsettings.gamma);
// ImGui::ColorEdit4("Color", &this->uniform.lightsettings.lightColor[0],
// ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR);
// ImGui::ColorEdit4("Ambient Color", &this->uniform.lightsettings.ambientColor[0],
// ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_Float);
// ImGui::DragFloat3("Direction", &this->uniform.lightsettings.direction[0]);

ImGui::TextUnformatted("Tessellation");
ImGui::DragFloat("Displacement", &this->uniform.tessellation.gDispFactor, 1, 0.0f, 100.0f);
Expand Down
18 changes: 9 additions & 9 deletions Samples/NormalMapping/NormalMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ namespace glsample {
this->addUIComponent(this->normalMapSettingComponent);

/* Default camera position and orientation. */
this->camera.setPosition(glm::vec3(-2.5f));
this->camera.setPosition(glm::vec3(20.5f));
this->camera.lookAt(glm::vec3(0.f));
}

struct uniform_buffer_block {
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
glm::mat4 ViewProj;
glm::mat4 modelViewProjection;
glm::mat4 model{};
glm::mat4 view{};
glm::mat4 proj{};
glm::mat4 modelView{};
glm::mat4 ViewProj{};
glm::mat4 modelViewProjection{};

/* */
glm::vec4 tintColor = glm::vec4(1, 1, 1, 1);
Expand All @@ -51,11 +51,11 @@ namespace glsample {
Scene scene; /* World Scene. */

/* */
unsigned int normalMapping_program;
unsigned int normalMapping_program{};

/* Uniform buffer. */
unsigned int uniform_buffer_binding = 0;
unsigned int uniform_buffer;
unsigned int uniform_buffer{};
const size_t nrUniformBuffer = 3;
size_t uniformAlignBufferSize = sizeof(uniform_buffer_block);

Expand Down
20 changes: 10 additions & 10 deletions Samples/OcclusionCulling/OcclusionCulling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ namespace glsample {
}

struct uniform_buffer_block {
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
glm::mat4 modelView;
glm::mat4 ViewProj;
glm::mat4 modelViewProjection;
glm::mat4 model{};
glm::mat4 view{};
glm::mat4 proj{};
glm::mat4 modelView{};
glm::mat4 ViewProj{};
glm::mat4 modelViewProjection{};

/* */
glm::vec4 tintColor = glm::vec4(1, 1, 1, 1);
Expand All @@ -62,15 +62,15 @@ namespace glsample {
ConditionalScene scene;

/* Textures. */
unsigned int diffuse_texture;
unsigned int normal_texture;
unsigned int diffuse_texture{};
unsigned int normal_texture{};

/* */
unsigned int normalMapping_program;
unsigned int normalMapping_program{};

/* Uniform buffer. */
unsigned int uniform_buffer_binding = 0;
unsigned int uniform_buffer;
unsigned int uniform_buffer{};
const size_t nrUniformBuffer = 3;
size_t uniformAlignBufferSize = sizeof(uniform_buffer_block);

Expand Down
Loading

0 comments on commit 9f47c2c

Please sign in to comment.