Advertisement
Miziziziz

Godot rand shader parent script

Jun 8th, 2018
2,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #goes on a ColorRect node that is the child of a CanvasLayer node
  2. #be sure to set the bottom and right anchor to 1 so it covers the whole scene
  3. extends ColorRect
  4.  
  5. export var grain_bounce = 0.4
  6. export var frame_switch_time = 0.08 #how often to randomize the film grain
  7. var cur_time = 0
  8.  
  9. func _process(delta):
  10. cur_time += delta
  11. if cur_time > frame_switch_time:
  12. cur_time = 0
  13. material.set_shader_param("randx", randf() * grain_bounce)
  14. material.set_shader_param("randy", randf() * grain_bounce)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement