diff --git a/kraken/CMakeLists.txt b/kraken/CMakeLists.txt index da4eb6c..49d606b 100644 --- a/kraken/CMakeLists.txt +++ b/kraken/CMakeLists.txt @@ -90,4 +90,5 @@ add_source_and_header(KRPipeline) add_source_and_header(KRPipelineManager) add_source_and_header(KRSampler) add_source_and_header(KRSamplerManager) +add_source_and_header(KRShaderReflection) add_source_and_header(KRViewport) diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index e28e78c..b6ee44c 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -40,77 +40,6 @@ using namespace hydra; - -const char* KRPipeline::KRENGINE_PUSH_CONSTANT_NAMES[] = { - "material_ambient", // PushConstant::material_ambient - "material_diffuse", // PushConstant::material_diffuse - "material_specular", // PushConstant::material_specular - "material_reflection", // PushConstant::material_reflection - "material_alpha", // PushConstant::material_alpha - "material_shininess", // PushConstant::material_shininess - "light_position", // PushConstant::light_position - "light_direction_model_space", // PushConstant::light_direction_model_space - "light_direction_view_space", // PushConstant::light_direction_view_space - "light_color", // PushConstant::light_color - "light_decay_start", // PushConstant::light_decay_start - "light_cutoff", // PushConstant::light_cutoff - "light_intensity", // PushConstant::light_intensity - "flare_size", // PushConstant::flare_size - "view_space_model_origin", // PushConstant::view_space_model_origin - "mvp_matrix", // PushConstant::mvp - "inv_projection_matrix", // PushConstant::invp - "inv_mvp_matrix", // PushConstant::invmvp - "inv_mvp_matrix_no_translate", // PushConstant::invmvp_no_translate - "model_view_inverse_transpose_matrix", // PushConstant::model_view_inverse_transpose - "model_inverse_transpose_matrix", // PushConstant::model_inverse_transpose - "model_view_matrix", // PushConstant::model_view - "model_matrix", // PushConstant::model_matrix - "projection_matrix", // PushConstant::projection_matrix - "camera_position_model_space", // PushConstant::camerapos_model_space - "viewport", // PushConstant::viewport - "diffuseTexture", // PushConstant::diffusetexture - "specularTexture", // PushConstant::speculartexture - "reflectionCubeTexture", // PushConstant::reflectioncubetexture - "reflectionTexture", // PushConstant::reflectiontexture - "normalTexture", // PushConstant::normaltexture - "diffuseTexture_Scale", // PushConstant::diffusetexture_scale - "specularTexture_Scale", // PushConstant::speculartexture_scale - "reflectionTexture_Scale", // PushConstant::reflectiontexture_scale - "normalTexture_Scale", // PushConstant::normaltexture_scale - "normalTexture_Scale", // PushConstant::ambienttexture_scale - "diffuseTexture_Offset", // PushConstant::diffusetexture_offset - "specularTexture_Offset", // PushConstant::speculartexture_offset - "reflectionTexture_Offset", // PushConstant::reflectiontexture_offset - "normalTexture_Offset", // PushConstant::normaltexture_offset - "ambientTexture_Offset", // PushConstant::ambienttexture_offset - "shadow_mvp1", // PushConstant::shadow_mvp1 - "shadow_mvp2", // PushConstant::shadow_mvp2 - "shadow_mvp3", // PushConstant::shadow_mvp3 - "shadowTexture1", // PushConstant::shadowtexture1 - "shadowTexture2", // PushConstant::shadowtexture2 - "shadowTexture3", // PushConstant::shadowtexture3 - "lightmapTexture", // PushConstant::lightmaptexture - "gbuffer_frame", // PushConstant::gbuffer_frame - "gbuffer_depth", // PushConstant::gbuffer_depth - "depthFrame", // PushConstant::depth_frame - "volumetricEnvironmentFrame", // PushConstant::volumetric_environment_frame - "renderFrame", // PushConstant::render_frame - "time_absolute", // PushConstant::absolute_time - "fog_near", // PushConstant::fog_near - "fog_far", // PushConstant::fog_far - "fog_density", // PushConstant::fog_density - "fog_color", // PushConstant::fog_color - "fog_scale", // PushConstant::fog_scale - "fog_density_premultiplied_exponential", // PushConstant::density_premultiplied_exponential - "fog_density_premultiplied_squared", // PushConstant::density_premultiplied_squared - "slice_depth_scale", // PushConstant::slice_depth_scale - "particle_origin", // PushConstant::particle_origin - "bone_transforms", // PushConstant::bone_transforms - "rim_color", // PushConstant::rim_color - "rim_power", // PushConstant::rim_power - "fade_color", // PushConstant::fade_color -}; - KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KRRenderPass* renderPass, Vector2i viewport_size, Vector2i scissor_size, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat) : KRContextObject(context) , m_deviceHandle(deviceHandle) @@ -511,7 +440,7 @@ void KRPipeline::initPushConstantStage(ShaderStage stage, const SpvReflectShader for (int iUniform = 0; iUniform < kPushConstantCount; iUniform++) { for (int iMember = 0; iMember < block.member_count; iMember++) { const SpvReflectBlockVariable& member = block.members[iMember]; - if (stricmp(KRENGINE_PUSH_CONSTANT_NAMES[iUniform], member.name) == 0) { + if (stricmp(SHADER_VALUE_NAMES[iUniform], member.name) == 0) { pushConstants.offset[iUniform] = member.offset; pushConstants.size[iUniform] = member.size; } @@ -559,7 +488,7 @@ void KRPipeline::initDescriptorSetStage(ShaderStage stage, const SpvReflectShade } } -bool KRPipeline::hasPushConstant(PushConstant location) const +bool KRPipeline::hasPushConstant(ShaderValue location) const { for (const StageInfo& stageInfo : m_stages) { const PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -570,7 +499,7 @@ bool KRPipeline::hasPushConstant(PushConstant location) const return false; } -void KRPipeline::setPushConstant(PushConstant location, float value) +void KRPipeline::setPushConstant(ShaderValue location, float value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -582,7 +511,7 @@ void KRPipeline::setPushConstant(PushConstant location, float value) } -void KRPipeline::setPushConstant(PushConstant location, int value) +void KRPipeline::setPushConstant(ShaderValue location, int value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -593,7 +522,7 @@ void KRPipeline::setPushConstant(PushConstant location, int value) } } -void KRPipeline::setPushConstant(PushConstant location, const Vector2& value) +void KRPipeline::setPushConstant(ShaderValue location, const Vector2& value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -603,7 +532,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Vector2& value) } } } -void KRPipeline::setPushConstant(PushConstant location, const Vector3& value) +void KRPipeline::setPushConstant(ShaderValue location, const Vector3& value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -614,7 +543,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Vector3& value) } } -void KRPipeline::setPushConstant(PushConstant location, const Vector4& value) +void KRPipeline::setPushConstant(ShaderValue location, const Vector4& value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -625,7 +554,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Vector4& value) } } -void KRPipeline::setPushConstant(PushConstant location, const Matrix4& value) +void KRPipeline::setPushConstant(ShaderValue location, const Matrix4& value) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -636,7 +565,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Matrix4& value) } } -void KRPipeline::setPushConstant(PushConstant location, const Matrix4* value, const size_t count) +void KRPipeline::setPushConstant(ShaderValue location, const Matrix4* value, const size_t count) { for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; @@ -653,7 +582,7 @@ void KRPipeline::updateDescriptorBinding() void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matModel) { - setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime()); + setPushConstant(ShaderValue::absolute_time, getContext().getAbsoluteTime()); int light_directional_count = 0; //int light_point_count = 0; @@ -665,7 +594,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM KRDirectionalLight* directional_light = (*light_itr); if (light_directional_count == 0) { int cShadowBuffers = directional_light->getShadowBufferCount(); - if (hasPushConstant(PushConstant::shadowtexture1) && cShadowBuffers > 0) { + if (hasPushConstant(ShaderValue::shadowtexture1) && cShadowBuffers > 0) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 3, directional_light->getShadowTextures()[0])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -673,7 +602,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM } } - if (hasPushConstant(PushConstant::shadowtexture2) && cShadowBuffers > 1 && ri.camera->settings.m_cShadowBuffers > 1) { + if (hasPushConstant(ShaderValue::shadowtexture2) && cShadowBuffers > 1 && ri.camera->settings.m_cShadowBuffers > 1) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 4, directional_light->getShadowTextures()[1])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -681,7 +610,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM } } - if (hasPushConstant(PushConstant::shadowtexture3) && cShadowBuffers > 2 && ri.camera->settings.m_cShadowBuffers > 2) { + if (hasPushConstant(ShaderValue::shadowtexture3) && cShadowBuffers > 2 && ri.camera->settings.m_cShadowBuffers > 2) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 5, directional_light->getShadowTextures()[2])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -693,17 +622,17 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM matBias.translate(1.0, 1.0, 1.0); matBias.scale(0.5); for (int iShadow = 0; iShadow < cShadowBuffers; iShadow++) { - setPushConstant(static_cast(static_cast(PushConstant::shadow_mvp1) + iShadow), matModel * directional_light->getShadowViewports()[iShadow].getViewProjectionMatrix() * matBias); + setPushConstant(static_cast(static_cast(ShaderValue::shadow_mvp1) + iShadow), matModel * directional_light->getShadowViewports()[iShadow].getViewProjectionMatrix() * matBias); } - if (hasPushConstant(PushConstant::light_direction_model_space)) { + if (hasPushConstant(ShaderValue::light_direction_model_space)) { Matrix4 inverseModelMatrix = matModel; inverseModelMatrix.invert(); // Bind the light direction vector Vector3 lightDirObject = Matrix4::Dot(inverseModelMatrix, directional_light->getWorldLightDirection()); lightDirObject.normalize(); - setPushConstant(PushConstant::light_direction_model_space, lightDirObject); + setPushConstant(ShaderValue::light_direction_model_space, lightDirObject); } } @@ -714,57 +643,57 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM //light_spot_count = spot_lights.size(); } - if (hasPushConstant(PushConstant::camerapos_model_space)) { + if (hasPushConstant(ShaderValue::camerapos_model_space)) { Matrix4 inverseModelMatrix = matModel; inverseModelMatrix.invert(); - if (hasPushConstant(PushConstant::camerapos_model_space)) { + if (hasPushConstant(ShaderValue::camerapos_model_space)) { // Transform location of camera to object space for calculation of specular halfVec Vector3 cameraPosObject = Matrix4::Dot(inverseModelMatrix, ri.viewport->getCameraPosition()); - setPushConstant(PushConstant::camerapos_model_space, cameraPosObject); + setPushConstant(ShaderValue::camerapos_model_space, cameraPosObject); } } - if (hasPushConstant(PushConstant::mvp) || hasPushConstant(KRPipeline::PushConstant::invmvp)) { + if (hasPushConstant(ShaderValue::mvp) || hasPushConstant(ShaderValue::invmvp)) { // Bind our modelmatrix variable to be a uniform called mvpmatrix in our shaderprogram Matrix4 mvpMatrix = matModel * ri.viewport->getViewProjectionMatrix(); - setPushConstant(PushConstant::mvp, mvpMatrix); + setPushConstant(ShaderValue::mvp, mvpMatrix); - if (hasPushConstant(KRPipeline::PushConstant::invmvp)) { - setPushConstant(KRPipeline::PushConstant::invmvp, Matrix4::Invert(mvpMatrix)); + if (hasPushConstant(ShaderValue::invmvp)) { + setPushConstant(ShaderValue::invmvp, Matrix4::Invert(mvpMatrix)); } } - if (hasPushConstant(KRPipeline::PushConstant::view_space_model_origin) || hasPushConstant(PushConstant::model_view_inverse_transpose) || hasPushConstant(KRPipeline::PushConstant::model_view)) { + if (hasPushConstant(ShaderValue::view_space_model_origin) || hasPushConstant(ShaderValue::model_view_inverse_transpose) || hasPushConstant(ShaderValue::model_view)) { Matrix4 matModelView = matModel * ri.viewport->getViewMatrix(); - setPushConstant(PushConstant::model_view, matModelView); + setPushConstant(ShaderValue::model_view, matModelView); - if (hasPushConstant(KRPipeline::PushConstant::view_space_model_origin)) { + if (hasPushConstant(ShaderValue::view_space_model_origin)) { Vector3 view_space_model_origin = Matrix4::Dot(matModelView, Vector3::Zero()); // Origin point of model space is the light source position. No perspective, so no w divide required - setPushConstant(PushConstant::view_space_model_origin, view_space_model_origin); + setPushConstant(ShaderValue::view_space_model_origin, view_space_model_origin); } - if (hasPushConstant(PushConstant::model_view_inverse_transpose)) { + if (hasPushConstant(ShaderValue::model_view_inverse_transpose)) { Matrix4 matModelViewInverseTranspose = matModelView; matModelViewInverseTranspose.transpose(); matModelViewInverseTranspose.invert(); - setPushConstant(PushConstant::model_view_inverse_transpose, matModelViewInverseTranspose); + setPushConstant(ShaderValue::model_view_inverse_transpose, matModelViewInverseTranspose); } } - if (hasPushConstant(PushConstant::model_inverse_transpose)) { + if (hasPushConstant(ShaderValue::model_inverse_transpose)) { Matrix4 matModelInverseTranspose = matModel; matModelInverseTranspose.transpose(); matModelInverseTranspose.invert(); - setPushConstant(PushConstant::model_inverse_transpose, matModelInverseTranspose); + setPushConstant(ShaderValue::model_inverse_transpose, matModelInverseTranspose); } - if (hasPushConstant(KRPipeline::PushConstant::invp)) { - setPushConstant(PushConstant::invp, ri.viewport->getInverseProjectionMatrix()); + if (hasPushConstant(ShaderValue::invp)) { + setPushConstant(ShaderValue::invp, ri.viewport->getInverseProjectionMatrix()); } - if (hasPushConstant(KRPipeline::PushConstant::invmvp_no_translate)) { + if (hasPushConstant(ShaderValue::invmvp_no_translate)) { Matrix4 matInvMVPNoTranslate = matModel * ri.viewport->getViewMatrix();; // Remove the translation matInvMVPNoTranslate.getPointer()[3] = 0; @@ -776,16 +705,16 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM matInvMVPNoTranslate.getPointer()[15] = 1.0; matInvMVPNoTranslate = matInvMVPNoTranslate * ri.viewport->getProjectionMatrix(); matInvMVPNoTranslate.invert(); - setPushConstant(PushConstant::invmvp_no_translate, matInvMVPNoTranslate); + setPushConstant(ShaderValue::invmvp_no_translate, matInvMVPNoTranslate); } - setPushConstant(PushConstant::model_matrix, matModel); - if (hasPushConstant(PushConstant::projection_matrix)) { - setPushConstant(PushConstant::projection_matrix, ri.viewport->getProjectionMatrix()); + setPushConstant(ShaderValue::model_matrix, matModel); + if (hasPushConstant(ShaderValue::projection_matrix)) { + setPushConstant(ShaderValue::projection_matrix, ri.viewport->getProjectionMatrix()); } - if (hasPushConstant(PushConstant::viewport)) { - setPushConstant(PushConstant::viewport, Vector4::Create( + if (hasPushConstant(ShaderValue::viewport)) { + setPushConstant(ShaderValue::viewport, Vector4::Create( (float)0.0, (float)0.0, (float)ri.viewport->getSize().x, @@ -795,42 +724,42 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM } // Fog parameters - setPushConstant(PushConstant::fog_near, ri.camera->settings.fog_near); - setPushConstant(PushConstant::fog_far, ri.camera->settings.fog_far); - setPushConstant(PushConstant::fog_density, ri.camera->settings.fog_density); - setPushConstant(PushConstant::fog_color, ri.camera->settings.fog_color); + setPushConstant(ShaderValue::fog_near, ri.camera->settings.fog_near); + setPushConstant(ShaderValue::fog_far, ri.camera->settings.fog_far); + setPushConstant(ShaderValue::fog_density, ri.camera->settings.fog_density); + setPushConstant(ShaderValue::fog_color, ri.camera->settings.fog_color); - if (hasPushConstant(PushConstant::fog_scale)) { - setPushConstant(PushConstant::fog_scale, 1.0f / (ri.camera->settings.fog_far - ri.camera->settings.fog_near)); + if (hasPushConstant(ShaderValue::fog_scale)) { + setPushConstant(ShaderValue::fog_scale, 1.0f / (ri.camera->settings.fog_far - ri.camera->settings.fog_near)); } - if (hasPushConstant(PushConstant::density_premultiplied_exponential)) { - setPushConstant(PushConstant::density_premultiplied_exponential, -ri.camera->settings.fog_density * 1.442695f); // -fog_density / log(2) + if (hasPushConstant(ShaderValue::density_premultiplied_exponential)) { + setPushConstant(ShaderValue::density_premultiplied_exponential, -ri.camera->settings.fog_density * 1.442695f); // -fog_density / log(2) } - if (hasPushConstant(PushConstant::density_premultiplied_squared)) { - setPushConstant(PushConstant::density_premultiplied_squared, (float)(-ri.camera->settings.fog_density * ri.camera->settings.fog_density * 1.442695)); // -fog_density * fog_density / log(2) + if (hasPushConstant(ShaderValue::density_premultiplied_squared)) { + setPushConstant(ShaderValue::density_premultiplied_squared, (float)(-ri.camera->settings.fog_density * ri.camera->settings.fog_density * 1.442695)); // -fog_density * fog_density / log(2) } // Sets the diffuseTexture variable to the first texture unit - setPushConstant(PushConstant::diffusetexture, 0); + setPushConstant(ShaderValue::diffusetexture, 0); // Sets the specularTexture variable to the second texture unit - setPushConstant(PushConstant::speculartexture, 1); + setPushConstant(ShaderValue::speculartexture, 1); // Sets the normalTexture variable to the third texture unit - setPushConstant(PushConstant::normaltexture, 2); + setPushConstant(ShaderValue::normaltexture, 2); // Sets the shadowTexture variable to the fourth texture unit - setPushConstant(PushConstant::shadowtexture1, 3); - setPushConstant(PushConstant::shadowtexture2, 4); - setPushConstant(PushConstant::shadowtexture3, 5); - setPushConstant(PushConstant::reflectioncubetexture, 4); - setPushConstant(PushConstant::lightmaptexture, 5); - setPushConstant(PushConstant::gbuffer_frame, 6); - setPushConstant(PushConstant::gbuffer_depth, 7); // Texture unit 7 is used for reading the depth buffer in gBuffer pass #2 and in post-processing pass - setPushConstant(PushConstant::reflectiontexture, 7); // Texture unit 7 is used for the reflection map textures in gBuffer pass #3 and when using forward rendering - setPushConstant(PushConstant::depth_frame, 0); - setPushConstant(PushConstant::render_frame, 1); - setPushConstant(PushConstant::volumetric_environment_frame, 2); + setPushConstant(ShaderValue::shadowtexture1, 3); + setPushConstant(ShaderValue::shadowtexture2, 4); + setPushConstant(ShaderValue::shadowtexture3, 5); + setPushConstant(ShaderValue::reflectioncubetexture, 4); + setPushConstant(ShaderValue::lightmaptexture, 5); + setPushConstant(ShaderValue::gbuffer_frame, 6); + setPushConstant(ShaderValue::gbuffer_depth, 7); // Texture unit 7 is used for reading the depth buffer in gBuffer pass #2 and in post-processing pass + setPushConstant(ShaderValue::reflectiontexture, 7); // Texture unit 7 is used for the reflection map textures in gBuffer pass #3 and when using forward rendering + setPushConstant(ShaderValue::depth_frame, 0); + setPushConstant(ShaderValue::render_frame, 1); + setPushConstant(ShaderValue::volumetric_environment_frame, 2); for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; diff --git a/kraken/KRPipeline.h b/kraken/KRPipeline.h index 6140494..ab3af81 100644 --- a/kraken/KRPipeline.h +++ b/kraken/KRPipeline.h @@ -220,88 +220,16 @@ public: bool bind(KRNode::RenderInfo& ri, const hydra::Matrix4& matModel); - enum class PushConstant : uint8_t - { - material_ambient = 0, - material_diffuse, - material_specular, - material_reflection, - material_alpha, - material_shininess, - light_position, - light_direction_model_space, - light_direction_view_space, - light_color, - light_decay_start, - light_cutoff, - light_intensity, - flare_size, - view_space_model_origin, - mvp, - invp, - invmvp, - invmvp_no_translate, - model_view_inverse_transpose, - model_inverse_transpose, - model_view, - model_matrix, - projection_matrix, - camerapos_model_space, - viewport, - diffusetexture, - speculartexture, - reflectioncubetexture, - reflectiontexture, - normaltexture, - diffusetexture_scale, - speculartexture_scale, - reflectiontexture_scale, - normaltexture_scale, - ambienttexture_scale, - diffusetexture_offset, - speculartexture_offset, - reflectiontexture_offset, - normaltexture_offset, - ambienttexture_offset, - shadow_mvp1, - shadow_mvp2, - shadow_mvp3, - shadowtexture1, - shadowtexture2, - shadowtexture3, - lightmaptexture, - gbuffer_frame, - gbuffer_depth, - depth_frame, - volumetric_environment_frame, - render_frame, - absolute_time, - fog_near, - fog_far, - fog_density, - fog_color, - fog_scale, - density_premultiplied_exponential, - density_premultiplied_squared, - slice_depth_scale, - particle_origin, - bone_transforms, - rim_color, - rim_power, - fade_color, - NUM_PUSH_CONSTANTS - }; + static const size_t kPushConstantCount = static_cast(ShaderValue::NUM_PUSH_CONSTANTS); - static const size_t kPushConstantCount = static_cast(PushConstant::NUM_PUSH_CONSTANTS); - - bool hasPushConstant(PushConstant location) const; - void setPushConstant(PushConstant location, float value); - void setPushConstant(PushConstant location, int value); - void setPushConstant(PushConstant location, const hydra::Vector2& value); - void setPushConstant(PushConstant location, const hydra::Vector3& value); - void setPushConstant(PushConstant location, const hydra::Vector4& value); - void setPushConstant(PushConstant location, const hydra::Matrix4& value); - void setPushConstant(PushConstant location, const hydra::Matrix4* value, const size_t count); + bool hasPushConstant(ShaderValue location) const; + void setPushConstant(ShaderValue location, float value); + void setPushConstant(ShaderValue location, int value); + void setPushConstant(ShaderValue location, const hydra::Vector2& value); + void setPushConstant(ShaderValue location, const hydra::Vector3& value); + void setPushConstant(ShaderValue location, const hydra::Vector4& value); + void setPushConstant(ShaderValue location, const hydra::Matrix4& value); + void setPushConstant(ShaderValue location, const hydra::Matrix4* value, const size_t count); void setImageBinding(const std::string& name, KRTexture* texture, KRSampler* sampler); @@ -312,7 +240,6 @@ private: void updateDescriptorBinding(); void updateDescriptorSets(); void updatePushConstants(KRNode::RenderInfo& ri, const hydra::Matrix4& matModel); - static const char* KRENGINE_PUSH_CONSTANT_NAMES[]; struct PushConstantInfo { diff --git a/kraken/KRShaderReflection.cpp b/kraken/KRShaderReflection.cpp new file mode 100644 index 0000000..2893ddb --- /dev/null +++ b/kraken/KRShaderReflection.cpp @@ -0,0 +1,102 @@ +// +// KRPipeline.cpp +// Kraken Engine +// +// Copyright 2024 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#include "KRShaderReflection.h" + +const char* SHADER_VALUE_NAMES[] = { + "material_ambient", // PushConstant::material_ambient + "material_diffuse", // PushConstant::material_diffuse + "material_specular", // PushConstant::material_specular + "material_reflection", // PushConstant::material_reflection + "material_alpha", // PushConstant::material_alpha + "material_shininess", // PushConstant::material_shininess + "light_position", // PushConstant::light_position + "light_direction_model_space", // PushConstant::light_direction_model_space + "light_direction_view_space", // PushConstant::light_direction_view_space + "light_color", // PushConstant::light_color + "light_decay_start", // PushConstant::light_decay_start + "light_cutoff", // PushConstant::light_cutoff + "light_intensity", // PushConstant::light_intensity + "flare_size", // PushConstant::flare_size + "view_space_model_origin", // PushConstant::view_space_model_origin + "mvp_matrix", // PushConstant::mvp + "inv_projection_matrix", // PushConstant::invp + "inv_mvp_matrix", // PushConstant::invmvp + "inv_mvp_matrix_no_translate", // PushConstant::invmvp_no_translate + "model_view_inverse_transpose_matrix", // PushConstant::model_view_inverse_transpose + "model_inverse_transpose_matrix", // PushConstant::model_inverse_transpose + "model_view_matrix", // PushConstant::model_view + "model_matrix", // PushConstant::model_matrix + "projection_matrix", // PushConstant::projection_matrix + "camera_position_model_space", // PushConstant::camerapos_model_space + "viewport", // PushConstant::viewport + "diffuseTexture", // PushConstant::diffusetexture + "specularTexture", // PushConstant::speculartexture + "reflectionCubeTexture", // PushConstant::reflectioncubetexture + "reflectionTexture", // PushConstant::reflectiontexture + "normalTexture", // PushConstant::normaltexture + "diffuseTexture_Scale", // PushConstant::diffusetexture_scale + "specularTexture_Scale", // PushConstant::speculartexture_scale + "reflectionTexture_Scale", // PushConstant::reflectiontexture_scale + "normalTexture_Scale", // PushConstant::normaltexture_scale + "normalTexture_Scale", // PushConstant::ambienttexture_scale + "diffuseTexture_Offset", // PushConstant::diffusetexture_offset + "specularTexture_Offset", // PushConstant::speculartexture_offset + "reflectionTexture_Offset", // PushConstant::reflectiontexture_offset + "normalTexture_Offset", // PushConstant::normaltexture_offset + "ambientTexture_Offset", // PushConstant::ambienttexture_offset + "shadow_mvp1", // PushConstant::shadow_mvp1 + "shadow_mvp2", // PushConstant::shadow_mvp2 + "shadow_mvp3", // PushConstant::shadow_mvp3 + "shadowTexture1", // PushConstant::shadowtexture1 + "shadowTexture2", // PushConstant::shadowtexture2 + "shadowTexture3", // PushConstant::shadowtexture3 + "lightmapTexture", // PushConstant::lightmaptexture + "gbuffer_frame", // PushConstant::gbuffer_frame + "gbuffer_depth", // PushConstant::gbuffer_depth + "depthFrame", // PushConstant::depth_frame + "volumetricEnvironmentFrame", // PushConstant::volumetric_environment_frame + "renderFrame", // PushConstant::render_frame + "time_absolute", // PushConstant::absolute_time + "fog_near", // PushConstant::fog_near + "fog_far", // PushConstant::fog_far + "fog_density", // PushConstant::fog_density + "fog_color", // PushConstant::fog_color + "fog_scale", // PushConstant::fog_scale + "fog_density_premultiplied_exponential", // PushConstant::density_premultiplied_exponential + "fog_density_premultiplied_squared", // PushConstant::density_premultiplied_squared + "slice_depth_scale", // PushConstant::slice_depth_scale + "particle_origin", // PushConstant::particle_origin + "bone_transforms", // PushConstant::bone_transforms + "rim_color", // PushConstant::rim_color + "rim_power", // PushConstant::rim_power + "fade_color", // PushConstant::fade_color +}; diff --git a/kraken/KRShaderReflection.h b/kraken/KRShaderReflection.h new file mode 100644 index 0000000..5b898e1 --- /dev/null +++ b/kraken/KRShaderReflection.h @@ -0,0 +1,115 @@ +// +// KRShaderReflection.h +// Kraken Engine +// +// Copyright 2024 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + + +#pragma once + +#include + +enum class ShaderValue : uint8_t +{ + material_ambient = 0, + material_diffuse, + material_specular, + material_reflection, + material_alpha, + material_shininess, + light_position, + light_direction_model_space, + light_direction_view_space, + light_color, + light_decay_start, + light_cutoff, + light_intensity, + flare_size, + view_space_model_origin, + mvp, + invp, + invmvp, + invmvp_no_translate, + model_view_inverse_transpose, + model_inverse_transpose, + model_view, + model_matrix, + projection_matrix, + camerapos_model_space, + viewport, + diffusetexture, + speculartexture, + reflectioncubetexture, + reflectiontexture, + normaltexture, + diffusetexture_scale, + speculartexture_scale, + reflectiontexture_scale, + normaltexture_scale, + ambienttexture_scale, + diffusetexture_offset, + speculartexture_offset, + reflectiontexture_offset, + normaltexture_offset, + ambienttexture_offset, + shadow_mvp1, + shadow_mvp2, + shadow_mvp3, + shadowtexture1, + shadowtexture2, + shadowtexture3, + lightmaptexture, + gbuffer_frame, + gbuffer_depth, + depth_frame, + volumetric_environment_frame, + render_frame, + absolute_time, + fog_near, + fog_far, + fog_density, + fog_color, + fog_scale, + density_premultiplied_exponential, + density_premultiplied_squared, + slice_depth_scale, + particle_origin, + bone_transforms, + rim_color, + rim_power, + fade_color, + NUM_PUSH_CONSTANTS +}; + +const char* SHADER_VALUE_NAMES[]; + +class KRReflectedObject +{ +public: + static std::map> ValueMap; +}; diff --git a/kraken/KRViewport.h b/kraken/KRViewport.h index 53e4697..56ce478 100755 --- a/kraken/KRViewport.h +++ b/kraken/KRViewport.h @@ -35,6 +35,8 @@ #include "aabb.h" +#include "KRShaderReflection.h" + class KRLight; class KRViewport diff --git a/kraken/nodes/KRDirectionalLight.cpp b/kraken/nodes/KRDirectionalLight.cpp index 7eaa292..8731006 100755 --- a/kraken/nodes/KRDirectionalLight.cpp +++ b/kraken/nodes/KRDirectionalLight.cpp @@ -160,9 +160,9 @@ void KRDirectionalLight::render(RenderInfo& ri) info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); - pShader->setPushConstant(KRPipeline::PushConstant::light_direction_view_space, light_direction_view_space); - pShader->setPushConstant(KRPipeline::PushConstant::light_color, m_color); - pShader->setPushConstant(KRPipeline::PushConstant::light_intensity, m_intensity * 0.01f); + pShader->setPushConstant(ShaderValue::light_direction_view_space, light_direction_view_space); + pShader->setPushConstant(ShaderValue::light_color, m_color); + pShader->setPushConstant(ShaderValue::light_intensity, m_intensity * 0.01f); pShader->bind(ri, getModelMatrix()); // TODO: Need to pass in the light index to the shader // Render a full screen quad diff --git a/kraken/nodes/KRLight.cpp b/kraken/nodes/KRLight.cpp index 429ae66..7729433 100755 --- a/kraken/nodes/KRLight.cpp +++ b/kraken/nodes/KRLight.cpp @@ -284,9 +284,9 @@ void KRLight::render(RenderInfo& ri) info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); - pParticleShader->setPushConstant(KRPipeline::PushConstant::light_color, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity); - pParticleShader->setPushConstant(KRPipeline::PushConstant::particle_origin, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero())); - pParticleShader->setPushConstant(KRPipeline::PushConstant::flare_size, m_dust_particle_size); + pParticleShader->setPushConstant(ShaderValue::light_color, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity); + pParticleShader->setPushConstant(ShaderValue::particle_origin, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero())); + pParticleShader->setPushConstant(ShaderValue::flare_size, m_dust_particle_size); pParticleShader->bind(ri, particleModelMatrix); // TODO: Pass light index to shader m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f); @@ -336,8 +336,8 @@ void KRLight::render(RenderInfo& ri) float slice_far = -ri.camera->settings.volumetric_environment_max_distance; float slice_spacing = (slice_far - slice_near) / slice_count; - pFogShader->setPushConstant(KRPipeline::PushConstant::slice_depth_scale, Vector2::Create(slice_near, slice_spacing)); - pFogShader->setPushConstant(KRPipeline::PushConstant::light_color, (m_color * ri.camera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f)); + pFogShader->setPushConstant(ShaderValue::slice_depth_scale, Vector2::Create(slice_near, slice_spacing)); + pFogShader->setPushConstant(ShaderValue::light_color, (m_color * ri.camera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f)); 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); @@ -426,8 +426,8 @@ void KRLight::render(RenderInfo& ri) KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); - pShader->setPushConstant(KRPipeline::PushConstant::material_alpha, 1.0f); - pShader->setPushConstant(KRPipeline::PushConstant::flare_size, m_flareSize); + pShader->setPushConstant(ShaderValue::material_alpha, 1.0f); + pShader->setPushConstant(ShaderValue::flare_size, m_flareSize); pShader->setImageBinding("diffuseTexture", m_pFlareTexture, getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER); pShader->bind(ri, getModelMatrix()); diff --git a/kraken/nodes/KRParticleSystemNewtonian.cpp b/kraken/nodes/KRParticleSystemNewtonian.cpp index b36b055..fcea5a5 100755 --- a/kraken/nodes/KRParticleSystemNewtonian.cpp +++ b/kraken/nodes/KRParticleSystemNewtonian.cpp @@ -105,7 +105,7 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri) info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); - pParticleShader->setPushConstant(KRPipeline::PushConstant::flare_size, 1.0f); + pParticleShader->setPushConstant(ShaderValue::flare_size, 1.0f); pParticleShader->bind(ri, getModelMatrix()); m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f); diff --git a/kraken/nodes/KRPointLight.cpp b/kraken/nodes/KRPointLight.cpp index 0c398ca..edd1418 100755 --- a/kraken/nodes/KRPointLight.cpp +++ b/kraken/nodes/KRPointLight.cpp @@ -116,11 +116,11 @@ 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); - pShader->setPushConstant(KRPipeline::PushConstant::light_color, m_color); - pShader->setPushConstant(KRPipeline::PushConstant::light_intensity, m_intensity * 0.01f); - pShader->setPushConstant(KRPipeline::PushConstant::light_decay_start, getDecayStart()); - pShader->setPushConstant(KRPipeline::PushConstant::light_cutoff, KRLIGHT_MIN_INFLUENCE); - pShader->setPushConstant(KRPipeline::PushConstant::light_position, light_position); + pShader->setPushConstant(ShaderValue::light_color, m_color); + pShader->setPushConstant(ShaderValue::light_intensity, m_intensity * 0.01f); + pShader->setPushConstant(ShaderValue::light_decay_start, getDecayStart()); + pShader->setPushConstant(ShaderValue::light_cutoff, KRLIGHT_MIN_INFLUENCE); + pShader->setPushConstant(ShaderValue::light_position, light_position); pShader->bind(ri, sphereModelMatrix); // TODO: Pass light index to shader if (bInsideLight) { diff --git a/kraken/nodes/KRSprite.cpp b/kraken/nodes/KRSprite.cpp index e0d72f3..08652ca 100755 --- a/kraken/nodes/KRSprite.cpp +++ b/kraken/nodes/KRSprite.cpp @@ -165,7 +165,7 @@ void KRSprite::render(RenderInfo& ri) info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); - pShader->setPushConstant(KRPipeline::PushConstant::material_alpha, m_spriteAlpha); + pShader->setPushConstant(ShaderValue::material_alpha, m_spriteAlpha); pShader->setImageBinding("diffuseTexture", m_pSpriteTexture, m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER); pShader->bind(ri, getModelMatrix()); diff --git a/kraken/resources/material/KRMaterial.cpp b/kraken/resources/material/KRMaterial.cpp index 827adff..9ea6d09 100755 --- a/kraken/resources/material/KRMaterial.cpp +++ b/kraken/resources/material/KRMaterial.cpp @@ -376,11 +376,11 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_ KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); // Rim highlighting parameters - pShader->setPushConstant(KRPipeline::PushConstant::rim_color, rim_color); - pShader->setPushConstant(KRPipeline::PushConstant::rim_power, rim_power); + pShader->setPushConstant(ShaderValue::rim_color, rim_color); + pShader->setPushConstant(ShaderValue::rim_power, rim_power); // Bind bones - if (pShader->hasPushConstant(KRPipeline::PushConstant::bone_transforms)) { + if (pShader->hasPushConstant(ShaderValue::bone_transforms)) { float bone_mats[256 * 16]; float* bone_mat_component = bone_mats; for (int bone_index = 0; bone_index < bones.size(); bone_index++) { @@ -407,40 +407,40 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_ *bone_mat_component++ = t[i]; } } - if (pShader->hasPushConstant(KRPipeline::PushConstant::bone_transforms)) { - pShader->setPushConstant(KRPipeline::PushConstant::bone_transforms, (Matrix4*)bone_mats, bones.size()); + if (pShader->hasPushConstant(ShaderValue::bone_transforms)) { + pShader->setPushConstant(ShaderValue::bone_transforms, (Matrix4*)bone_mats, bones.size()); } } - pShader->setPushConstant(KRPipeline::PushConstant::material_ambient, m_ambientColor + ri.camera->settings.ambient_intensity); + pShader->setPushConstant(ShaderValue::material_ambient, m_ambientColor + ri.camera->settings.ambient_intensity); if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_FORWARD_OPAQUE) { // We pre-multiply the light color with the material color in the forward renderer - pShader->setPushConstant(KRPipeline::PushConstant::material_diffuse, Vector3::Create(m_diffuseColor.x * ri.camera->settings.light_intensity.x, m_diffuseColor.y * ri.camera->settings.light_intensity.y, m_diffuseColor.z * ri.camera->settings.light_intensity.z)); + pShader->setPushConstant(ShaderValue::material_diffuse, Vector3::Create(m_diffuseColor.x * ri.camera->settings.light_intensity.x, m_diffuseColor.y * ri.camera->settings.light_intensity.y, m_diffuseColor.z * ri.camera->settings.light_intensity.z)); } else { - pShader->setPushConstant(KRPipeline::PushConstant::material_diffuse, m_diffuseColor); + pShader->setPushConstant(ShaderValue::material_diffuse, m_diffuseColor); } if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_FORWARD_OPAQUE) { // We pre-multiply the light color with the material color in the forward renderer - pShader->setPushConstant(KRPipeline::PushConstant::material_specular, Vector3::Create(m_specularColor.x * ri.camera->settings.light_intensity.x, m_specularColor.y * ri.camera->settings.light_intensity.y, m_specularColor.z * ri.camera->settings.light_intensity.z)); + pShader->setPushConstant(ShaderValue::material_specular, Vector3::Create(m_specularColor.x * ri.camera->settings.light_intensity.x, m_specularColor.y * ri.camera->settings.light_intensity.y, m_specularColor.z * ri.camera->settings.light_intensity.z)); } else { - pShader->setPushConstant(KRPipeline::PushConstant::material_specular, m_specularColor); + pShader->setPushConstant(ShaderValue::material_specular, m_specularColor); } - pShader->setPushConstant(KRPipeline::PushConstant::material_shininess, m_ns); - pShader->setPushConstant(KRPipeline::PushConstant::material_reflection, m_reflectionColor); - pShader->setPushConstant(KRPipeline::PushConstant::diffusetexture_scale, m_diffuseMapScale); - pShader->setPushConstant(KRPipeline::PushConstant::speculartexture_scale, m_specularMapScale); - pShader->setPushConstant(KRPipeline::PushConstant::reflectiontexture_scale, m_reflectionMapScale); - pShader->setPushConstant(KRPipeline::PushConstant::normaltexture_scale, m_normalMapScale); - pShader->setPushConstant(KRPipeline::PushConstant::diffusetexture_offset, m_diffuseMapOffset); - pShader->setPushConstant(KRPipeline::PushConstant::speculartexture_offset, m_specularMapOffset); - pShader->setPushConstant(KRPipeline::PushConstant::reflectiontexture_offset, m_reflectionMapOffset); - pShader->setPushConstant(KRPipeline::PushConstant::normaltexture_offset, m_normalMapOffset); + pShader->setPushConstant(ShaderValue::material_shininess, m_ns); + pShader->setPushConstant(ShaderValue::material_reflection, m_reflectionColor); + pShader->setPushConstant(ShaderValue::diffusetexture_scale, m_diffuseMapScale); + pShader->setPushConstant(ShaderValue::speculartexture_scale, m_specularMapScale); + pShader->setPushConstant(ShaderValue::reflectiontexture_scale, m_reflectionMapScale); + pShader->setPushConstant(ShaderValue::normaltexture_scale, m_normalMapScale); + pShader->setPushConstant(ShaderValue::diffusetexture_offset, m_diffuseMapOffset); + pShader->setPushConstant(ShaderValue::speculartexture_offset, m_specularMapOffset); + pShader->setPushConstant(ShaderValue::reflectiontexture_offset, m_reflectionMapOffset); + pShader->setPushConstant(ShaderValue::normaltexture_offset, m_normalMapOffset); - pShader->setPushConstant(KRPipeline::PushConstant::material_alpha, m_tr); + pShader->setPushConstant(ShaderValue::material_alpha, m_tr); if (bDiffuseMap) { m_pDiffuseMap->resetPoolExpiry(lod_coverage, KRTexture::TEXTURE_USAGE_DIFFUSE_MAP);