Add pipeline validation for missing shaders
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled

Add skybox texture now using image binding system
This commit is contained in:
2026-06-01 00:06:28 -07:00
parent 1ec9085d88
commit 568a870843
14 changed files with 99 additions and 73 deletions

View File

@@ -81,9 +81,20 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf
return itr->second;
}
std::vector<std::string> shaderNames;
shaderNames.push_back(*info.shader_name + ".vert");
shaderNames.push_back(*info.shader_name + ".frag");
std::vector<KRShader*> shaders;
shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".vert", "spv"));
shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".frag", "spv"));
for (const std::string& name : shaderNames) {
KRShader* shader = m_pContext->getShaderManager()->get(name, "spv");
if (shader == nullptr) {
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Shader not found: %s", name.c_str());
return nullptr;
}
shaders.push_back(shader);
}
KRPipeline* pipeline = new KRPipeline(*m_pContext, surface.m_deviceHandle, info.renderPass, surface.getDimensions(), surface.getDimensions(), info, info.shader_name->c_str(), shaders, info.vertexAttributes, info.modelFormat);
m_pipelines[key] = pipeline;

View File

@@ -134,7 +134,7 @@ void KRAmbientZone::render(RenderInfo& ri)
info.vertexAttributes = sphereModel->getVertexAttributes();
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pPipeline->bind(ri, sphereModelMatrix)) {
if (pPipeline && pPipeline->bind(ri, sphereModelMatrix)) {
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
}
} // sphereModel

View File

@@ -156,7 +156,7 @@ void KRAudioSource::render(RenderInfo& ri)
info.vertexAttributes = sphereModel->getVertexAttributes();
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader->bind(ri, sphereModelMatrix)) {
if (pShader && pShader->bind(ri, sphereModelMatrix)) {
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
}
} // sphereModels.size()

View File

@@ -96,7 +96,7 @@ void KRBone::render(RenderInfo& ri)
info.vertexAttributes = sphereModel->getVertexAttributes();
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader->bind(ri, sphereModelMatrix)) {
if (pShader && pShader->bind(ri, sphereModelMatrix)) {
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
}
} // sphereModel

View File

@@ -154,8 +154,6 @@ void KRCamera::render(KRNode::RenderInfo& ri)
GL_PUSH_GROUP_MARKER("Sky Box");
if (m_skyBox.val.isBound()) {
std::string shader_name("sky_box");
PipelineInfo info{};
info.shader_name = &shader_name;
@@ -165,14 +163,11 @@ void KRCamera::render(KRNode::RenderInfo& ri)
info.cullMode = CullMode::kCullNone;
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
pPipeline->setImageBinding("diffuseTexture", m_skyBox.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
if (pPipeline->bind(ri, Matrix4())) {
if (pPipeline && pPipeline->bind(ri, Matrix4())) {
// Render a full screen quad
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
}
}
GL_POP_GROUP_MARKER;
}
@@ -625,7 +620,7 @@ void KRCamera::renderDebug(RenderInfo& ri)
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
KRPipeline* fontShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
if (fontShader->bind(ri, Matrix4())) {
if (fontShader && fontShader->bind(ri, Matrix4())) {
m_debug_text_vbo_data.bind(ri.commandBuffer);
@@ -860,6 +855,11 @@ bool KRCamera::getImageBinding(const std::string& name, const KRTextureBinding**
*binding = &m_fontTexture;
*sample = getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER;
return true;
} else if (name == "skyboxTexture") {
*binding = &m_skyBox.val;
*sample = getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER;
return true;
} else {
return KRNode::getImageBinding(name, binding, sample);
}

View File

@@ -222,7 +222,7 @@ void KRCollider::render(RenderInfo& ri)
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader->bind(ri, getModelMatrix())) {
if (pShader && pShader->bind(ri, getModelMatrix())) {
m_model.val.get()->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
}

View File

@@ -159,6 +159,7 @@ void KRDirectionalLight::render(RenderInfo& ri)
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader) {
pShader->setPushConstant(ShaderValue::light_direction_view_space, light_direction_view_space);
if (pShader->bind(ri, getModelMatrix())) { // TODO: Need to pass in the light index to the shader
// Render a full screen quad
@@ -166,6 +167,7 @@ void KRDirectionalLight::render(RenderInfo& ri)
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
}
}
}
ri.reflectedObjects.pop_back();
}

View File

