diff --git a/res/engine/shaders/fancy.frag b/res/engine/shaders/fancy.frag index 7f3bdeb..3c8a7b2 100644 --- a/res/engine/shaders/fancy.frag +++ b/res/engine/shaders/fancy.frag @@ -48,7 +48,7 @@ void main() { float light_distance = length(fragLightPosTangentSpace - fragPosTangentSpace); float attenuation = 1.0 / (1.0 + 0.09 * light_distance + 0.032 * (light_distance * light_distance)); - light_colour *= 5.0 * attenuation; + //light_colour *= 5.0 * attenuation; const vec3 emission = vec3(0.0, 0.0, 0.0); @@ -56,7 +56,7 @@ void main() { const vec3 N = GetNormal(); const vec3 V = normalize(fragViewPosTangentSpace - fragPosTangentSpace); - const vec3 L = normalize(fragLightPosTangentSpace - fragPosTangentSpace); + const vec3 L = normalize(fragLightPosTangentSpace /* - fragPosTangentSpace */ ); //const vec3 L = normalize(vec3(5.0, 0.0, 3.0)); const vec3 H = normalize(V + L); diff --git a/res/engine/shaders/fancy.vert b/res/engine/shaders/fancy.vert index fcaa88e..6636c45 100644 --- a/res/engine/shaders/fancy.vert +++ b/res/engine/shaders/fancy.vert @@ -39,8 +39,8 @@ void main() { fragUV = inUV; fragPosTangentSpace = worldToTangentSpace * vec3(worldPosition); fragViewPosTangentSpace = worldToTangentSpace * vec3(inverse(frameSetUniformBuffer.view) * vec4(0.0, 0.0, 0.0, 1.0)); - //fragLightPosTangentSpace = worldToTangentSpace * vec3(-0.4278,0.7923,0.43502); - fragLightPosTangentSpace = worldToTangentSpace * vec3(10.0, 0.0, 10.0); + fragLightPosTangentSpace = worldToTangentSpace * vec3(-0.4278,0.7923,0.43502); // directional light + //fragLightPosTangentSpace = worldToTangentSpace * vec3(10.0, 0.0, 10.0); fragNormWorldSpace = N; fragViewPosWorldSpace = vec3(inverse(frameSetUniformBuffer.view) * vec4(0.0, 0.0, 0.0, 1.0)); diff --git a/src/gfx_device_vulkan.cpp b/src/gfx_device_vulkan.cpp index 50f7e1f..f988e7b 100644 --- a/src/gfx_device_vulkan.cpp +++ b/src/gfx_device_vulkan.cpp @@ -72,7 +72,7 @@ static constexpr uint32_t FRAMES_IN_FLIGHT = 2; // This improved FPS by 5x static constexpr size_t PUSH_CONSTANT_MAX_SIZE = 128; // bytes static constexpr VkIndexType INDEX_TYPE = VK_INDEX_TYPE_UINT32; -static constexpr int kShadowmapSize = 1024; +static constexpr int kShadowmapSize = 2048; // structures and enums diff --git a/src/renderer.cpp b/src/renderer.cpp index e550cfc..6ff15e0 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -32,12 +32,12 @@ Renderer::Renderer(Application& app, gfx::GraphicsSettings settings) : Applicati } global_uniform.layout = device_->CreateDescriptorSetLayout(globalSetBindings); global_uniform.set = device_->AllocateDescriptorSet(global_uniform.layout); - // const glm::vec3 light_location = glm::vec3{-0.4278, 0.7923, 0.43502} * 10.0f; - const glm::vec3 light_location = glm::vec3{10.0f, 0.0f, 10.0f}; - // const glm::mat4 light_proj = glm::orthoRH_ZO(-10.0f, 10.0f, -10.0f, 10.0f, 1.0f, 50.0f); - const glm::mat4 light_proj = glm::perspectiveFovRH_ZO(glm::radians(90.0f), 1.0f, 1.0f, 5.0f, 50.0f); + const glm::vec3 light_location = glm::vec3{-0.4278, 0.7923, 0.43502} * 40.0f; + //const glm::vec3 light_location = glm::vec3{10.0f, 0.0f, 10.0f}; + const glm::mat4 light_proj = glm::orthoRH_ZO(-24.0f, 24.0f, -15.0f, 15.0f, 10.0f, 65.0f); + //const glm::mat4 light_proj = glm::perspectiveFovRH_ZO(glm::radians(90.0f), 1.0f, 1.0f, 5.0f, 50.0f); const glm::mat4 light_view = glm::lookAtRH(light_location, glm::vec3{0.0f, 0.0f, 0.0f}, glm::vec3{0.0f, 0.0f, 1.0f}); - global_uniform.uniform_buffer_data.data.proj = glm::mat4{1.0f}; + global_uniform.uniform_buffer_data.data.proj = light_proj; global_uniform.uniform_buffer_data.data.lightSpaceMatrix = light_proj * light_view; global_uniform.uniform_buffer = device_->CreateUniformBuffer(sizeof(global_uniform.uniform_buffer_data), &global_uniform.uniform_buffer_data); device_->UpdateDescriptorUniformBuffer(global_uniform.set, 0, global_uniform.uniform_buffer, 0, sizeof(global_uniform.uniform_buffer_data)); diff --git a/test/src/game.cpp b/test/src/game.cpp index 159d7ec..0e6a49f 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -77,6 +77,11 @@ void PlayGame(GameSettings settings) /* create camera */ engine::Entity camera = main_scene->CreateEntity("camera"); + auto camren = main_scene->AddComponent(camera); + camren->visible = true; + camren->mesh = GenSphereMesh(app.renderer()->GetDevice(), 0.2f, 10); + camren->material = app.GetResource("builtin.default"); + /* as of right now, the entity with tag 'camera' is used to build the view * matrix */