diff --git a/projects/voxelization/resources/shaders/shader.frag b/projects/voxelization/resources/shaders/shader.frag index edafc8c0077416cb57aedc4e7358126846507e18..def0ea0c981a5c246c3bc384c34dfcb639aeac54 100644 --- a/projects/voxelization/resources/shaders/shader.frag +++ b/projects/voxelization/resources/shaders/shader.frag @@ -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 diff --git a/projects/voxelization/src/main.cpp b/projects/voxelization/src/main.cpp index ec8153e735553e26f3b1b2cafe06950398bb5308..1fecb63eeff8bb558b6cdf84af3f788a694841b2 100644 --- a/projects/voxelization/src/main.cpp +++ b/projects/voxelization/src/main.cpp @@ -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();