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
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:
@@ -712,7 +712,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
|
||||
setPushConstant(ShaderValue::speculartexture, 1);
|
||||
|
||||
// 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
|
||||
setPushConstant(ShaderValue::shadowtexture1, 3);
|
||||
|
||||
@@ -139,21 +139,6 @@ const char* SHADER_VALUE_NAMES[] = {
|
||||
"material_transmission_map_rotation",
|
||||
"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_direction_model_space", // PushConstant::light_direction_model_space
|
||||
"light_direction_view_space", // PushConstant::light_direction_view_space
|
||||
|
||||
@@ -157,21 +157,6 @@ enum class ShaderValue : uint8_t
|
||||
material_transmission_map_rotation,
|
||||
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_direction_model_space,
|
||||
light_direction_view_space,
|
||||
|
||||
@@ -361,7 +361,6 @@ void KRLight::render(RenderInfo& ri)
|
||||
|
||||
|
||||
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->bind(ri, getModelMatrix());
|
||||
|
||||
|
||||
@@ -149,9 +149,6 @@ void KRSprite::render(RenderInfo& ri)
|
||||
bool KRSprite::getShaderValue(ShaderValue value, float* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::material_alpha:
|
||||
*output = m_spriteAlpha;
|
||||
return true;
|
||||
}
|
||||
return KRNode::getShaderValue(value, output);
|
||||
}
|
||||
|
||||
@@ -730,11 +730,8 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
||||
bool KRMaterial::getShaderValue(ShaderValue value, float* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::material_alpha:
|
||||
*output = m_baseColorFactor[3];
|
||||
return true;
|
||||
case ShaderValue::material_shininess:
|
||||
*output = 1.0f - m_roughnessFactor;
|
||||
case ShaderValue::material_roughness_factor:
|
||||
*output = m_roughnessFactor;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -743,22 +740,22 @@ bool KRMaterial::getShaderValue(ShaderValue value, float* output) const
|
||||
bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::material_diffusetexture_scale:
|
||||
case ShaderValue::material_baseColor_map_scale:
|
||||
*output = m_baseColorMap.scale;
|
||||
return true;
|
||||
case ShaderValue::material_speculartexture_scale:
|
||||
case ShaderValue::material_specularColor_map_scale:
|
||||
*output = m_specularColorMap.scale;
|
||||
return true;
|
||||
case ShaderValue::material_normaltexture_scale:
|
||||
case ShaderValue::material_normal_map_scale:
|
||||
*output = m_normalMap.scale;
|
||||
return true;
|
||||
case ShaderValue::material_diffusetexture_offset:
|
||||
case ShaderValue::material_baseColor_map_offset:
|
||||
*output = m_baseColorMap.offset;
|
||||
return true;
|
||||
case ShaderValue::material_speculartexture_offset:
|
||||
case ShaderValue::material_specularColor_map_offset:
|
||||
*output = m_specularColorMap.offset;
|
||||
return true;
|
||||
case ShaderValue::material_normaltexture_offset:
|
||||
case ShaderValue::material_normal_map_offset:
|
||||
*output = m_normalMap.offset;
|
||||
return true;
|
||||
}
|
||||
@@ -768,12 +765,19 @@ bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const
|
||||
bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector3* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::material_diffuse:
|
||||
*output = hydra::Vector3::Create(m_baseColorFactor);
|
||||
return true;
|
||||
case ShaderValue::material_specular:
|
||||
case ShaderValue::material_specularColor_factor:
|
||||
*output = m_specularColorFactor;
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -158,4 +158,5 @@ private:
|
||||
bool getShaderValue(ShaderValue value, float* 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::Vector4* output) const final;
|
||||
};
|
||||
|
||||
@@ -234,7 +234,7 @@ layout( push_constant ) uniform constants
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
mediump float material_shininess;
|
||||
mediump float material_roughness_factor;
|
||||
#endif
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
@@ -322,7 +322,7 @@ layout( push_constant ) uniform constants
|
||||
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
|
||||
mediump float material_shininess;
|
||||
mediump float material_roughness_factor;
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
sampler2D normalTexture;
|
||||
#endif
|
||||
@@ -346,9 +346,8 @@ layout( push_constant ) uniform constants
|
||||
#endif
|
||||
#else
|
||||
lowp vec3 material_ambient;
|
||||
lowp vec3 material_diffuse;
|
||||
lowp vec3 material_specular;
|
||||
lowp float material_alpha;
|
||||
lowp vec4 material_baseColor_factor;
|
||||
lowp vec3 material_specularColor_factor;
|
||||
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
@@ -432,7 +431,7 @@ void main()
|
||||
#else
|
||||
mediump vec3 view_space_normal = vec3(model_view_inverse_transpose_matrix * vec4(normal, 1.0));
|
||||
#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
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
#if ALPHA_TEST == 1
|
||||
@@ -457,13 +456,13 @@ void main()
|
||||
mediump float lamberFactor = max(0.0,dot(lightVec, normal));
|
||||
#endif
|
||||
mediump float specularFactor = 0.0;
|
||||
if(PushConstants.material_shininess > 0.0) {
|
||||
if(PushConstants.material_roughness_factor < 1.0) {
|
||||
#if GBUFFER_PASS == 3
|
||||
specularFactor = gbuffer_specular_factor;
|
||||
#else
|
||||
mediump float halfVecDot = dot(halfVec,normal);
|
||||
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
|
||||
}
|
||||
@@ -546,23 +545,23 @@ void main()
|
||||
|
||||
#if ENABLE_DIFFUSE == 1
|
||||
// -------------------- Add diffuse light --------------------
|
||||
colorOut += diffuseMaterial * vec4(PushConstants.material_diffuse * lamberFactor, 1.0);
|
||||
colorOut += diffuseMaterial * vec4(PushConstants.material_baseColor_factor.rgb * lamberFactor, 1.0);
|
||||
#endif
|
||||
|
||||
// -------------------- Apply material_alpha --------------------
|
||||
|
||||
#if ALPHA_BLEND == 1
|
||||
colorOut.a = diffuseMaterial.a;
|
||||
colorOut *= material_alpha;
|
||||
colorOut *= material_baseColor_factor.a;
|
||||
#endif
|
||||
|
||||
// -------------------- Add specular light --------------------
|
||||
// Additive, not masked against diffuse alpha
|
||||
#if ENABLE_SPECULAR == 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
|
||||
colorOut.rgb += material_specular * specularFactor;
|
||||
colorOut.rgb += material_specularColor_factor * specularFactor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ layout( push_constant ) uniform constants
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
mediump float material_shininess;
|
||||
mediump float material_roughness_factor;
|
||||
#endif
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
@@ -169,7 +169,7 @@ layout( push_constant ) uniform constants
|
||||
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
|
||||
mediump float material_shininess;
|
||||
mediump float material_roughness_factor;
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
sampler2D normalTexture;
|
||||
#endif
|
||||
@@ -193,10 +193,8 @@ layout( push_constant ) uniform constants
|
||||
#endif
|
||||
#else
|
||||
lowp vec3 material_ambient;
|
||||
lowp vec3 material_diffuse;
|
||||
lowp vec3 material_specular;
|
||||
lowp float material_alpha;
|
||||
|
||||
lowp vec4 material_baseColor_factor;
|
||||
lowp vec3 material_specularColor_factor;
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
sampler2D diffuseTexture;
|
||||
@@ -493,7 +491,7 @@ void main()
|
||||
// ------ 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
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user