I appreciate the thought and the code. I actually have a parallax scrolling background in the game that worked great with an image. It just doesn't work with the shader I'm using. The shader itself maintains the same look no matter how you move the texture it is applied to. So I was trying to work with the shader. Unfortunately, the direction of the shader only moved with a float. So I had to change it to a Vector2, then rotate it, then turn off the constant rotation, then do this:
# Given a player velocity, animate the starfield. func _physics_process(_delta: float) -> void:
if Game.starfield_panning:
var limited_vector := player.velocity.limit_length()
var panning_vector := Vector2(limited_vector.y, limited_vector.x)
#print(panning_vector)
starfield_texture.material.set_shader_parameter("pan_speed", panning_vector * 1.0)
if Game.starfield_acceleration:
if player.velocity.x < 0 or player.velocity.y < 0:
starfield_texture.material.set_shader_parameter("anim_speed", 0.75)
elif player.velocity.x > 0 or player.velocity.y > 0:
starfield_texture.material.set_shader_parameter("anim_speed", -0.75)
else:
starfield_texture.material.set_shader_parameter("anim_speed", 0.2)
The problem is it always looks like you're jumping into warp speed, even if I use really low numbers like 0.1 (instead of 0.75). In this case I think I just needed to rebuild the shader from the ground up - and it's a bit outside my wheelhouse.