Moved PipelineInfo to KRPipeline.h
Added PipelineInfo::RasterMode
This commit is contained in:
@@ -129,7 +129,7 @@ void KRAmbientZone::render(RenderInfo& ri)
|
|||||||
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
||||||
Matrix4 sphereModelMatrix = getModelMatrix();
|
Matrix4 sphereModelMatrix = getModelMatrix();
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
@@ -137,6 +137,7 @@ void KRAmbientZone::render(RenderInfo& ri)
|
|||||||
info.directional_lights = &ri.directional_lights;
|
info.directional_lights = &ri.directional_lights;
|
||||||
info.spot_lights = &ri.spot_lights;
|
info.spot_lights = &ri.spot_lights;
|
||||||
info.renderPass = ri.renderPass;
|
info.renderPass = ri.renderPass;
|
||||||
|
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
||||||
|
|
||||||
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ void KRAudioSource::render(RenderInfo& ri)
|
|||||||
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
||||||
Matrix4 sphereModelMatrix = getModelMatrix();
|
Matrix4 sphereModelMatrix = getModelMatrix();
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void KRBone::render(RenderInfo& ri)
|
|||||||
// Disable z-buffer test
|
// Disable z-buffer test
|
||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "KRCamera.h"
|
#include "KRCamera.h"
|
||||||
#include "KRDirectionalLight.h"
|
#include "KRDirectionalLight.h"
|
||||||
#include "KRRenderPass.h"
|
#include "KRRenderPass.h"
|
||||||
|
#include "KRPipeline.h"
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void KRCamera::InitNodeInfo(KrNodeInfo* nodeInfo)
|
void KRCamera::InitNodeInfo(KrNodeInfo* nodeInfo)
|
||||||
@@ -299,7 +300,12 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
bool haveMesh = testVertices.isVBOReady();
|
bool haveMesh = testVertices.isVBOReady();
|
||||||
|
|
||||||
if (haveMesh) {
|
if (haveMesh) {
|
||||||
KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(surface, forwardOpaquePass, "vulkan_test", testVertices.getVertexAttributes(), KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP);
|
PipelineInfo info{};
|
||||||
|
std::string shader_name("vulkan_test");
|
||||||
|
info.shader_name = &shader_name;
|
||||||
|
info.pCamera = this;
|
||||||
|
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
|
||||||
|
KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(surface, info, testVertices.getVertexAttributes(), KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP);
|
||||||
testPipeline->bind(commandBuffer);
|
testPipeline->bind(commandBuffer);
|
||||||
testVertices.bind(commandBuffer);
|
testVertices.bind(commandBuffer);
|
||||||
vkCmdDraw(commandBuffer, 4, 1, 0, 0);
|
vkCmdDraw(commandBuffer, 4, 1, 0, 0);
|
||||||
@@ -340,7 +346,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
if(m_pSkyBoxTexture) {
|
if(m_pSkyBoxTexture) {
|
||||||
|
|
||||||
std::string shader_name("sky_box");
|
std::string shader_name("sky_box");
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = this;
|
info.pCamera = this;
|
||||||
info.renderPass = KRNode::RENDER_PASS_FORWARD_OPAQUE;
|
info.renderPass = KRNode::RENDER_PASS_FORWARD_OPAQUE;
|
||||||
@@ -533,7 +539,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = this;
|
info.pCamera = this;
|
||||||
@@ -770,7 +776,7 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
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));
|
||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("PostShader");
|
std::string shader_name("PostShader");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = this;
|
info.pCamera = this;
|
||||||
@@ -961,7 +967,7 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
// Enable alpha blending
|
// Enable alpha blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("debug_font");
|
std::string shader_name("debug_font");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = this;
|
info.pCamera = this;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ void KRCollider::render(RenderInfo& ri)
|
|||||||
|
|
||||||
GL_PUSH_GROUP_MARKER("Debug Overlays");
|
GL_PUSH_GROUP_MARKER("Debug Overlays");
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ void KRDirectionalLight::render(RenderInfo& ri) {
|
|||||||
light_direction_view_space = Matrix4::Dot(matModelViewInverseTranspose, light_direction_view_space);
|
light_direction_view_space = Matrix4::Dot(matModelViewInverseTranspose, light_direction_view_space);
|
||||||
light_direction_view_space.normalize();
|
light_direction_view_space.normalize();
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("light_directional");
|
std::string shader_name("light_directional");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
this_point_light.push_back(point_light);
|
this_point_light.push_back(point_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("dust_particle");
|
std::string shader_name("dust_particle");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
@@ -306,7 +306,7 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
this_point_light.push_back(point_light);
|
this_point_light.push_back(point_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
info.point_lights = &this_point_light;
|
info.point_lights = &this_point_light;
|
||||||
@@ -348,7 +348,7 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
|
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("occlusion_test");
|
std::string shader_name("occlusion_test");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
@@ -403,7 +403,7 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
GLDEBUG(glDepthRangef(0.0, 1.0));
|
GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||||
|
|
||||||
// Render light flare on transparency pass
|
// Render light flare on transparency pass
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("flare");
|
std::string shader_name("flare");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
@@ -528,7 +528,7 @@ void KRLight::renderShadowBuffers(RenderInfo& ri)
|
|||||||
GLDEBUG(glDisable(GL_BLEND));
|
GLDEBUG(glDisable(GL_BLEND));
|
||||||
|
|
||||||
// Use shader program
|
// Use shader program
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("ShadowShader");
|
std::string shader_name("ShadowShader");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector<KRBone *>
|
|||||||
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
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);
|
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||||
|
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("ObjectShader");
|
std::string shader_name("ObjectShader");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri) {
|
|||||||
m_pContext->getTextureManager()->selectTexture(0, pParticleTexture, 0.0f, KRTexture::TEXTURE_USAGE_PARTICLE);
|
m_pContext->getTextureManager()->selectTexture(0, pParticleTexture, 0.0f, KRTexture::TEXTURE_USAGE_PARTICLE);
|
||||||
|
|
||||||
int particle_count = 10000;
|
int particle_count = 10000;
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("dust_particle");
|
std::string shader_name("dust_particle");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ const char *KRPipeline::KRENGINE_UNIFORM_NAMES[] = {
|
|||||||
"fade_color", // KRENGINE_UNIFORM_FADE_COLOR
|
"fade_color", // KRENGINE_UNIFORM_FADE_COLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, KRRenderPass& renderPass, const char* szKey, const std::vector<KRShader*>& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat)
|
KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector<KRShader*>& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat)
|
||||||
: KRContextObject(context)
|
: KRContextObject(context)
|
||||||
, m_iProgram(0) // not used for Vulkan
|
, m_iProgram(0) // not used for Vulkan
|
||||||
{
|
{
|
||||||
@@ -321,6 +321,8 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, KRRenderPass& ren
|
|||||||
depthStencil.front = {};
|
depthStencil.front = {};
|
||||||
depthStencil.back = {};
|
depthStencil.back = {};
|
||||||
|
|
||||||
|
KRRenderPass& renderPass = surface.getForwardOpaquePass(); // TODO - This needs to be selected dynamically from info.render_pass
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineInfo{};
|
VkGraphicsPipelineCreateInfo pipelineInfo{};
|
||||||
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||||
pipelineInfo.stageCount = stage_count;
|
pipelineInfo.stageCount = stage_count;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#define KRPIPELINE_H
|
#define KRPIPELINE_H
|
||||||
|
|
||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include "KRPipeline.h"
|
|
||||||
#include "KRCamera.h"
|
#include "KRCamera.h"
|
||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
#include "KRViewport.h"
|
#include "KRViewport.h"
|
||||||
@@ -45,10 +44,44 @@ class KRShader;
|
|||||||
class KRSurface;
|
class KRSurface;
|
||||||
class KRRenderPass;
|
class KRRenderPass;
|
||||||
|
|
||||||
|
class PipelineInfo {
|
||||||
class KRPipeline : public KRContextObject {
|
|
||||||
public:
|
public:
|
||||||
KRPipeline(KRContext& context, KRSurface& surface, KRRenderPass& renderPass, const char* szKey, const std::vector<KRShader*>& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
|
enum class RasterMode : uint32_t {
|
||||||
|
kOpaque = 0,
|
||||||
|
kAlphaBlend = 1,
|
||||||
|
kAdditive = 2
|
||||||
|
};
|
||||||
|
const std::string* shader_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 : 1;
|
||||||
|
bool bNormalMap : 1;
|
||||||
|
bool bSpecMap : 1;
|
||||||
|
bool bReflectionMap : 1;
|
||||||
|
bool bReflectionCubeMap : 1;
|
||||||
|
bool bLightMap : 1;
|
||||||
|
bool bDiffuseMapScale : 1;
|
||||||
|
bool bSpecMapScale : 1;
|
||||||
|
bool bNormalMapScale : 1;
|
||||||
|
bool bReflectionMapScale : 1;
|
||||||
|
bool bDiffuseMapOffset : 1;
|
||||||
|
bool bSpecMapOffset : 1;
|
||||||
|
bool bNormalMapOffset : 1;
|
||||||
|
bool bReflectionMapOffset : 1;
|
||||||
|
bool bAlphaTest : 1;
|
||||||
|
bool bAlphaBlend : 1;
|
||||||
|
bool bRimColor : 1;
|
||||||
|
RasterMode rasterMode;
|
||||||
|
KRNode::RenderPass renderPass;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KRPipeline : public KRContextObject {
|
||||||
|
public:
|
||||||
|
|
||||||
|
KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector<KRShader*>& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
|
||||||
KRPipeline(KRContext &context, char *szKey, std::string options, std::string vertShaderSource, const std::string fragShaderSource);
|
KRPipeline(KRContext &context, char *szKey, std::string options, std::string vertShaderSource, const std::string fragShaderSource);
|
||||||
virtual ~KRPipeline();
|
virtual ~KRPipeline();
|
||||||
const char *getKey() const;
|
const char *getKey() const;
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ KRPipelineManager::~KRPipelineManager() {
|
|||||||
#endif // ANDROID
|
#endif // ANDROID
|
||||||
}
|
}
|
||||||
|
|
||||||
KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, KRRenderPass& renderPass, const std::string& shader_name, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat)
|
KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo& info, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat)
|
||||||
{
|
{
|
||||||
std::pair<std::string, std::vector<int> > key;
|
std::pair<std::string, std::vector<int> > key;
|
||||||
key.first = shader_name;
|
key.first = *info.shader_name;
|
||||||
key.second.push_back(surface.m_deviceHandle);
|
key.second.push_back(surface.m_deviceHandle);
|
||||||
key.second.push_back(surface.m_swapChain->m_imageFormat);
|
key.second.push_back(surface.m_swapChain->m_imageFormat);
|
||||||
key.second.push_back(surface.m_swapChain->m_extent.width);
|
key.second.push_back(surface.m_swapChain->m_extent.width);
|
||||||
@@ -80,9 +80,9 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, KRRenderPass& ren
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<KRShader*> shaders;
|
std::vector<KRShader*> shaders;
|
||||||
shaders.push_back(m_pContext->getShaderManager()->get(shader_name + ".vert", "spv"));
|
shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".vert", "spv"));
|
||||||
shaders.push_back(m_pContext->getShaderManager()->get(shader_name + ".frag", "spv"));
|
shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".frag", "spv"));
|
||||||
KRPipeline* pipeline = new KRPipeline(*m_pContext, surface, renderPass, shader_name.c_str(), shaders, vertexAttributes, modelFormat);
|
KRPipeline* pipeline = new KRPipeline(*m_pContext, surface, info, info.shader_name->c_str(), shaders, vertexAttributes, modelFormat);
|
||||||
|
|
||||||
m_pipelines[key] = pipeline;
|
m_pipelines[key] = pipeline;
|
||||||
|
|
||||||
@@ -166,6 +166,7 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf
|
|||||||
key.second.push_back((int)(info.pCamera->settings.vignette_falloff * 1000.0f));
|
key.second.push_back((int)(info.pCamera->settings.vignette_falloff * 1000.0f));
|
||||||
key.second.push_back(info.bRimColor);
|
key.second.push_back(info.bRimColor);
|
||||||
key.second.push_back(bFadeColorEnabled);
|
key.second.push_back(bFadeColorEnabled);
|
||||||
|
key.second.push_back((int)info.rasterMode);
|
||||||
|
|
||||||
|
|
||||||
KRPipeline *pPipeline = m_pipelines[key];
|
KRPipeline *pPipeline = m_pipelines[key];
|
||||||
|
|||||||
@@ -47,42 +47,17 @@ using std::vector;
|
|||||||
#define KRPIPELINEMANAGER_H
|
#define KRPIPELINEMANAGER_H
|
||||||
|
|
||||||
class KRPipeline;
|
class KRPipeline;
|
||||||
|
class PipelineInfo;
|
||||||
class KRCamera;
|
class KRCamera;
|
||||||
|
|
||||||
class KRPipelineManager : public KRContextObject {
|
class KRPipelineManager : public KRContextObject {
|
||||||
public:
|
public:
|
||||||
typedef struct {
|
|
||||||
const std::string* shader_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 : 1;
|
|
||||||
bool bNormalMap : 1;
|
|
||||||
bool bSpecMap : 1;
|
|
||||||
bool bReflectionMap : 1;
|
|
||||||
bool bReflectionCubeMap : 1;
|
|
||||||
bool bLightMap : 1;
|
|
||||||
bool bDiffuseMapScale : 1;
|
|
||||||
bool bSpecMapScale : 1;
|
|
||||||
bool bNormalMapScale : 1;
|
|
||||||
bool bReflectionMapScale : 1;
|
|
||||||
bool bDiffuseMapOffset : 1;
|
|
||||||
bool bSpecMapOffset : 1;
|
|
||||||
bool bNormalMapOffset : 1;
|
|
||||||
bool bReflectionMapOffset : 1;
|
|
||||||
bool bAlphaTest : 1;
|
|
||||||
bool bAlphaBlend : 1;
|
|
||||||
bool bRimColor : 1;
|
|
||||||
KRNode::RenderPass renderPass;
|
|
||||||
} PipelineInfo;
|
|
||||||
|
|
||||||
KRPipelineManager(KRContext &context);
|
KRPipelineManager(KRContext &context);
|
||||||
virtual ~KRPipelineManager();
|
virtual ~KRPipelineManager();
|
||||||
KRPipeline* get(const char* szKey);
|
KRPipeline* get(const char* szKey);
|
||||||
|
|
||||||
KRPipeline *getPipeline(KRSurface& surface, KRRenderPass& renderPass, const std::string& shader_name, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
|
KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
|
||||||
KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info);
|
KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info);
|
||||||
bool selectPipeline(KRSurface& surface, 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(KRSurface& surface, 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(KRSurface& surface, const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color);
|
bool selectPipeline(KRSurface& surface, const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void KRPointLight::render(RenderInfo& ri)
|
|||||||
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + ri.camera->settings.getPerspectiveNearZ()) * (influence_radius + ri.camera->settings.getPerspectiveNearZ());
|
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + ri.camera->settings.getPerspectiveNearZ()) * (influence_radius + ri.camera->settings.getPerspectiveNearZ());
|
||||||
|
|
||||||
std::string shader_name(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"));
|
std::string shader_name(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"));
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
info.point_lights = &this_light;
|
info.point_lights = &this_light;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void KRReverbZone::render(RenderInfo& ri)
|
|||||||
|
|
||||||
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
if(ri.renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
|
||||||
Matrix4 sphereModelMatrix = getModelMatrix();
|
Matrix4 sphereModelMatrix = getModelMatrix();
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("visualize_overlay");
|
std::string shader_name("visualize_overlay");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ void KRScene::render(KRNode::RenderInfo& ri, KROctreeNode* pOctreeNode, unordere
|
|||||||
// Disable z-buffer write
|
// Disable z-buffer write
|
||||||
GLDEBUG(glDepthMask(GL_FALSE));
|
GLDEBUG(glDepthMask(GL_FALSE));
|
||||||
}
|
}
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("occlusion_test");
|
std::string shader_name("occlusion_test");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ void KRSprite::render(RenderInfo& ri) {
|
|||||||
GLDEBUG(glDepthRangef(0.0, 1.0));
|
GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||||
|
|
||||||
// Render light sprite on transparency pass
|
// Render light sprite on transparency pass
|
||||||
KRPipelineManager::PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("sprite");
|
std::string shader_name("sprite");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
info.pCamera = ri.camera;
|
info.pCamera = ri.camera;
|
||||||
|
|||||||
Reference in New Issue
Block a user