Reduced glitch textures when pressing generate button.

Still some glitches remain when changing the resolution, though.
WorldChunkRefactoring
Martin Felis 2023-06-13 22:29:05 +02:00
parent f21db2ac4f
commit b672d4556a
4 changed files with 7 additions and 5 deletions

View File

@ -202,7 +202,7 @@ public class Game : Spatial
Transform cameraTransform = _camera.Transform;
cameraTransform.origin = _player.GlobalTranslation + _cameraOffset;
// _camera.Transform = cameraTransform;
_camera.Transform = cameraTransform;
}

View File

@ -19,7 +19,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0096302, 0, 0 )
script = ExtResource( 1 )
[node name="Mesh" type="MeshInstance" parent="."]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, -5, 0 )
transform = Transform( -4.24e-08, 0, 0.97, 0, 1, 0, -0.97, 0, -4.24e-08, 0, -5, 0 )
mesh = SubResource( 6 )
material/0 = ExtResource( 2 )

View File

@ -159,6 +159,7 @@ public class TileWorld : Spatial
private void OnHeightMapChanged()
{
_currentGenerationState = GenerationState.Heightmap;
_heightmapOffscreenViewport.RenderTargetUpdateMode = Viewport.UpdateMode.Once;
}
private void OnMapGenerationComplete()
@ -232,6 +233,7 @@ public class TileWorld : Spatial
imageTexture.CreateFromImage(Heightmap);
imageTexture.Flags = 0;
_worldOffscreenTextureRect.Texture = imageTexture;
_worldOffscreenViewport.RenderTargetUpdateMode = Viewport.UpdateMode.Once;
}
else if (_currentGenerationState == GenerationState.Color)
{
@ -317,7 +319,7 @@ public class TileWorld : Spatial
// TODO: coordinates do not match for bigger maps
return new Vector3(
tileCenter.x - Size * 0.75f * 0.5f,
tileCenter.x - Mathf.Round(Size * 0.75f * 0.5f),
GetHeightAtOffset(offsetCoord),
tileCenter.y + (Mathf.Sqrt(3) / 2) * Size * 0.5f);
}

View File

@ -25,7 +25,7 @@ hdr = false
disable_3d = true
usage = 0
render_target_v_flip = true
render_target_update_mode = 3
render_target_update_mode = 1
[node name="TextureRect" type="TextureRect" parent="WorldOffscreenViewport"]
material = ExtResource( 3 )
@ -41,7 +41,7 @@ hdr = false
disable_3d = true
usage = 0
render_target_v_flip = true
render_target_update_mode = 3
render_target_update_mode = 1
[node name="TextureRect" type="TextureRect" parent="HeightmapOffscreenViewport"]
material = ExtResource( 4 )