Updated call sites to ensure that KRPipeline::setUniform calls are made before KRPipeline::bind calls.
Eliminated kraken::SetUniform helper functions, which are no longer used.
This commit is contained in:
@@ -152,11 +152,10 @@ void KRDirectionalLight::render(RenderInfo& ri) {
|
||||
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP;
|
||||
|
||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), nullptr, &this_light, nullptr, ri.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);
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_INTENSITY, m_intensity * 0.01f);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), nullptr, &this_light, nullptr, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
// Render a full screen quad
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
||||
|
||||
@@ -35,26 +35,6 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
void SetUniform(GLint location, const Vector2 &v)
|
||||
{
|
||||
if (location != -1) GLDEBUG(glUniform2f(location, v.x, v.y));
|
||||
}
|
||||
|
||||
void SetUniform(GLint location, const Vector3 &v)
|
||||
{
|
||||
if (location != -1) GLDEBUG(glUniform3f(location, v.x, v.y, v.z));
|
||||
}
|
||||
|
||||
void SetUniform(GLint location, const Vector4 &v)
|
||||
{
|
||||
if (location != -1) GLDEBUG(glUniform4f(location, v.x, v.y, v.z, v.w));
|
||||
}
|
||||
|
||||
void SetUniform(GLint location, const Matrix4 &v)
|
||||
{
|
||||
if (location != -1) GLDEBUG(glUniformMatrix4fv(location, 1, GL_FALSE, v.c));
|
||||
}
|
||||
|
||||
void setXMLAttribute(const std::string &base_name, tinyxml2::XMLElement *e, const Vector3 &value, const Vector3 &default_value)
|
||||
{
|
||||
// TODO - Increase number of digits after the decimal in floating point format (6 -> 12?)
|
||||
|
||||
@@ -61,11 +61,6 @@ float const PI = 3.141592653589793f;
|
||||
float const D2R = PI * 2 / 360;
|
||||
|
||||
namespace kraken {
|
||||
void SetUniform(GLint location, const Vector2 &v);
|
||||
void SetUniform(GLint location, const Vector3 &v);
|
||||
void SetUniform(GLint location, const Vector4 &v);
|
||||
void SetUniform(GLint location, const Matrix4 &v);
|
||||
|
||||
void setXMLAttribute(const std::string &base_name, ::tinyxml2::XMLElement *e, const Vector3 &value, const Vector3 &default_value);
|
||||
const Vector3 getXMLAttribute(const std::string &base_name, ::tinyxml2::XMLElement *e, const Vector3 &default_value);
|
||||
} // namespace kraken
|
||||
|
||||
@@ -269,11 +269,11 @@ void KRLight::render(RenderInfo& ri) {
|
||||
info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
||||
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pParticleShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, particleModelMatrix, &this_point_light, &this_directional_light, &this_spot_light, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_PARTICLE_ORIGIN, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
|
||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, m_dust_particle_size);
|
||||
pParticleShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, particleModelMatrix, &this_point_light, &this_directional_light, &this_spot_light, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
KRDataBlock particle_index_data;
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, m_pContext->getMeshManager()->getRandomParticles(), particle_index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true, 1.0f
|
||||
@@ -320,8 +320,6 @@ void KRLight::render(RenderInfo& ri) {
|
||||
|
||||
KRPipeline *pFogShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pFogShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, Matrix4(), &this_point_light, &this_directional_light, &this_spot_light, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
int slice_count = (int)(ri.camera->settings.volumetric_environment_quality * 495.0) + 5;
|
||||
|
||||
float slice_near = -ri.camera->settings.getPerspectiveNearZ();
|
||||
@@ -330,6 +328,7 @@ void KRLight::render(RenderInfo& ri) {
|
||||
|
||||
pFogShader->setUniform(KRPipeline::KRENGINE_UNIFORM_SLICE_DEPTH_SCALE, Vector2::Create(slice_near, slice_spacing));
|
||||
pFogShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, (m_color * ri.camera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f));
|
||||
pFogShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, Matrix4(), &this_point_light, &this_directional_light, &this_spot_light, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
KRDataBlock index_data;
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, m_pContext->getMeshManager()->getVolumetricLightingVertexes(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX), true, 1.0f
|
||||
@@ -421,11 +420,10 @@ void KRLight::render(RenderInfo& ri) {
|
||||
|
||||
|
||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||
|
||||
@@ -349,8 +349,6 @@ bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector<KRBone *>
|
||||
info.renderPass = ri.renderPass;
|
||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, matModel, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, rim_color, rim_power, Vector4::Zero());
|
||||
|
||||
// Bind bones
|
||||
if(pShader->m_pushConstantOffset[KRPipeline::KRENGINE_UNIFORM_BONE_TRANSFORMS] != -1) {
|
||||
float bone_mats[256 * 16];
|
||||
@@ -435,6 +433,7 @@ bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector<KRBone *>
|
||||
m_pContext->getTextureManager()->selectTexture(7, m_pReflectionMap, lod_coverage, KRTexture::TEXTURE_USAGE_REFLECTION_MAP);
|
||||
}
|
||||
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, matModel, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, rim_color, rim_power, Vector4::Zero());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,9 +104,8 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri) {
|
||||
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||
|
||||
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pParticleShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
||||
pParticleShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
KRDataBlock index_data;
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, m_pContext->getMeshManager()->getRandomParticles(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false, 1.0f
|
||||
|
||||
@@ -108,26 +108,28 @@ void KRPointLight::render(RenderInfo& ri)
|
||||
else {
|
||||
info.rasterMode = bVisualize ? PipelineInfo::RasterMode::kAdditive : PipelineInfo::RasterMode::kAlphaBlend;
|
||||
}
|
||||
|
||||
info.vertexAttributes = bInsideLight ? m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES.getVertexAttributes() : 1 << KRMesh::KRENGINE_ATTRIB_VERTEX;
|
||||
info.modelFormat = bInsideLight ? KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP : KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||
|
||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, sphereModelMatrix, &this_light, nullptr, nullptr, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_INTENSITY, m_intensity * 0.01f);
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_DECAY_START, getDecayStart());
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_CUTOFF, KRLIGHT_MIN_INFLUENCE);
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_POSITION, light_position);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, sphereModelMatrix, &this_light, nullptr, nullptr, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||
|
||||
if(bInsideLight) {
|
||||
// Render a full screen quad
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||
} else {
|
||||
// Render sphere of light's influence
|
||||
generateMesh();
|
||||
|
||||
GLDEBUG(glVertexAttribPointer(KRMesh::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, m_sphereVertices));
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, m_cVertices));
|
||||
|
||||
vkCmdDraw(ri.commandBuffer, m_cVertices, 1, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -158,10 +158,9 @@ void KRSprite::render(RenderInfo& ri) {
|
||||
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP;
|
||||
|
||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||
|
||||
pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
||||
pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, getModelMatrix(), &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.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);
|
||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user