Vulkan refactoring - passing VkCommandBuffer down through node render functions
This commit is contained in:
@@ -118,11 +118,11 @@ void KRAmbientZone::setZone(const std::string &zone)
|
|||||||
m_zone = zone;
|
m_zone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAmbientZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRAmbientZone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_SIREN_AMBIENT_ZONES;
|
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_SIREN_AMBIENT_ZONES;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
std::string getZone();
|
std::string getZone();
|
||||||
void setZone(const std::string &zone);
|
void setZone(const std::string &zone);
|
||||||
|
|||||||
@@ -184,12 +184,12 @@ void KRAudioSource::queueBuffer()
|
|||||||
m_nextBufferIndex = (m_nextBufferIndex + 1) % m_audioFile->getBufferCount();
|
m_nextBufferIndex = (m_nextBufferIndex + 1) % m_audioFile->getBufferCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAudioSource::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRAudioSource::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
bool bVisualize = false;
|
bool bVisualize = false;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
virtual void physicsUpdate(float deltaTime);
|
virtual void physicsUpdate(float deltaTime);
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
// ---- Audio Playback Controls ----
|
// ---- Audio Playback Controls ----
|
||||||
|
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ AABB KRBone::getBounds() {
|
|||||||
return AABB::Create(-Vector3::One(), Vector3::One(), getModelMatrix()); // Only required for bone debug visualization
|
return AABB::Create(-Vector3::One(), Vector3::One(), getModelMatrix()); // Only required for bone debug visualization
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRBone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRBone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_BONES;
|
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_BONES;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
void setBindPose(const Matrix4 &pose);
|
void setBindPose(const Matrix4 &pose);
|
||||||
const Matrix4 &getBindPose();
|
const Matrix4 &getBindPose();
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ const std::string KRCamera::getSkyBox() const
|
|||||||
return m_skyBox;
|
return m_skyBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight)
|
void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight)
|
||||||
{
|
{
|
||||||
// ----====---- Record timing information for measuring FPS ----====----
|
// ----====---- Record timing information for measuring FPS ----====----
|
||||||
uint64_t current_time = m_pContext->getAbsoluteTimeMilliseconds();
|
uint64_t current_time = m_pContext->getAbsoluteTimeMilliseconds();
|
||||||
@@ -132,13 +132,13 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
scene.updateOctree(m_viewport);
|
scene.updateOctree(m_viewport);
|
||||||
|
|
||||||
// ----====---- Pre-stream resources ----====----
|
// ----====---- Pre-stream resources ----====----
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_PRESTREAM, true);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_PRESTREAM, true);
|
||||||
|
|
||||||
// ----====---- Generate Shadowmaps for Lights ----====----
|
// ----====---- Generate Shadowmaps for Lights ----====----
|
||||||
if(settings.m_cShadowBuffers > 0) {
|
if(settings.m_cShadowBuffers > 0) {
|
||||||
GL_PUSH_GROUP_MARKER("Generate Shadowmaps");
|
GL_PUSH_GROUP_MARKER("Generate Shadowmaps");
|
||||||
|
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_GENERATE_SHADOWMAPS, false /*settings.bEnableDeferredLighting*/);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_GENERATE_SHADOWMAPS, false /*settings.bEnableDeferredLighting*/);
|
||||||
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glDisable(GL_BLEND));
|
GLDEBUG(glDisable(GL_BLEND));
|
||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_GBUFFER, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_GBUFFER, false);
|
||||||
|
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
@@ -208,7 +208,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
|
|
||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_LIGHTS, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_LIGHTS, false);
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
// TODO: At this point, we only want to render octree nodes that produced fragments during the 1st pass into the GBuffer
|
// TODO: At this point, we only want to render octree nodes that produced fragments during the 1st pass into the GBuffer
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_OPAQUE, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_OPAQUE, false);
|
||||||
|
|
||||||
// Deactivate source buffer texture units
|
// Deactivate source buffer texture units
|
||||||
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 6, 0);
|
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 6, 0);
|
||||||
@@ -289,7 +289,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
|
|
||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_OPAQUE, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_OPAQUE, false);
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
// Render all transparent geometry
|
// Render all transparent geometry
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, false);
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
||||||
|
|
||||||
// ----====---- Perform Occlusion Tests ----====----
|
// ----====---- Perform Occlusion Tests ----====----
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, RENDER_PASS_PARTICLE_OCCLUSION, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, RENDER_PASS_PARTICLE_OCCLUSION, false);
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
||||||
|
|
||||||
// Render all flares
|
// Render all flares
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_ADDITIVE_PARTICLES, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_ADDITIVE_PARTICLES, false);
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glDepthRangef(0.0, 1.0));
|
GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), volumetricLightingViewport, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, false);
|
scene.render(commandBuffer, this, m_viewport.getVisibleBounds(), volumetricLightingViewport, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, false);
|
||||||
|
|
||||||
if(settings.volumetric_environment_downsample != 0) {
|
if(settings.volumetric_environment_downsample != 0) {
|
||||||
// Set render target
|
// Set render target
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
KRCamera(KRScene &scene, std::string name);
|
KRCamera(KRScene &scene, std::string name);
|
||||||
virtual ~KRCamera();
|
virtual ~KRCamera();
|
||||||
|
|
||||||
void renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight);
|
void renderFrame(VkCommandBuffer& commandBuffer, GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight);
|
||||||
|
|
||||||
KRRenderSettings settings;
|
KRRenderSettings settings;
|
||||||
|
|
||||||
|
|||||||
@@ -192,11 +192,11 @@ void KRCollider::setAudioOcclusion(float audio_occlusion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KRCollider::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRCollider::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_COLLIDERS) {
|
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_COLLIDERS) {
|
||||||
loadModel();
|
loadModel();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
float getAudioOcclusion();
|
float getAudioOcclusion();
|
||||||
void setAudioOcclusion(float audio_occlusion);
|
void setAudioOcclusion(float audio_occlusion);
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<KRMesh *> m_models;
|
std::vector<KRMesh *> m_models;
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ int KRDirectionalLight::configureShadowBufferViewports(const KRViewport &viewpor
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRDirectionalLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRLight::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRLight::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
||||||
// Lights are rendered on the second pass of the deferred renderer
|
// Lights are rendered on the second pass of the deferred renderer
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
Vector3 getLocalLightDirection();
|
Vector3 getLocalLightDirection();
|
||||||
Vector3 getWorldLightDirection();
|
Vector3 getWorldLightDirection();
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -213,15 +213,15 @@ float KRLight::getDecayStart() {
|
|||||||
return m_decayStart;
|
return m_decayStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_GENERATE_SHADOWMAPS && (pCamera->settings.volumetric_environment_enable || pCamera->settings.dust_particle_enable || (pCamera->settings.m_cShadowBuffers > 0 && m_casts_shadow))) {
|
if(renderPass == KRNode::RENDER_PASS_GENERATE_SHADOWMAPS && (pCamera->settings.volumetric_environment_enable || pCamera->settings.dust_particle_enable || (pCamera->settings.m_cShadowBuffers > 0 && m_casts_shadow))) {
|
||||||
allocateShadowBuffers(configureShadowBufferViewports(viewport));
|
allocateShadowBuffers(configureShadowBufferViewports(viewport));
|
||||||
renderShadowBuffers(pCamera);
|
renderShadowBuffers(commandBuffer, pCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES && pCamera->settings.dust_particle_enable) {
|
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES && pCamera->settings.dust_particle_enable) {
|
||||||
@@ -461,7 +461,7 @@ int KRLight::configureShadowBufferViewports(const KRViewport &viewport)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRLight::renderShadowBuffers(KRCamera *pCamera)
|
void KRLight::renderShadowBuffers(VkCommandBuffer& commandBuffer, KRCamera *pCamera)
|
||||||
{
|
{
|
||||||
for(int iShadow=0; iShadow < m_cShadowBuffers; iShadow++) {
|
for(int iShadow=0; iShadow < m_cShadowBuffers; iShadow++) {
|
||||||
if(!shadowValid[iShadow]) {
|
if(!shadowValid[iShadow]) {
|
||||||
@@ -501,7 +501,7 @@ void KRLight::renderShadowBuffers(KRCamera *pCamera)
|
|||||||
getContext().getPipelineManager()->selectPipeline(*pCamera, shadowShader, m_shadowViewports[iShadow], Matrix4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, Vector3::Zero(), 0.0f, Vector4::Zero());
|
getContext().getPipelineManager()->selectPipeline(*pCamera, shadowShader, m_shadowViewports[iShadow], Matrix4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
|
|
||||||
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
getScene().render(commandBuffer, pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
||||||
|
|
||||||
GLDEBUG(glEnable(GL_CULL_FACE));
|
GLDEBUG(glEnable(GL_CULL_FACE));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
void setFlareOcclusionSize(float occlusion_size);
|
void setFlareOcclusionSize(float occlusion_size);
|
||||||
void deleteBuffers();
|
void deleteBuffers();
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
int getShadowBufferCount();
|
int getShadowBufferCount();
|
||||||
GLuint *getShadowTextures();
|
GLuint *getShadowTextures();
|
||||||
@@ -102,7 +102,7 @@ protected:
|
|||||||
void invalidateShadowBuffers();
|
void invalidateShadowBuffers();
|
||||||
|
|
||||||
virtual int configureShadowBufferViewports(const KRViewport &viewport);
|
virtual int configureShadowBufferViewports(const KRViewport &viewport);
|
||||||
void renderShadowBuffers(KRCamera *pCamera);
|
void renderShadowBuffers(VkCommandBuffer& commandBuffer, KRCamera *pCamera);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ void KRModel::loadModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRModel::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRModel::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) {
|
if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) {
|
||||||
preStream(viewport);
|
preStream(viewport);
|
||||||
@@ -167,7 +167,7 @@ void KRModel::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_PARTICLE_OCCLUSION && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE && renderPass != KRNode::RENDER_PASS_GENERATE_SHADOWMAPS && renderPass != KRNode::RENDER_PASS_PRESTREAM) {
|
if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_PARTICLE_OCCLUSION && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE && renderPass != KRNode::RENDER_PASS_GENERATE_SHADOWMAPS && renderPass != KRNode::RENDER_PASS_PRESTREAM) {
|
||||||
loadModel();
|
loadModel();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
return new_node;
|
return new_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRNode::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, RenderPass renderPass)
|
void KRNode::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public:
|
|||||||
|
|
||||||
KRScene &getScene();
|
KRScene &getScene();
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, RenderPass renderPass);
|
||||||
|
|
||||||
virtual void physicsUpdate(float deltaTime);
|
virtual void physicsUpdate(float deltaTime);
|
||||||
virtual bool hasPhysics();
|
virtual bool hasPhysics();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
virtual AABB getBounds() = 0;
|
virtual AABB getBounds() = 0;
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) = 0;
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KRParticleSystem(KRScene &scene, std::string name);
|
KRParticleSystem(KRScene &scene, std::string name);
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ bool KRParticleSystemNewtonian::hasPhysics()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRParticleSystemNewtonian::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||||
if(viewport.visible(getBounds())) {
|
if(viewport.visible(getBounds())) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
|
|
||||||
virtual void physicsUpdate(float deltaTime);
|
virtual void physicsUpdate(float deltaTime);
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ AABB KRPointLight::getBounds() {
|
|||||||
return AABB::Create(Vector3::Create(-influence_radius), Vector3::Create(influence_radius), getModelMatrix());
|
return AABB::Create(Vector3::Create(-influence_radius), Vector3::Create(influence_radius), getModelMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRPointLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRLight::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRLight::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
bool bVisualize = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && pCamera->settings.bShowDeferred;
|
bool bVisualize = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && pCamera->settings.bShowDeferred;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void generateMesh();
|
void generateMesh();
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ void KRReverbZone::setZone(const std::string &zone)
|
|||||||
m_zone = zone;
|
m_zone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRReverbZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
void KRReverbZone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_SIREN_REVERB_ZONES;
|
bool bVisualize = pCamera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_SIREN_REVERB_ZONES;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
std::string getZone();
|
std::string getZone();
|
||||||
void setZone(const std::string &zone);
|
void setZone(const std::string &zone);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ KRScene::~KRScene() {
|
|||||||
m_pRootNode = NULL;
|
m_pRootNode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRScene::renderFrame(GLint defaultFBO, float deltaTime, int width, int height) {
|
void KRScene::renderFrame(VkCommandBuffer& commandBuffer, GLint defaultFBO, float deltaTime, int width, int height) {
|
||||||
getContext().startFrame(deltaTime);
|
getContext().startFrame(deltaTime);
|
||||||
KRCamera *camera = find<KRCamera>("default_camera");
|
KRCamera *camera = find<KRCamera>("default_camera");
|
||||||
if(camera == NULL) {
|
if(camera == NULL) {
|
||||||
@@ -70,7 +70,7 @@ void KRScene::renderFrame(GLint defaultFBO, float deltaTime, int width, int heig
|
|||||||
getContext().getAudioManager()->setReverbMaxLength(camera->settings.siren_reverb_max_length);
|
getContext().getAudioManager()->setReverbMaxLength(camera->settings.siren_reverb_max_length);
|
||||||
getContext().getTextureManager()->setMaxAnisotropy(camera->settings.max_anisotropy);
|
getContext().getTextureManager()->setMaxAnisotropy(camera->settings.max_anisotropy);
|
||||||
|
|
||||||
camera->renderFrame(defaultFBO, width, height);
|
camera->renderFrame(commandBuffer, defaultFBO, width, height);
|
||||||
getContext().endFrame(deltaTime);
|
getContext().endFrame(deltaTime);
|
||||||
physicsUpdate(deltaTime);
|
physicsUpdate(deltaTime);
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ std::set<KRLight *> &KRScene::getLights()
|
|||||||
return m_lights;
|
return m_lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRScene::render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame) {
|
void KRScene::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame) {
|
||||||
if(new_frame) {
|
if(new_frame) {
|
||||||
// Expire cached occlusion test results.
|
// Expire cached occlusion test results.
|
||||||
// Cached "failed" results are expired on the next frame (marked with .second of -1)
|
// Cached "failed" results are expired on the next frame (marked with .second of -1)
|
||||||
@@ -143,7 +143,7 @@ void KRScene::render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds,
|
|||||||
// Render outer nodes
|
// Render outer nodes
|
||||||
for(std::set<KRNode *>::iterator itr=outerNodes.begin(); itr != outerNodes.end(); itr++) {
|
for(std::set<KRNode *>::iterator itr=outerNodes.begin(); itr != outerNodes.end(); itr++) {
|
||||||
KRNode *node = (*itr);
|
KRNode *node = (*itr);
|
||||||
node->render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
node->render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<KROctreeNode *> remainingOctrees;
|
std::vector<KROctreeNode *> remainingOctrees;
|
||||||
@@ -159,10 +159,10 @@ void KRScene::render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds,
|
|||||||
newRemainingOctrees.clear();
|
newRemainingOctrees.clear();
|
||||||
newRemainingOctreesTestResults.clear();
|
newRemainingOctreesTestResults.clear();
|
||||||
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctrees.begin(); octree_itr != remainingOctrees.end(); octree_itr++) {
|
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctrees.begin(); octree_itr != remainingOctrees.end(); octree_itr++) {
|
||||||
render(*octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, false, false);
|
render(commandBuffer, *octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, false, false);
|
||||||
}
|
}
|
||||||
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctreesTestResults.begin(); octree_itr != remainingOctreesTestResults.end(); octree_itr++) {
|
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctreesTestResults.begin(); octree_itr != remainingOctreesTestResults.end(); octree_itr++) {
|
||||||
render(*octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, true, false);
|
render(commandBuffer, *octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, true, false);
|
||||||
}
|
}
|
||||||
remainingOctrees = newRemainingOctrees;
|
remainingOctrees = newRemainingOctrees;
|
||||||
remainingOctreesTestResults = newRemainingOctreesTestResults;
|
remainingOctreesTestResults = newRemainingOctreesTestResults;
|
||||||
@@ -171,11 +171,11 @@ void KRScene::render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds,
|
|||||||
newRemainingOctrees.clear();
|
newRemainingOctrees.clear();
|
||||||
newRemainingOctreesTestResults.clear();
|
newRemainingOctreesTestResults.clear();
|
||||||
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctreesTestResultsOnly.begin(); octree_itr != remainingOctreesTestResultsOnly.end(); octree_itr++) {
|
for(std::vector<KROctreeNode *>::iterator octree_itr = remainingOctreesTestResultsOnly.begin(); octree_itr != remainingOctreesTestResultsOnly.end(); octree_itr++) {
|
||||||
render(*octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, true, true);
|
render(commandBuffer, *octree_itr, visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, newRemainingOctrees, newRemainingOctreesTestResults, remainingOctreesTestResultsOnly, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly)
|
void KRScene::render(VkCommandBuffer& commandBuffer, KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly)
|
||||||
{
|
{
|
||||||
if(pOctreeNode) {
|
if(pOctreeNode) {
|
||||||
|
|
||||||
@@ -360,14 +360,14 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibl
|
|||||||
// Render objects that are at this octree level
|
// Render objects that are at this octree level
|
||||||
for(std::set<KRNode *>::iterator itr=pOctreeNode->getSceneNodes().begin(); itr != pOctreeNode->getSceneNodes().end(); itr++) {
|
for(std::set<KRNode *>::iterator itr=pOctreeNode->getSceneNodes().begin(); itr != pOctreeNode->getSceneNodes().end(); itr++) {
|
||||||
//assert(pOctreeNode->getBounds().contains((*itr)->getBounds())); // Sanity check
|
//assert(pOctreeNode->getBounds().contains((*itr)->getBounds())); // Sanity check
|
||||||
(*itr)->render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
(*itr)->render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render child octrees
|
// Render child octrees
|
||||||
const int *childOctreeOrder = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT || renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES || renderPass == KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE ? viewport.getBackToFrontOrder() : viewport.getFrontToBackOrder();
|
const int *childOctreeOrder = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT || renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES || renderPass == KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE ? viewport.getBackToFrontOrder() : viewport.getFrontToBackOrder();
|
||||||
|
|
||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
render(pOctreeNode->getChildren()[childOctreeOrder[i]], visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, remainingOctrees, remainingOctreesTestResults, remainingOctreesTestResultsOnly, false, false);
|
render(commandBuffer, pOctreeNode->getChildren()[childOctreeOrder[i]], visibleBounds, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass, remainingOctrees, remainingOctreesTestResults, remainingOctreesTestResultsOnly, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove lights added at this octree level from the stack
|
// Remove lights added at this octree level from the stack
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ public:
|
|||||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo, unsigned int layer_mask);
|
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo, unsigned int layer_mask);
|
||||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo, unsigned int layer_mask);
|
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo, unsigned int layer_mask);
|
||||||
|
|
||||||
void renderFrame(GLint defaultFBO, float deltaTime, int width, int height);
|
void renderFrame(VkCommandBuffer& commandBuffer, GLint defaultFBO, float deltaTime, int width, int height);
|
||||||
void render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame);
|
void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame);
|
||||||
|
|
||||||
void render(KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly);
|
void render(VkCommandBuffer& commandBuffer, KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly);
|
||||||
|
|
||||||
void updateOctree(const KRViewport &viewport);
|
void updateOctree(const KRViewport &viewport);
|
||||||
void buildOctreeForTheFirstTime();
|
void buildOctreeForTheFirstTime();
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ AABB KRSprite::getBounds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRSprite::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) {
|
if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) {
|
||||||
// Pre-stream sprites, even if the alpha is zero
|
// Pre-stream sprites, even if the alpha is zero
|
||||||
@@ -128,7 +128,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
|
|
||||||
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
if(m_lod_visible <= LOD_VISIBILITY_PRESTREAM) return;
|
||||||
|
|
||||||
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
KRNode::render(commandBuffer, pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
void setSpriteAlpha(float alpha);
|
void setSpriteAlpha(float alpha);
|
||||||
float getSpriteAlpha() const;
|
float getSpriteAlpha() const;
|
||||||
|
|
||||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
virtual AABB getBounds();
|
virtual AABB getBounds();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user