@@ -226,7 +226,7 @@ void KRLight::render(RenderInfo& ri)
info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
if (pParticleShader) {
pParticleShader->setPushConstant(ShaderValue::dust_particle_color, m_color.val * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
pParticleShader->setPushConstant(ShaderValue::particle_origin, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
if (pParticleShader->bind(ri, particleModelMatrix)) { // TODO: Pass light index to shader
@@ -238,6 +238,7 @@ void KRLight::render(RenderInfo& ri)
}
}
}
}
if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE && ri.camera->settings.volumetric_environment_enable && m_light_shafts) {
@@ -259,6 +260,12 @@ void KRLight::render(RenderInfo& ri)
this_point_light.push_back(point_light);
}
int slice_count = (int)(ri.camera->settings.volumetric_environment_quality * 495.0) + 5;
float slice_near = -ri.camera->settings.getPerspectiveNearZ();
float slice_far = -ri.camera->settings.volumetric_environment_max_distance;
float slice_spacing = (slice_far - slice_near) / slice_count;
PipelineInfo info{};
info.shader_name = &shader_name;
info.pCamera = ri.camera;
@@ -272,19 +279,14 @@ void KRLight::render(RenderInfo& ri)
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
KRPipeline* pFogShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
int slice_count = (int)(ri.camera->settings.volumetric_environment_quality * 495.0) + 5;
float slice_near = -ri.camera->settings.getPerspectiveNearZ();
float slice_far = -ri.camera->settings.volumetric_environment_max_distance;
float slice_spacing = (slice_far - slice_near) / slice_count;
if (pFogShader) {
pFogShader->setPushConstant(ShaderValue::slice_depth_scale, Vector2::Create(slice_near, slice_spacing));
pFogShader->setPushConstant(ShaderValue::light_color, (m_color.val * ri.camera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 10.0f));
pFogShader->bind(ri, Matrix4()); // TODO: Pass indexes of lights to shader
if (pFogShader->bind(ri, Matrix4())) { // TODO: Pass indexes of lights to shader
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_VOLUMETRIC_LIGHTING, 1.0f);
vkCmdDraw(ri.commandBuffer, slice_count * 6, 1, 0, 0);
}
}
}
@@ -314,7 +316,7 @@ void KRLight::render(RenderInfo& ri)
info.vertexAttributes = sphereModel->getVertexAttributes();
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
pPipeline->bind(ri, occlusion_test_sphere_matrix);
if (pPipeline && pPipeline->bind(ri, occlusion_test_sphere_matrix)) {
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
#if TARGET_OS_IPHONE || defined(ANDROID)
@@ -331,6 +333,7 @@ void KRLight::render(RenderInfo& ri)
GLDEBUG(glEndQuery(GL_SAMPLES_PASSED));
#endif
}
}
}
}
@@ -362,14 +365,16 @@ void KRLight::render(RenderInfo& ri)
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader) {
pShader->setImageBinding("diffuseTexture", m_flareTexture.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
pShader->bind(ri, getModelMatrix());
if (pShader->bind(ri, getModelMatrix())) {
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
}
}
}
}
}
}
}
@@ -464,6 +469,9 @@ void KRLight::renderShadowBuffers(RenderInfo& ri)
GLDEBUG(glDisable(GL_DITHER));
ri.viewport = &m_shadowViewports[iShadow];
// Use shader program
PipelineInfo info{};
std::string shader_name("ShadowShader");
@@ -474,8 +482,8 @@ void KRLight::renderShadowBuffers(RenderInfo& ri)
info.cullMode = CullMode::kCullNone; // Disabling culling, which eliminates some self-cast shadow artifacts
KRPipeline* shadowShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
ri.viewport = &m_shadowViewports[iShadow];
if (shadowShader->bind(ri, Matrix4())) {
if (shadowShader && shadowShader->bind(ri, Matrix4())) {
getScene().render(ri);
}
}

View File

@@ -102,7 +102,7 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri)
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
if (pParticleShader->bind(ri, getModelMatrix())) {
if (pParticleShader && pParticleShader->bind(ri, getModelMatrix())) {
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);

View File

@@ -116,7 +116,7 @@ void KRPointLight::render(RenderInfo& ri)
info.modelFormat = bInsideLight ? ModelFormat::KRENGINE_MODEL_FORMAT_STRIP : ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader->bind(ri, sphereModelMatrix)) { // TODO: Pass light index to shader
if (pShader && pShader->bind(ri, sphereModelMatrix)) { // TODO: Pass light index to shader
if (bInsideLight) {
// Render a full screen quad

View File

@@ -131,7 +131,7 @@ void KRReverbZone::render(RenderInfo& ri)
info.vertexAttributes = sphereModel->getVertexAttributes();
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader->bind(ri, sphereModelMatrix)) {
if (pShader && pShader->bind(ri, sphereModelMatrix)) {
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
}
} // sphereModel

View File

@@ -136,6 +136,7 @@ void KRSprite::render(RenderInfo& ri)
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader) {
pShader->setImageBinding("diffuseTexture", m_spriteTexture.val.get(), m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
if (pShader->bind(ri, getModelMatrix())) {
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
@@ -144,6 +145,7 @@ void KRSprite::render(RenderInfo& ri)
}
}
}
}
}
bool KRSprite::getShaderValue(ShaderValue value, float* output) const

View File

@@ -788,6 +788,9 @@ bool KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
info.vertexAttributes = vertexAttributes;
info.cullMode = cullMode;
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
if (pShader == nullptr) {
return false;
}
// Bind bones
if (pShader->hasPushConstant(ShaderValue::bone_transforms)) {

View File

@@ -32,10 +32,10 @@
out vec4 colorOut;
uniform samplerCube diffuseTexture;
uniform samplerCube skyboxTexture;
in mediump vec3 texCoord;
void main() {
colorOut = textureCube(diffuseTexture, normalize(texCoord));
colorOut = textureCube(skyboxTexture, normalize(texCoord));
}