Updating call sites to use struct argument version of KRPipelineManager::getPipeline

This commit is contained in:
2022-04-04 02:00:01 -07:00
parent de5d6e64aa
commit 9e0136f051
14 changed files with 241 additions and 58 deletions

View File

@@ -129,7 +129,16 @@ void KRAmbientZone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, st
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
Matrix4 sphereModelMatrix = getModelMatrix();
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pPipeline, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -196,7 +196,16 @@ void KRAudioSource::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, st
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
Matrix4 sphereModelMatrix = getModelMatrix();
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -91,7 +91,16 @@ void KRBone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vect
// Disable z-buffer test
GLDEBUG(glDisable(GL_DEPTH_TEST));
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");

View File

@@ -338,7 +338,21 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& surface)
}
if(m_pSkyBoxTexture) {
getContext().getPipelineManager()->selectPipeline("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, Matrix4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero());
std::string shader_name("sky_box");
std::vector<KRPointLight*> no_point_lights;
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
KRPipelineManager::PipelineInfo info{};
info.shader_name = &shader_name;
info.pCamera = this;
info.point_lights = &no_point_lights;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_OPAQUE;
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(info);
getContext().getPipelineManager()->selectPipeline(*this, pPipeline, m_viewport, Matrix4(), no_point_lights, no_directional_lights, no_spot_lights, 0, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero());
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
@@ -525,8 +539,18 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& surface)
GLDEBUG(glEnable(GL_BLEND));
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
KRPipeline *pVisShader = getContext().getPipelineManager()->getPipeline("visualize_overlay", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
std::vector<KRPointLight*> no_point_lights;
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = this;
info.point_lights = &no_point_lights;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
KRPipeline *pVisShader = getContext().getPipelineManager()->getPipeline(info);
m_pContext->getMeshManager()->bindVBO(commandBuffer, &getContext().getMeshManager()->KRENGINE_VBO_DATA_3D_CUBE_VERTICES, 1.0f);
for(unordered_map<AABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
@@ -757,7 +781,20 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer)
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
GLDEBUG(glDisable(GL_DEPTH_TEST));
KRPipeline *postShader = m_pContext->getPipelineManager()->getPipeline("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
std::vector<KRPointLight*> no_point_lights;
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
KRPipelineManager::PipelineInfo info{};
std::string shader_name("PostShader");
info.shader_name = &shader_name;
info.pCamera = this;
info.point_lights = &no_point_lights;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
KRPipeline *postShader = m_pContext->getPipelineManager()->getPipeline(info);
Vector3 rim_color;
getContext().getPipelineManager()->selectPipeline(*this, postShader, m_viewport, Matrix4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f, m_fade_color);
@@ -942,8 +979,18 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer)
// Enable alpha blending
GLDEBUG(glEnable(GL_BLEND));
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
KRPipeline *fontShader = m_pContext->getPipelineManager()->getPipeline("debug_font", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
std::vector<KRPointLight*> no_point_lights;
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
KRPipelineManager::PipelineInfo info{};
std::string shader_name("debug_font");
info.shader_name = &shader_name;
info.pCamera = this;
info.point_lights = &no_point_lights;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
KRPipeline *fontShader = m_pContext->getPipelineManager()->getPipeline(info);
getContext().getPipelineManager()->selectPipeline(*this, fontShader, m_viewport, Matrix4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero());
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);

View File

@@ -204,7 +204,16 @@ void KRCollider::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::
GL_PUSH_GROUP_MARKER("Debug Overlays");
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -130,6 +130,9 @@ void KRDirectionalLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamer
std::vector<KRDirectionalLight *> this_light;
this_light.push_back(this);
std::vector<KRPointLight*> no_point_lights;
std::vector<KRSpotLight*> no_spot_lights;
Matrix4 matModelViewInverseTranspose = viewport.getViewMatrix() * getModelMatrix();
matModelViewInverseTranspose.transpose();
matModelViewInverseTranspose.invert();
@@ -138,8 +141,17 @@ void KRDirectionalLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamer
light_direction_view_space = Matrix4::Dot(matModelViewInverseTranspose, light_direction_view_space);
light_direction_view_space.normalize();
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("light_directional", pCamera, std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
KRPipelineManager::PipelineInfo info{};
std::string shader_name("light_directional");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &no_point_lights;
info.directional_lights = &this_light;
info.spot_lights = &no_spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, getModelMatrix(), no_point_lights, this_light, no_spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space);
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);

View File

@@ -258,7 +258,15 @@ void KRLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vec
this_point_light.push_back(point_light);
}
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline("dust_particle", pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("dust_particle");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &this_point_light;
info.directional_lights = &this_directional_light;
info.spot_lights = &this_spot_light;
info.renderPass = renderPass;
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
@@ -298,7 +306,15 @@ void KRLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vec
this_point_light.push_back(point_light);
}
KRPipeline *pFogShader = m_pContext->getPipelineManager()->getPipeline(shader_name, pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES);
KRPipelineManager::PipelineInfo info{};
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &this_point_light;
info.directional_lights = &this_directional_light;
info.spot_lights = &this_spot_light;
info.renderPass = KRNode::RENDER_PASS_ADDITIVE_PARTICLES;
KRPipeline *pFogShader = m_pContext->getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pFogShader, viewport, Matrix4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, Vector3::Zero(), 0.0f, Vector4::Zero())) {
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
@@ -378,7 +394,15 @@ void KRLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vec
GLDEBUG(glDepthRangef(0.0, 1.0));
// Render light flare on transparency pass
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("flare");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
@@ -495,7 +519,18 @@ void KRLight::renderShadowBuffers(VkCommandBuffer& commandBuffer, KRCamera *pCam
GLDEBUG(glDisable(GL_BLEND));
// Use shader program
KRPipeline *shadowShader = m_pContext->getPipelineManager()->getPipeline("ShadowShader", pCamera, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
std::vector<KRPointLight*> no_point_lights;
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
KRPipelineManager::PipelineInfo info{};
std::string shader_name("ShadowShader");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &no_point_lights;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
KRPipeline *shadowShader = m_pContext->getPipelineManager()->getPipeline(info);
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());

View File

@@ -319,8 +319,34 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, (int)bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("ObjectShader");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.bone_count = (int)bones.size();
info.renderPass = renderPass;
info.bDiffuseMap = bDiffuseMap;
info.bNormalMap = bNormalMap;
info.bSpecMap = bSpecMap;
info.bReflectionMap = bReflectionMap;
info.bReflectionCubeMap = bReflectionCubeMap;
info.bLightMap = bLightMap;
info.bDiffuseMapScale = m_diffuseMapScale != default_scale && bDiffuseMap;
info.bSpecMapScale = m_specularMapScale != default_scale && bSpecMap;
info.bNormalMapScale = m_normalMapScale != default_scale && bNormalMap;
info.bReflectionMapScale = m_reflectionMapScale != default_scale && bReflectionMap;
info.bDiffuseMapOffset = m_diffuseMapOffset != default_offset && bDiffuseMap;
info.bSpecMapOffset = m_specularMapOffset != default_offset && bSpecMap;
info.bNormalMapOffset = m_normalMapOffset != default_offset && bNormalMap;
info.bReflectionMapOffset = m_reflectionMapOffset != default_offset && bReflectionMap;
info.bAlphaTest = bAlphaTest;
info.bAlphaBlend = bAlphaBlend;
info.bRimColor = rim_power != 0.0f;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
Vector4 fade_color;
if(!getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, rim_power, fade_color)) {

View File

@@ -96,8 +96,15 @@ void KRParticleSystemNewtonian::render(VkCommandBuffer& commandBuffer, KRCamera
m_pContext->getTextureManager()->selectTexture(0, pParticleTexture, 0.0f, KRTexture::TEXTURE_USAGE_PARTICLE);
int particle_count = 10000;
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("dust_particle");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(info);
// Vector3 rim_color; Vector4 fade_color;
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -89,36 +89,6 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, KRRenderPass& ren
return pipeline;
}
KRPipeline* KRPipelineManager::getPipeline(const std::string& pipeline_name, KRCamera* pCamera, const std::vector<KRPointLight*>& point_lights, const std::vector<KRDirectionalLight*>& directional_lights, const std::vector<KRSpotLight*>& spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale, bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor) {
PipelineInfo info;
info.shader_name = &pipeline_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.bone_count = bone_count;
info.bDiffuseMap = bDiffuseMap;
info.bNormalMap = bNormalMap;
info.bSpecMap = bSpecMap;
info.bReflectionMap = bReflectionMap;
info.bReflectionCubeMap = bReflectionCubeMap;
info.bLightMap = bLightMap;
info.bDiffuseMapScale = bDiffuseMapScale;
info.bSpecMapScale = bSpecMapScale;
info.bNormalMapScale = bNormalMapScale;
info.bReflectionMapScale = bReflectionMapScale;
info.bDiffuseMapOffset = bDiffuseMapOffset;
info.bSpecMapOffset = bDiffuseMapOffset;
info.bNormalMapOffset = bNormalMapOffset;
info.bReflectionMapOffset = bReflectionMapOffset;
info.bAlphaTest = bAlphaTest;
info.bAlphaBlend = bAlphaBlend;
info.renderPass = renderPass;
info.bRimColor = bRimColor;
return getPipeline(info);
}
KRPipeline *KRPipelineManager::getPipeline(const PipelineInfo &info) {
int iShadowQuality = 0; // FINDME - HACK - Placeholder code, need to iterate through lights and dynamically build shader
@@ -311,7 +281,33 @@ KRPipeline *KRPipelineManager::getPipeline(const PipelineInfo &info) {
bool KRPipelineManager::selectPipeline(const std::string &pipeline_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const Matrix4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)
{
KRPipeline *pPipeline = getPipeline(pipeline_name, &camera, point_lights, directional_lights, spot_lights, bone_count, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, bDiffuseMapScale, bSpecMapScale, bNormalMapScale, bReflectionMapScale, bDiffuseMapOffset, bSpecMapOffset, bNormalMapOffset, bReflectionMapOffset, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
PipelineInfo info{};
info.shader_name = &pipeline_name;
info.pCamera = &camera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.bone_count = bone_count;
info.bDiffuseMap = bDiffuseMap;
info.bNormalMap = bNormalMap;
info.bSpecMap = bSpecMap;
info.bReflectionMap = bReflectionMap;
info.bReflectionCubeMap = bReflectionCubeMap;
info.bLightMap = bLightMap;
info.bDiffuseMapScale = bDiffuseMapScale;
info.bSpecMapScale = bSpecMapScale;
info.bNormalMapScale = bNormalMapScale;
info.bReflectionMapScale = bReflectionMapScale;
info.bDiffuseMapOffset = bDiffuseMapOffset;
info.bSpecMapOffset = bDiffuseMapOffset;
info.bNormalMapOffset = bNormalMapOffset;
info.bReflectionMapOffset = bReflectionMapOffset;
info.bAlphaTest = bAlphaTest;
info.bAlphaBlend = bAlphaBlend;
info.renderPass = renderPass;
info.bRimColor = rim_power != 0.0f;
KRPipeline *pPipeline = getPipeline(info);
return selectPipeline(camera, pPipeline, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power, fade_color);
}

View File

@@ -84,8 +84,6 @@ public:
KRPipeline *getPipeline(KRSurface& surface, KRRenderPass& renderPass, const std::string& shader_name, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
KRPipeline* getPipeline(const PipelineInfo& info);
KRPipeline *getPipeline(const std::string &pipeline_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor = false);
bool selectPipeline(KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
bool selectPipeline(const std::string &pipeline_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const Matrix4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);

View File

@@ -96,7 +96,17 @@ void KRPointLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + pCamera->settings.getPerspectiveNearZ()) * (influence_radius + pCamera->settings.getPerspectiveNearZ());
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"), pCamera, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
std::vector<KRDirectionalLight*> no_directional_lights;
std::vector<KRSpotLight*> no_spot_lights;
std::string shader_name(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"));
KRPipelineManager::PipelineInfo info{};
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &this_light;
info.directional_lights = &no_directional_lights;
info.spot_lights = &no_spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -127,8 +127,16 @@ void KRReverbZone::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
Matrix4 sphereModelMatrix = getModelMatrix();
KRPipelineManager::PipelineInfo info{};
std::string shader_name("visualize_overlay");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {

View File

@@ -156,7 +156,15 @@ void KRSprite::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::ve
GLDEBUG(glDepthRangef(0.0, 1.0));
// Render light sprite on transparency pass
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline("sprite", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRPipelineManager::PipelineInfo info{};
std::string shader_name("sprite");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(info);
if(getContext().getPipelineManager()->selectPipeline(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);