Skip to content

Commit 5de81af

Browse files
committed
fixed bug where light of the sun was not affected by the transmiatance of the atmosphere
1 parent 9189d76 commit 5de81af

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Internal/Application/ApplicationState/ApplicationState.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ AtmosphereParameters* ApplicationState::GetAtmosphereParameters()
117117
void ApplicationState::pSetAtmosphereParameters(AtmosphereParameters* pAtmosphereParams)
118118
{
119119
m_atmosphereParams = pAtmosphereParams;
120-
// TODO: for now i dont know of better place to tell renderer that it should attenuate sun based on the zenith angle
121-
m_globalRenderingInfo->accountForAtmosphereTransmitance = static_cast<bool>(pAtmosphereParams->booleans.z);
122-
// camera position in global data is going to be bottom sphere radius
123-
m_globalRenderingInfo->atmosphereParams.x = pAtmosphereParams->groundAlbedo.w;
124-
m_globalRenderingInfo->atmosphereParams.y = pAtmosphereParams->rayleighScattering.w;
125-
126-
// for the new packed type
127-
m_globalRenderingData2->atmosphereParams.x = pAtmosphereParams->groundAlbedo.w; // top radius
128-
m_globalRenderingData2->atmosphereParams.y = pAtmosphereParams->rayleighScattering.w; // botom radius
129-
m_globalRenderingData2->atmosphereParams.z = static_cast<bool>(pAtmosphereParams->booleans.z); // account for transmitance in the light calculations
130120
}
131121

132122
void ApplicationState::pSetGlobalRenderingInfoData2(GlobalRenderingInfo2* pGlobalRenderingInfo)

Internal/Application/Client.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,17 @@ void Client::UpdateCamera(CameraUpdateInfo& cameraUpdateInfo)
150150
m_globalRenderingData2.inverseProj = m_camera->GetinverseProjectionMatrix();
151151

152152

153-
m_globalRenderingData2.atmosphereParams = glm::vec4(0);
153+
154+
if(m_applicationState->GetAtmosphereParameters()){
155+
auto ap = m_applicationState->GetAtmosphereParameters();
156+
m_globalRenderingData2.atmosphereParams = glm::vec4(
157+
ap->groundAlbedo.w,
158+
ap->rayleighScattering.w,
159+
static_cast<bool>(ap->booleans.z),
160+
0.0
161+
);
162+
}
163+
154164
m_globalRenderingData2.cameraPosition = glm::vec4(m_camera->GetPosition(), m_camera->GetFOVRad());
155165

156166
//========================

Internal/Vulkan/Utils/VUniformBufferManager/UnifromsRegistry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct GlobalRenderingInfo2
5757
glm::mat4 viewPrevFrame = glm::mat4(1.0);
5858
glm::mat4 projPrevFrame = glm::mat4(1.0);
5959

60-
glm::vec4 atmosphereParams;
60+
glm::vec4 atmosphereParams; // x - bottom radius , y - top radius, z - account for scattering
6161
glm::vec4 cameraPosition;
6262
glm::vec4 viewParams; // x - image plane distance, y - focal length, z - near plane, w -far plane
6363
glm::vec4 viewParams2; // x - FOV, y - aspect ratio, z - aparature size, w -cameraType

0 commit comments

Comments
 (0)