Replacing more setPushConstant calls with generalized reflection
This commit is contained in:
@@ -107,7 +107,6 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri)
|
|||||||
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
|
|
||||||
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pParticleShader->setPushConstant(ShaderValue::dust_particle_size, 1.0f);
|
|
||||||
pParticleShader->bind(ri, getModelMatrix());
|
pParticleShader->bind(ri, getModelMatrix());
|
||||||
|
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
||||||
@@ -117,3 +116,13 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri)
|
|||||||
}
|
}
|
||||||
ri.reflectedObjects.pop_back();
|
ri.reflectedObjects.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KRParticleSystemNewtonian::getShaderValue(ShaderValue value, float* output) const
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case ShaderValue::dust_particle_size:
|
||||||
|
*output = 1.0f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return KRParticleSystem::getShaderValue(value, output);
|
||||||
|
}
|
||||||
@@ -51,6 +51,8 @@ public:
|
|||||||
|
|
||||||
virtual void physicsUpdate(float deltaTime);
|
virtual void physicsUpdate(float deltaTime);
|
||||||
virtual bool hasPhysics();
|
virtual bool hasPhysics();
|
||||||
|
protected:
|
||||||
|
bool getShaderValue(ShaderValue value, float* output) const override;
|
||||||
private:
|
private:
|
||||||
float m_particlesAbsoluteTime;
|
float m_particlesAbsoluteTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ bool KRPointLight::getShaderValue(ShaderValue value, float* output) const
|
|||||||
{
|
{
|
||||||
return KRLight::getShaderValue(value, output);
|
return KRLight::getShaderValue(value, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRPointLight::getShaderValue(ShaderValue value, hydra::Vector3* output) const
|
bool KRPointLight::getShaderValue(ShaderValue value, hydra::Vector3* output) const
|
||||||
{
|
{
|
||||||
return KRLight::getShaderValue(value, output);
|
return KRLight::getShaderValue(value, output);
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ AABB KRSprite::getBounds()
|
|||||||
|
|
||||||
void KRSprite::render(RenderInfo& ri)
|
void KRSprite::render(RenderInfo& ri)
|
||||||
{
|
{
|
||||||
|
ri.reflectedObjects.push_back(this);
|
||||||
|
|
||||||
if (m_lod_visible >= LOD_VISIBILITY_PRESTREAM && ri.renderPass->getType() == RenderPassType::RENDER_PASS_PRESTREAM) {
|
if (m_lod_visible >= LOD_VISIBILITY_PRESTREAM && ri.renderPass->getType() == RenderPassType::RENDER_PASS_PRESTREAM) {
|
||||||
// Pre-stream sprites, even if the alpha is zero
|
// Pre-stream sprites, even if the alpha is zero
|
||||||
@@ -165,7 +166,6 @@ void KRSprite::render(RenderInfo& ri)
|
|||||||
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
|
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
|
||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->setPushConstant(ShaderValue::material_alpha, m_spriteAlpha);
|
|
||||||
pShader->setImageBinding("diffuseTexture", m_pSpriteTexture, m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
pShader->setImageBinding("diffuseTexture", m_pSpriteTexture, m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
||||||
pShader->bind(ri, getModelMatrix());
|
pShader->bind(ri, getModelMatrix());
|
||||||
|
|
||||||
@@ -174,4 +174,15 @@ void KRSprite::render(RenderInfo& ri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ri.reflectedObjects.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KRSprite::getShaderValue(ShaderValue value, float* output) const
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case ShaderValue::material_alpha:
|
||||||
|
*output = m_spriteAlpha;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return KRNode::getShaderValue(value, output);
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
bool getShaderValue(ShaderValue value, float* output) const override;
|
||||||
|
|
||||||
std::string m_spriteTexture;
|
std::string m_spriteTexture;
|
||||||
KRTexture* m_pSpriteTexture;
|
KRTexture* m_pSpriteTexture;
|
||||||
float m_spriteAlpha;
|
float m_spriteAlpha;
|
||||||
|
|||||||
Reference in New Issue
Block a user