Add some docs

This commit is contained in:
Vincent Lejeune 2014-12-31 21:46:28 +01:00
parent 8c4b2862c0
commit 1985f188a3
5 changed files with 35 additions and 21 deletions

View File

@ -725,7 +725,8 @@ public:
void renderScene(scene::ICameraSceneNode * const camnode, unsigned pointlightcount, std::vector<GlowData>& glows, float dt, bool hasShadows, bool forceRTT);
unsigned UpdateLightsInfo(scene::ICameraSceneNode * const camnode, float dt);
void UpdateSplitAndLightcoordRangeFromComputeShaders(size_t width, size_t height);
void computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height);
void computeMatrixesAndCameras(scene::ICameraSceneNode * const camnode, size_t width, size_t height);
void uploadLightingData();
// --------------------- OLD RTT --------------------
/**

View File

@ -182,8 +182,9 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_PUSH_CPU_MARKER("Update Light Info", 0xFF, 0x0, 0x0);
unsigned plc = UpdateLightsInfo(camnode, dt);
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Compute camera matrix", 0x0, 0xFF, 0x0);
computeCameraMatrix(camnode, viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
PROFILER_PUSH_CPU_MARKER("UBO upload", 0x0, 0xFF, 0x0);
computeMatrixesAndCameras(camnode, viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
uploadLightingData();
PROFILER_POP_CPU_MARKER();
renderScene(camnode, plc, glows, dt, track->hasShadows(), false);

View File

@ -106,6 +106,27 @@ unsigned IrrDriver::UpdateLightsInfo(scene::ICameraSceneNode * const camnode, fl
return lightnum;
}
/** Upload lighting info to the dedicated uniform buffer
*/
void IrrDriver::uploadLightingData()
{
float Lighting[36];
Lighting[0] = m_sundirection.X;
Lighting[1] = m_sundirection.Y;
Lighting[2] = m_sundirection.Z;
Lighting[4] = m_suncolor.getRed();
Lighting[5] = m_suncolor.getGreen();
Lighting[6] = m_suncolor.getBlue();
Lighting[7] = 0.54f;
memcpy(&Lighting[8], blueSHCoeff, 9 * sizeof(float));
memcpy(&Lighting[17], greenSHCoeff, 9 * sizeof(float));
memcpy(&Lighting[26], redSHCoeff, 9 * sizeof(float));
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::LightingDataUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, 36 * sizeof(float), Lighting);
}
void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
{
//RH

View File

@ -319,8 +319,9 @@ FrameBuffer* RTT::render(scene::ICameraSceneNode* camera, float dt)
std::vector<IrrDriver::GlowData> glows;
// TODO: put this outside of the rendering loop
irr_driver->generateDiffuseCoefficients();
irr_driver->computeCameraMatrix(camera, m_width, m_height);
irr_driver->computeMatrixesAndCameras(camera, m_width, m_height);
unsigned plc = irr_driver->UpdateLightsInfo(camera, dt);
irr_driver->uploadLightingData();
irr_driver->renderScene(camera, plc, glows, dt, false, true);
FrameBuffer* frame_buffer = irr_driver->getPostProcessing()->render(camera, false);

View File

@ -213,7 +213,13 @@ void IrrDriver::UpdateSplitAndLightcoordRangeFromComputeShaders(size_t width, si
}
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
/** Generate View, Projection, Inverse View, Inverse Projection, ViewProjection and InverseProjection matrixes
and matrixes and cameras for the four shadow cascade and RSM.
* \param camnode point of view used
* \param width of the rendering viewport
* \param height of the rendering viewport
*/
void IrrDriver::computeMatrixesAndCameras(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
{
if (CVS->isSDSMEnabled())
UpdateSplitAndLightcoordRangeFromComputeShaders(width, height);
@ -377,22 +383,6 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
tmp[145] = float(height);
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, (16 * 9 + 2) * sizeof(float), tmp);
float Lighting[36];
Lighting[0] = m_sundirection.X;
Lighting[1] = m_sundirection.Y;
Lighting[2] = m_sundirection.Z;
Lighting[4] = m_suncolor.getRed();
Lighting[5] = m_suncolor.getGreen();
Lighting[6] = m_suncolor.getBlue();
Lighting[7] = 0.54f;
memcpy(&Lighting[8], blueSHCoeff, 9 * sizeof(float));
memcpy(&Lighting[17], greenSHCoeff, 9 * sizeof(float));
memcpy(&Lighting[26], redSHCoeff, 9 * sizeof(float));
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::LightingDataUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, 36 * sizeof(float), Lighting);
}