Removed deprecated material attributes
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

This commit is contained in:
2026-05-06 00:29:48 -07:00
parent 6d85afcd0e
commit b68a056011
9 changed files with 37 additions and 69 deletions

View File

@@ -712,7 +712,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
setPushConstant(ShaderValue::speculartexture, 1); setPushConstant(ShaderValue::speculartexture, 1);
// Sets the normalTexture variable to the third texture unit // Sets the normalTexture variable to the third texture unit
setPushConstant(ShaderValue::material_normaltexture, 2); setPushConstant(ShaderValue::material_normal_map_texture, 2);
// Sets the shadowTexture variable to the fourth texture unit // Sets the shadowTexture variable to the fourth texture unit
setPushConstant(ShaderValue::shadowtexture1, 3); setPushConstant(ShaderValue::shadowtexture1, 3);

View File

@@ -139,21 +139,6 @@ const char* SHADER_VALUE_NAMES[] = {
"material_transmission_map_rotation", "material_transmission_map_rotation",
"material_transmission_factor", "material_transmission_factor",
// Deprecated material attributes...
"material_diffuse",
"material_specular",
"material_speculartexture_scale",
"material_speculartexture_offset",
"material_alpha",
"material_shininess",
"material_normaltexture",
"material_normaltexture_scale",
"material_normaltexture_offset",
"material_diffusetexture_scale",
"material_diffusetexture_offset",
"material_ambienttexture_scale",
"material_ambienttexture_offset",
"light_position", // PushConstant::light_position "light_position", // PushConstant::light_position
"light_direction_model_space", // PushConstant::light_direction_model_space "light_direction_model_space", // PushConstant::light_direction_model_space
"light_direction_view_space", // PushConstant::light_direction_view_space "light_direction_view_space", // PushConstant::light_direction_view_space

View File

@@ -157,21 +157,6 @@ enum class ShaderValue : uint8_t
material_transmission_map_rotation, material_transmission_map_rotation,
material_transmission_factor, material_transmission_factor,
// Deprecated material attributes...
material_diffuse,
material_specular,
material_speculartexture_scale,
material_speculartexture_offset,
material_alpha,
material_shininess,
material_normaltexture,
material_normaltexture_scale,
material_normaltexture_offset,
material_diffusetexture_scale,
material_diffusetexture_offset,
material_ambienttexture_scale,
material_ambienttexture_offset,
light_position, light_position,
light_direction_model_space, light_direction_model_space,
light_direction_view_space, light_direction_view_space,

View File

@@ -361,7 +361,6 @@ void KRLight::render(RenderInfo& ri)
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
pShader->setPushConstant(ShaderValue::material_alpha, 1.0f);
pShader->setImageBinding("diffuseTexture", m_flareTexture.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER); pShader->setImageBinding("diffuseTexture", m_flareTexture.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
pShader->bind(ri, getModelMatrix()); pShader->bind(ri, getModelMatrix());

View File

@@ -149,9 +149,6 @@ void KRSprite::render(RenderInfo& ri)
bool KRSprite::getShaderValue(ShaderValue value, float* output) const bool KRSprite::getShaderValue(ShaderValue value, float* output) const
{ {
switch (value) { switch (value) {
case ShaderValue::material_alpha:
*output = m_spriteAlpha;
return true;
} }
return KRNode::getShaderValue(value, output); return KRNode::getShaderValue(value, output);
} }

View File

@@ -730,11 +730,8 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
bool KRMaterial::getShaderValue(ShaderValue value, float* output) const bool KRMaterial::getShaderValue(ShaderValue value, float* output) const
{ {
switch (value) { switch (value) {
case ShaderValue::material_alpha: case ShaderValue::material_roughness_factor:
*output = m_baseColorFactor[3]; *output = m_roughnessFactor;
return true;
case ShaderValue::material_shininess:
*output = 1.0f - m_roughnessFactor;
return true; return true;
} }
return false; return false;
@@ -743,22 +740,22 @@ bool KRMaterial::getShaderValue(ShaderValue value, float* output) const
bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const
{ {
switch (value) { switch (value) {
case ShaderValue::material_diffusetexture_scale: case ShaderValue::material_baseColor_map_scale:
*output = m_baseColorMap.scale; *output = m_baseColorMap.scale;
return true; return true;
case ShaderValue::material_speculartexture_scale: case ShaderValue::material_specularColor_map_scale:
*output = m_specularColorMap.scale; *output = m_specularColorMap.scale;
return true; return true;
case ShaderValue::material_normaltexture_scale: case ShaderValue::material_normal_map_scale:
*output = m_normalMap.scale; *output = m_normalMap.scale;
return true; return true;
case ShaderValue::material_diffusetexture_offset: case ShaderValue::material_baseColor_map_offset:
*output = m_baseColorMap.offset; *output = m_baseColorMap.offset;
return true; return true;
case ShaderValue::material_speculartexture_offset: case ShaderValue::material_specularColor_map_offset:
*output = m_specularColorMap.offset; *output = m_specularColorMap.offset;
return true; return true;
case ShaderValue::material_normaltexture_offset: case ShaderValue::material_normal_map_offset:
*output = m_normalMap.offset; *output = m_normalMap.offset;
return true; return true;
} }
@@ -768,12 +765,19 @@ bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const
bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector3* output) const bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector3* output) const
{ {
switch (value) { switch (value) {
case ShaderValue::material_diffuse: case ShaderValue::material_specularColor_factor:
*output = hydra::Vector3::Create(m_baseColorFactor);
return true;
case ShaderValue::material_specular:
*output = m_specularColorFactor; *output = m_specularColorFactor;
return true; return true;
} }
return false; return false;
} }
bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector4* output) const
{
switch (value) {
case ShaderValue::material_baseColor_factor:
*output = m_baseColorFactor;
return true;
}
return false;
}

View File

@@ -158,4 +158,5 @@ private:
bool getShaderValue(ShaderValue value, float* output) const final; bool getShaderValue(ShaderValue value, float* output) const final;
bool getShaderValue(ShaderValue value, hydra::Vector2* output) const final; bool getShaderValue(ShaderValue value, hydra::Vector2* output) const final;
bool getShaderValue(ShaderValue value, hydra::Vector3* output) const final; bool getShaderValue(ShaderValue value, hydra::Vector3* output) const final;
bool getShaderValue(ShaderValue value, hydra::Vector4* output) const final;
}; };

View File

@@ -234,7 +234,7 @@ layout( push_constant ) uniform constants
#endif #endif
#endif #endif
#else #else
mediump float material_shininess; mediump float material_roughness_factor;
#endif #endif
#if GBUFFER_PASS == 1 #if GBUFFER_PASS == 1
#if HAS_NORMAL_MAP == 1 #if HAS_NORMAL_MAP == 1
@@ -322,7 +322,7 @@ layout( push_constant ) uniform constants
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1 #if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
mediump float material_shininess; mediump float material_roughness_factor;
#if HAS_NORMAL_MAP == 1 #if HAS_NORMAL_MAP == 1
sampler2D normalTexture; sampler2D normalTexture;
#endif #endif
@@ -346,9 +346,8 @@ layout( push_constant ) uniform constants
#endif #endif
#else #else
lowp vec3 material_ambient; lowp vec3 material_ambient;
lowp vec3 material_diffuse; lowp vec4 material_baseColor_factor;
lowp vec3 material_specular; lowp vec3 material_specularColor_factor;
lowp float material_alpha;
#if HAS_DIFFUSE_MAP == 1 #if HAS_DIFFUSE_MAP == 1
@@ -432,7 +431,7 @@ void main()
#else #else
mediump vec3 view_space_normal = vec3(model_view_inverse_transpose_matrix * vec4(normal, 1.0)); mediump vec3 view_space_normal = vec3(model_view_inverse_transpose_matrix * vec4(normal, 1.0));
#endif #endif
colorOut = vec4(view_space_normal * 0.5 + 0.5, PushConstants.material_shininess / 100.0); colorOut = vec4(view_space_normal * 0.5 + 0.5, (1.0 - PushConstants.material_roughness_factor) / 100.0);
#else #else
#if HAS_DIFFUSE_MAP == 1 #if HAS_DIFFUSE_MAP == 1
#if ALPHA_TEST == 1 #if ALPHA_TEST == 1
@@ -457,13 +456,13 @@ void main()
mediump float lamberFactor = max(0.0,dot(lightVec, normal)); mediump float lamberFactor = max(0.0,dot(lightVec, normal));
#endif #endif
mediump float specularFactor = 0.0; mediump float specularFactor = 0.0;
if(PushConstants.material_shininess > 0.0) { if(PushConstants.material_roughness_factor < 1.0) {
#if GBUFFER_PASS == 3 #if GBUFFER_PASS == 3
specularFactor = gbuffer_specular_factor; specularFactor = gbuffer_specular_factor;
#else #else
mediump float halfVecDot = dot(halfVec,normal); mediump float halfVecDot = dot(halfVec,normal);
if(halfVecDot > 0.0) { if(halfVecDot > 0.0) {
specularFactor = max(0.0,pow(halfVecDot, PushConstants.material_shininess)); specularFactor = max(0.0,pow(halfVecDot, 1.0 - PushConstants.material_roughness_factor));
} }
#endif #endif
} }
@@ -546,23 +545,23 @@ void main()
#if ENABLE_DIFFUSE == 1 #if ENABLE_DIFFUSE == 1
// -------------------- Add diffuse light -------------------- // -------------------- Add diffuse light --------------------
colorOut += diffuseMaterial * vec4(PushConstants.material_diffuse * lamberFactor, 1.0); colorOut += diffuseMaterial * vec4(PushConstants.material_baseColor_factor.rgb * lamberFactor, 1.0);
#endif #endif
// -------------------- Apply material_alpha -------------------- // -------------------- Apply material_alpha --------------------
#if ALPHA_BLEND == 1 #if ALPHA_BLEND == 1
colorOut.a = diffuseMaterial.a; colorOut.a = diffuseMaterial.a;
colorOut *= material_alpha; colorOut *= material_baseColor_factor.a;
#endif #endif
// -------------------- Add specular light -------------------- // -------------------- Add specular light --------------------
// Additive, not masked against diffuse alpha // Additive, not masked against diffuse alpha
#if ENABLE_SPECULAR == 1 #if ENABLE_SPECULAR == 1
#if HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1 #if HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1
colorOut.rgb += material_specular * vec3(texture(specularTexture, spec_uv)) * specularFactor; colorOut.rgb += material_specularColor_factor * vec3(texture(specularTexture, spec_uv)) * specularFactor;
#else #else
colorOut.rgb += material_specular * specularFactor; colorOut.rgb += material_specularColor_factor * specularFactor;
#endif #endif
#endif #endif

View File

@@ -81,7 +81,7 @@ layout( push_constant ) uniform constants
#endif #endif
#endif #endif
#else #else
mediump float material_shininess; mediump float material_roughness_factor;
#endif #endif
#if GBUFFER_PASS == 1 #if GBUFFER_PASS == 1
#if HAS_NORMAL_MAP == 1 #if HAS_NORMAL_MAP == 1
@@ -169,7 +169,7 @@ layout( push_constant ) uniform constants
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1 #if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
mediump float material_shininess; mediump float material_roughness_factor;
#if HAS_NORMAL_MAP == 1 #if HAS_NORMAL_MAP == 1
sampler2D normalTexture; sampler2D normalTexture;
#endif #endif
@@ -193,10 +193,8 @@ layout( push_constant ) uniform constants
#endif #endif
#else #else
lowp vec3 material_ambient; lowp vec3 material_ambient;
lowp vec3 material_diffuse; lowp vec4 material_baseColor_factor;
lowp vec3 material_specular; lowp vec3 material_specularColor_factor;
lowp float material_alpha;
#if HAS_DIFFUSE_MAP == 1 #if HAS_DIFFUSE_MAP == 1
sampler2D diffuseTexture; sampler2D diffuseTexture;
@@ -493,7 +491,7 @@ void main()
// ------ Calculate per-vertex lighting ------ // ------ Calculate per-vertex lighting ------
mediump vec3 halfVec = normalize((normalize(PushConstants.camera_position_model_space - vertex_position_skinned) + PushConstants.light_direction_model_space)); // Normalizing anyways, no need to divide by 2 mediump vec3 halfVec = normalize((normalize(PushConstants.camera_position_model_space - vertex_position_skinned) + PushConstants.light_direction_model_space)); // Normalizing anyways, no need to divide by 2
lamberFactor = max(0.0,dot(PushConstants.light_direction_model_space, vertex_normal_skinned)); lamberFactor = max(0.0,dot(PushConstants.light_direction_model_space, vertex_normal_skinned));
specularFactor = max(0.0,pow(dot(halfVec,vertex_normal_skinned), PushConstants.material_shininess)); specularFactor = max(0.0,pow(dot(halfVec,vertex_normal_skinned), 1.0 - PushConstants.material_roughness_factor));
#endif #endif
#endif #endif
} }