Infinitly tile floor around player in 3D?

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

I have a water plane texture that I need to tile around the player as they explore, I have some prototype code going but no matter what I try it visibly jumps if I move on more than one axis.

Does anyone have a better version of this code or know how to improve and fix it?

Here it is:

extends Node

# Define the player node when it loads in
@onready var player = $"Player"
@onready var scene = load("res://Assets/Enviroment/Water.tscn")
@onready var water = scene.instantiate() 
var _stored_pos
var _stored_x = 0
var _stored_z = 0

# Define relative possible positions 
const positions = [Vector3(0,0,0), Vector3(1,0,0), Vector3(-1,0,0), Vector3(0,0,1), Vector3(1,0,1), Vector3(-1,0,1), Vector3(0,0,-1), Vector3(1,0,-1), Vector3(-1,0,-1)]

func _ready():
	# Set the stored position when it loads in
	_stored_pos = player.position
	_spawn(player.position)

func _spawn(center):
	# get the player pos
	var _player_pos = player.position
	var _center_pos = center

	# Variable to store how many were spawned
	var item = 0

	for child in $"Water_Container".get_children():
		child.queue_free()

	# For every possible spawning position, spawn one
	for i in positions:
		# Define what to spawn (water)
		water = scene.instantiate() 
		# Spawn the water in the position * 90 to accomodate for size
		var pos = positions[item] * 90
		print(pos)
		water.position = _player_pos + pos
		print("spawning water")
		$"Water_Container".add_child(water)
		# Iterate the coutner 
		item += 1


func _process(delta: float):
	var player_pos = player.position
	var diff_x = player_pos.x - _stored_pos.x
	var diff_z = player_pos.z - _stored_pos.z

	if abs(diff_x) >= 67.5:
		_stored_x += int(diff_x / 90)
		_spawn(Vector3(_stored_x, 0, player_pos.z / 90))
		_stored_pos.x = player_pos.x

	if abs(diff_z) >= 45:
		_stored_z += int(diff_z / 45)
		_spawn(Vector3(player.position.x / 90, 0, _stored_z))
		_stored_pos.z = player_pos.z

This sounds like it could be done really easy with a shader. But I’m not good at shaders. I know there is a tile texture option.

If this is in reference to your water shader you could just keep using the noise texture as it should be able to infinatly generate coherent noise as the player moves.

No need to tile

I dont know how to make the noise texture relative to the world. Everything i tried just broke the shader in one way or another

This is what I found so far I wanted to make one myself but I can’t find the time. I think this should work for 3d even though they are doing it for 2d. And instead of auto scrolling with time you get the player position with a uniform.

The trick is to then move the mesh with the player in space, scrolling it in the opposite direction to show movement. And either make it big enough that it fades into the horizon, or make another mesh that is the same base color but without noise detail.

I think you could probably do a distance test and make it fade out in a circle around the player, but I don’t know how yet.