- Edited
- Solved -
Because I was sampling it from a SubViewport, I needed to add await RenderingServer.frame_post_draw before I sampled from it.
I have a bug I've been avoiding for a while, but I'm trying to take a second go at it.
My game makes a map through a shader, and uses a noise texture as the random element of the generation. However, I cannot change the NoiseTexture2D during runtime, no matter what I do. Here's my code.
var islandNoise = NoiseTexture2D.new()
islandNoise.width = 512
islandNoise.height = 512
islandNoise.generate_mipmaps = true
islandNoise.normalize = true
#0.0049... is a magic number
var texNoise = FastNoiseLite.new()
texNoise.noise_type = 1
texNoise.frequency = 0.0049
texNoise.fractal_octaves = 9
texNoise.fractal_lacunarity = 1.65
texNoise.fractal_gain = 0.5
texNoise.fractal_weighted_strength = 0.03
texNoise.seed = randi()
islandNoise.noise = texNoise
await islandNoise.changed
shaderProcess.get_material().set_shader_parameter("island_tex", islandNoise)
var island = $ShaderProcess.get_texture().get_image()
I even looked at it in the remote inspector, and the noiseTexture2D was the same. When I left it blank, it still didn't add a noiseTexture to the shader.