Guest User

Untitled

a guest
Jul 31st, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. hi agdg, this is the scene node's script that is setting stuff on a sprite2d:
  2.  
  3. extends Node2D
  4. var bg_seed_timer = 0
  5. const bg_seed_change_duration = 2.0
  6. var bg_next_texture
  7. var bg
  8. func _ready():
  9. bg = get_node("background")
  10. bg_next_texture = bg.texture.duplicate()
  11. bg_next_texture.noise = FastNoiseLite.new()
  12. bg_next_texture.noise.seed = randi()
  13. bg.material.set_shader_parameter("next_texture",bg_next_texture)
  14. #bg.material.set_shader_parameter("starttime",fmod(Time.get_unix_time_from_system(),3600))
  15. return
  16. func _physics_process(delta):
  17. bg_seed_timer += delta
  18. if bg_seed_timer >= bg_seed_change_duration:
  19. bg_seed_timer -= bg_seed_change_duration
  20. bg.texture.noise.seed = bg_next_texture.noise.seed
  21. bg_next_texture.noise.seed = randi()
  22. #await bg_next_texture.changed
  23. #await bg.texture.changed
  24. bg.material.set_shader_parameter("timebump",bg_seed_timer/bg_seed_change_duration)
  25. return
  26.  
  27. and this is the shader for that sprite (trimmed some stuff that's not running during tests):
  28. shader_type canvas_item;
  29. uniform float starttime;
  30. uniform sampler2D next_texture;
  31. uniform float timebump;
  32. void fragment() {
  33. vec2 uv = UV;
  34. COLOR = mix(texture(TEXTURE,uv),texture(next_texture,uv),timebump);
  35. }
  36.  
  37. i am passing a float "timebump" on every frame instead of passing the initial time to the shader for testing purposes, i know it can be frowned at...
  38.  
Advertisement
Add Comment
Please, Sign In to add comment