Skip to content
Snippets Groups Projects
Commit e7d8aaf5 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#81] Add sun color and brightness to UI

parent 18a5ce25
No related branches found
No related tags found
1 merge request!68Resolve "Complete Voxelization"
......@@ -11,7 +11,9 @@ layout(location = 2) in vec3 passPos;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=0) uniform sunBuffer {
vec3 L; float padding;
vec3 L; float padding;
vec3 sunColor;
float sunStrength;
mat4 lightMatrix;
};
layout(set=0, binding=1) uniform texture2D shadowMap;
......@@ -35,11 +37,10 @@ float shadowTest(vec3 worldPos){
}
void main() {
vec3 N = normalize(passNormal);
vec3 sunColor = vec3(1);
vec3 sun = sunColor * clamp(dot(N, L), 0, 1);
sun *= shadowTest(passPos);
vec3 ambient = vec3(0.1);
vec3 albedo = texture(sampler2D(albedoTexture, textureSampler), passUV).rgb;
outColor = albedo * (sun + ambient);
vec3 N = normalize(passNormal);
vec3 sun = sunStrength * sunColor * clamp(dot(N, L), 0, 1);
sun *= shadowTest(passPos);
vec3 ambient = vec3(0.1);
vec3 albedo = texture(sampler2D(albedoTexture, textureSampler), passUV).rgb;
outColor = albedo * (sun + ambient);
}
\ No newline at end of file
......@@ -13,8 +13,8 @@
int main(int argc, const char** argv) {
const char* applicationName = "Voxelization";
uint32_t windowWidth = 800;
uint32_t windowHeight = 600;
uint32_t windowWidth = 1280;
uint32_t windowHeight = 720;
vkcv::Window window = vkcv::Window::create(
applicationName,
......@@ -156,9 +156,11 @@ int main(int argc, const char** argv) {
// light info buffer
struct LightInfo {
glm::vec3 direction;
float padding;
glm::mat4 lightMatrix;
glm::vec3 direction;
float padding;
glm::vec3 sunColor = glm::vec3(1.f);
float sunStrength = 1.f;
glm::mat4 lightMatrix;
};
LightInfo lightInfo;
vkcv::Buffer lightBuffer = core.createBuffer<LightInfo>(vkcv::BufferType::UNIFORM, sizeof(glm::vec3));
......@@ -449,7 +451,9 @@ int main(int argc, const char** argv) {
gui.beginGUI();
ImGui::Begin("Settings");
ImGui::DragFloat2("Light angles", &lightAngles.x);
ImGui::DragFloat2("Light angles", &lightAngles.x);
ImGui::ColorEdit3("Sun color", &lightInfo.sunColor.x);
ImGui::DragFloat("Sun strength", &lightInfo.sunStrength);
ImGui::End();
gui.endGUI();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment