2
0
Эх сурвалжийг харах

Merge pull request #53233 from metinc/fix-animated-sprite-precision-error

Rémi Verschelde 4 жил өмнө
parent
commit
bd7bea2087

+ 1 - 1
scene/2d/canvas_item.cpp

@@ -148,7 +148,7 @@ void CanvasItemMaterial::_update_shader() {
 		code += "\t\tparticle_frame = mod(particle_frame, particle_total_frames);\n";
 		code += "\t}";
 		code += "\tUV /= vec2(h_frames, v_frames);\n";
-		code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
+		code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n";
 		code += "}\n";
 	}
 

+ 1 - 1
scene/resources/material.cpp

@@ -672,7 +672,7 @@ void SpatialMaterial::_update_shader() {
 			code += "\t\tparticle_frame = mod(particle_frame, particle_total_frames);\n";
 			code += "\t}";
 			code += "\tUV /= vec2(h_frames, v_frames);\n";
-			code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
+			code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n";
 		} break;
 	}