Merge pull request #65353 from QbieShay/qbee/fix-billboard-nonuniform-scale
This commit is contained in:
commit
0c4bdf443d
2 changed files with 9 additions and 3 deletions
|
@ -955,11 +955,14 @@ void BaseMaterial3D::_update_shader() {
|
|||
} break;
|
||||
case BILLBOARD_PARTICLES: {
|
||||
//make billboard
|
||||
code += " mat4 mat_world = mat4(normalize(INV_VIEW_MATRIX[0]) * length(MODEL_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]) * length(MODEL_MATRIX[0]),normalize(INV_VIEW_MATRIX[2]) * length(MODEL_MATRIX[2]), MODEL_MATRIX[3]);\n";
|
||||
code += " mat4 mat_world = mat4(normalize(INV_VIEW_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]) ,normalize(INV_VIEW_MATRIX[2]), MODEL_MATRIX[3]);\n";
|
||||
//rotate by rotation
|
||||
code += " mat_world = mat_world * mat4(vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n";
|
||||
//set modelview
|
||||
code += " MODELVIEW_MATRIX = VIEW_MATRIX * mat_world;\n";
|
||||
if (flags[FLAG_BILLBOARD_KEEP_SCALE]) {
|
||||
code += " MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(MODEL_MATRIX[0].xyz), 0.0, 0.0, 0.0),vec4(0.0, length(MODEL_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(MODEL_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n";
|
||||
}
|
||||
//set modelview normal
|
||||
code += " MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);\n";
|
||||
|
||||
|
|
|
@ -7606,8 +7606,11 @@ String VisualShaderNodeBillboard::generate_code(Shader::Mode p_mode, VisualShade
|
|||
break;
|
||||
case BILLBOARD_TYPE_PARTICLES:
|
||||
code += " {\n";
|
||||
code += " mat4 __wm = mat4(normalize(INV_VIEW_MATRIX[0]) * length(MODEL_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]) * length(MODEL_MATRIX[0]), normalize(INV_VIEW_MATRIX[2]) * length(MODEL_MATRIX[2]), MODEL_MATRIX[3]);\n";
|
||||
code += " mat4 __wm = mat4(normalize(INV_VIEW_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]), normalize(INV_VIEW_MATRIX[2]), MODEL_MATRIX[3]);\n";
|
||||
code += " __wm = __wm * mat4(vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n";
|
||||
if (keep_scale) {
|
||||
code += " __wm = __wm * mat4(vec4(length(MODEL_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, length(MODEL_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(MODEL_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n";
|
||||
}
|
||||
code += " " + p_output_vars[0] + " = VIEW_MATRIX * __wm;\n";
|
||||
code += " }\n";
|
||||
break;
|
||||
|
@ -7650,7 +7653,7 @@ bool VisualShaderNodeBillboard::is_keep_scale_enabled() const {
|
|||
Vector<StringName> VisualShaderNodeBillboard::get_editable_properties() const {
|
||||
Vector<StringName> props;
|
||||
props.push_back("billboard_type");
|
||||
if (billboard_type == BILLBOARD_TYPE_ENABLED || billboard_type == BILLBOARD_TYPE_FIXED_Y) {
|
||||
if (billboard_type == BILLBOARD_TYPE_ENABLED || billboard_type == BILLBOARD_TYPE_FIXED_Y || billboard_type == BILLBOARD_TYPE_PARTICLES) {
|
||||
props.push_back("keep_scale");
|
||||
}
|
||||
return props;
|
||||
|
|
Loading…
Reference in a new issue