-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNebula.gd
55 lines (39 loc) · 1.31 KB
/
Nebula.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@tool
extends Sprite2D
# class member variables go here, for example:
@export var seede = 1234567 : set = set_seed
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
# this is for the background nebula
texture.set_size_override(Vector2i(1150, 768*2))
randomize()
#seede = randi()
var s = randi()
set_seed(s)
seede = s
print("Seed" + str(seede))
#pass
func set_seed(value):
rand_from_seed(value)
var off = [randf() * 100, randf() * 100]
var scale_n = (randf() * 2 + 1) / get_texture().get_height()
# shaders don't know the Godot color type
var color = Vector3(randf(), randf(), randf())
var color2 = Vector3(randf(), randf(), randf())
var density = randf() * 0.2
var falloff = randf() * 2.0 + 3.0
print("Set up values: " + str(off) + " " + str(scale_n) + " " + str(color) + " " + str(density) + " " + str(falloff))
var m = get_material()
m.set_shader_parameter("offset", off)
m.set_shader_parameter("scale", scale_n)
m.set_shader_parameter("color", color)
m.set_shader_parameter("color2", color2)
m.set_shader_parameter("density", density)
m.set_shader_parameter("falloff", falloff)
print("Sent values to shader")
#pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass