@@ -695,25 +695,10 @@ void Renderer::Render(const std::vector<Entity*>& entities, CameraComponent* cam
695695
696696 commandBuffers[currentFrame].bindDescriptorSets (vk::PipelineBindPoint::eGraphics, **currentLayout, 0 , {*selectedDescriptorSets[currentFrame]}, {});
697697
698- // Define PBR push constants structure matching the shader
699- struct PushConstants {
700- glm::vec4 baseColorFactor;
701- float metallicFactor;
702- float roughnessFactor;
703- int baseColorTextureSet;
704- int physicalDescriptorTextureSet;
705- int normalTextureSet;
706- int occlusionTextureSet;
707- int emissiveTextureSet;
708- float alphaMask;
709- float alphaMaskCutoff;
710- glm::vec3 emissiveFactor; // Add emissive factor for HDR emissive sources
711- float emissiveStrength; // KHR_materials_emissive_strength extension
712- };
713698
714699 // Set PBR material properties using push constants
715700 if (usePBR) {
716- PushConstants pushConstants{};
701+ MaterialProperties pushConstants{};
717702
718703 // Try to get material properties for this specific entity
719704 if (modelLoader && entity->GetName ().find (" _Material_" ) != std::string::npos) {
@@ -758,7 +743,12 @@ void Renderer::Render(const std::vector<Entity*>& entities, CameraComponent* cam
758743 pushConstants.physicalDescriptorTextureSet = 0 ;
759744 pushConstants.normalTextureSet = 0 ;
760745 pushConstants.occlusionTextureSet = 0 ;
761- pushConstants.emissiveTextureSet = 0 ;
746+ // For emissive: indicate absence with -1 so shader uses factor-only emissive
747+ int emissiveSet = -1 ;
748+ if (meshComponent && !meshComponent->GetEmissiveTexturePath ().empty ()) {
749+ emissiveSet = 0 ;
750+ }
751+ pushConstants.emissiveTextureSet = emissiveSet;
762752 pushConstants.alphaMask = 0 .0f ;
763753 pushConstants.alphaMaskCutoff = 0 .5f ;
764754
@@ -767,7 +757,7 @@ void Renderer::Render(const std::vector<Entity*>& entities, CameraComponent* cam
767757 **currentLayout,
768758 vk::ShaderStageFlagBits::eFragment,
769759 0 ,
770- vk::ArrayProxy<const uint8_t >(sizeof (PushConstants ), reinterpret_cast <const uint8_t *>(&pushConstants))
760+ vk::ArrayProxy<const uint8_t >(sizeof (MaterialProperties ), reinterpret_cast <const uint8_t *>(&pushConstants))
771761 );
772762 }
773763
0 commit comments