mirror of
https://github.com/redstrate/Novus.git
synced 2025-06-08 06:07:46 +00:00
Make lighting work (finally)
Now it can display a directional light source, albeit in a tiny hardcoded size. Time to clean up my mess!
This commit is contained in:
parent
eb9e5dc094
commit
7bba79f62f
2 changed files with 14 additions and 6 deletions
|
@ -89,7 +89,7 @@ private:
|
||||||
glm::mat3x4 m_InverseViewMatrix;
|
glm::mat3x4 m_InverseViewMatrix;
|
||||||
glm::mat4 m_ViewProjectionMatrix;
|
glm::mat4 m_ViewProjectionMatrix;
|
||||||
glm::mat4 m_InverseViewProjectionMatrix;
|
glm::mat4 m_InverseViewProjectionMatrix;
|
||||||
glm::mat4 m_InverseProjectionMatrix;
|
glm::mat4 m_InverseProjectionMatrix; // used for view position recalc
|
||||||
glm::mat4 m_ProjectionMatrix; // FIXME: ourburos is wrong, this is actually viewProjection
|
glm::mat4 m_ProjectionMatrix; // FIXME: ourburos is wrong, this is actually viewProjection
|
||||||
glm::mat4 m_MainViewToProjectionMatrix;
|
glm::mat4 m_MainViewToProjectionMatrix;
|
||||||
glm::vec3 m_EyePosition;
|
glm::vec3 m_EyePosition;
|
||||||
|
|
|
@ -130,7 +130,7 @@ RenderSystem::RenderSystem(Renderer &renderer, GameData *data)
|
||||||
g_LightParam = createUniformBuffer(sizeof(LightParam));
|
g_LightParam = createUniformBuffer(sizeof(LightParam));
|
||||||
|
|
||||||
LightParam lightParam{};
|
LightParam lightParam{};
|
||||||
lightParam.m_Position = glm::vec4(5);
|
lightParam.m_Position = glm::vec4(-5);
|
||||||
lightParam.m_Direction = glm::normalize(glm::vec4(0) - lightParam.m_Position);
|
lightParam.m_Direction = glm::normalize(glm::vec4(0) - lightParam.m_Position);
|
||||||
lightParam.m_DiffuseColor = glm::vec4(1);
|
lightParam.m_DiffuseColor = glm::vec4(1);
|
||||||
lightParam.m_SpecularColor = glm::vec4(1);
|
lightParam.m_SpecularColor = glm::vec4(1);
|
||||||
|
@ -146,7 +146,12 @@ RenderSystem::RenderSystem(Renderer &renderer, GameData *data)
|
||||||
g_CommonParameter = createUniformBuffer(sizeof(CommonParameter));
|
g_CommonParameter = createUniformBuffer(sizeof(CommonParameter));
|
||||||
|
|
||||||
CommonParameter commonParam{};
|
CommonParameter commonParam{};
|
||||||
commonParam.m_RenderTarget = {640.0f, 480.0f, 0.0f, 0.0f}; // used to convert screen-space coordinates back into 0.0-1.0
|
/*commonParam.m_RenderTarget = {1640.0f / 2.0f,
|
||||||
|
480.0f / 2.0f,
|
||||||
|
640.0f / 2.0,
|
||||||
|
480.0f / 2.0}; // used to convert screen-space coordinates back into 0.0-1.0
|
||||||
|
*/
|
||||||
|
commonParam.m_RenderTarget = {1.0f / 640.0f, 1.0f / 480.0f, 0.0f, 0.0f}; // used to convert screen-space coordinates back into 0.0-1.0
|
||||||
|
|
||||||
copyDataToUniform(g_CommonParameter, &commonParam, sizeof(CommonParameter));
|
copyDataToUniform(g_CommonParameter, &commonParam, sizeof(CommonParameter));
|
||||||
}
|
}
|
||||||
|
@ -172,9 +177,12 @@ void RenderSystem::render(uint32_t imageIndex, VkCommandBuffer commandBuffer)
|
||||||
cameraParameter.m_InverseViewMatrix = glm::transpose(glm::inverse(viewMatrix));
|
cameraParameter.m_InverseViewMatrix = glm::transpose(glm::inverse(viewMatrix));
|
||||||
cameraParameter.m_ViewProjectionMatrix = glm::transpose(viewProjectionMatrix);
|
cameraParameter.m_ViewProjectionMatrix = glm::transpose(viewProjectionMatrix);
|
||||||
cameraParameter.m_InverseViewProjectionMatrix = glm::transpose(glm::inverse(viewProjectionMatrix));
|
cameraParameter.m_InverseViewProjectionMatrix = glm::transpose(glm::inverse(viewProjectionMatrix));
|
||||||
cameraParameter.m_InverseProjectionMatrix = glm::transpose(glm::inverse(projectionMatrix));
|
|
||||||
cameraParameter.m_ProjectionMatrix = cameraParameter.m_ViewProjectionMatrix;
|
// known params
|
||||||
cameraParameter.m_MainViewToProjectionMatrix = cameraParameter.m_InverseViewProjectionMatrix;
|
cameraParameter.m_InverseProjectionMatrix = glm::transpose(glm::inverse(viewProjectionMatrix));
|
||||||
|
cameraParameter.m_ProjectionMatrix = glm::transpose(viewProjectionMatrix);
|
||||||
|
|
||||||
|
cameraParameter.m_MainViewToProjectionMatrix = glm::transpose(glm::inverse(projectionMatrix));
|
||||||
cameraParameter.m_EyePosition = glm::vec3(5.0f); // placeholder
|
cameraParameter.m_EyePosition = glm::vec3(5.0f); // placeholder
|
||||||
cameraParameter.m_LookAtVector = glm::vec3(0.0f); // placeholder
|
cameraParameter.m_LookAtVector = glm::vec3(0.0f); // placeholder
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue