Skip to content

Commit

Permalink
Fix shader crash when using unary minus in expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaosus committed Sep 11, 2024
1 parent 4788f54 commit eadfeb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions servers/rendering/shader_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::Scalar> &p
}

case SL::TYPE_INT:
return itos(p_values[0].sint);
return itos(Math::abs(p_values[0].sint)); // To prevent writing unary minus twice.
case SL::TYPE_IVEC2:
case SL::TYPE_IVEC3:
case SL::TYPE_IVEC4: {
Expand Down Expand Up @@ -238,7 +238,7 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::Scalar> &p
return text;
} break;
case SL::TYPE_FLOAT:
return f2sp0(p_values[0].real);
return f2sp0(Math::abs(p_values[0].real)); // To prevent writing unary minus twice.
case SL::TYPE_VEC2:
case SL::TYPE_VEC3:
case SL::TYPE_VEC4: {
Expand Down

0 comments on commit eadfeb3

Please sign in to comment.