@@ -152,8 +152,8 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
152152 lnormal = normal;
153153 }
154154
155- int uv_x = CLAMP (int (Math::fposmod (uv.x , (real_t )1.0 ) * bake_texture_size), 0 , bake_texture_size - 1 );
156- int uv_y = CLAMP (int (Math::fposmod (uv.y , (real_t )1.0 ) * bake_texture_size), 0 , bake_texture_size - 1 );
155+ int uv_x = CLAMP (int (Math::fposmod (uv.x * p_material. uv1_scale . x + p_material. uv1_offset . x , (real_t )1.0 ) * bake_texture_size), 0 , bake_texture_size - 1 );
156+ int uv_y = CLAMP (int (Math::fposmod (uv.y * p_material. uv1_scale . y + p_material. uv1_offset . y , (real_t )1.0 ) * bake_texture_size), 0 , bake_texture_size - 1 );
157157
158158 int ofs = uv_y * bake_texture_size + uv_x;
159159 albedo_accum.r += p_material.albedo [ofs].r ;
@@ -184,8 +184,8 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
184184 lnormal = normal;
185185 }
186186
187- int uv_x = CLAMP (Math::fposmod (uv.x , (real_t )1.0 ) * bake_texture_size, 0 , bake_texture_size - 1 );
188- int uv_y = CLAMP (Math::fposmod (uv.y , (real_t )1.0 ) * bake_texture_size, 0 , bake_texture_size - 1 );
187+ int uv_x = CLAMP (Math::fposmod (uv.x * p_material. uv1_scale . x + p_material. uv1_offset . x , (real_t )1.0 ) * bake_texture_size, 0 , bake_texture_size - 1 );
188+ int uv_y = CLAMP (Math::fposmod (uv.y * p_material. uv1_scale . y + p_material. uv1_offset . y , (real_t )1.0 ) * bake_texture_size, 0 , bake_texture_size - 1 );
189189
190190 int ofs = uv_y * bake_texture_size + uv_x;
191191
@@ -377,11 +377,15 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
377377 mc.emission = _get_bake_texture (empty, Color (0 , 0 , 0 ), Color (0 , 0 , 0 ));
378378 }
379379
380+ mc.uv1_scale = mat->get_uv1_scale ();
381+ mc.uv1_offset = mat->get_uv1_offset ();
380382 } else {
381383 Ref<Image> empty;
382384
383385 mc.albedo = _get_bake_texture (empty, Color (0 , 0 , 0 ), Color (1 , 1 , 1 ));
384386 mc.emission = _get_bake_texture (empty, Color (0 , 0 , 0 ), Color (0 , 0 , 0 ));
387+ mc.uv1_scale = Vector3 (1 , 1 , 1 );
388+ mc.uv1_offset = Vector3 (0 , 0 , 0 );
385389 }
386390
387391 material_cache[p_material] = mc;
0 commit comments