How to edit noise texture parameters, like period, lacunarity inside shader material?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jonilearncode

How can i access the period, lacunarity, etc of a noise texture inside the shader? The final intention is at run-time update a shader like simplex noise (fog) zoom/period aspect of it.

shader_type canvas_item;

uniform vec2 offset;
uniform float period; --------------------------> at gdscript i pass this value

uniform float intensity : hint_range(0.1, 2.0);
uniform sampler2D noise_texture : hint_albedo; --------------------> this is a noise texture created on editor

shader code below

void fragment() {
vec2 coord = SCREEN_UV + offset;

#### pseudo_code ########
noise_texture.period = period ---> how to update the period of the noise texture ??? Should be inside this shader or in gdscript ????

#### end ########


vec4 noise_a = texture(noise_texture, coord + TIME * 0.01);
vec4 noise_b = texture(noise_texture, vec2(coord.y, coord.x) - TIME * 0.015);

vec4 noise_final = mix(noise_a, noise_b, 0.5);

if (noise_final.a > 0.0) {
	noise_final.a = noise_final.r * intensity;
}

COLOR = noise_final;

}

Thanks in advance!

:bust_in_silhouette: Reply From: jonilearncode

I found one way.

In gdscript i tried this:

func _ready():
	print(material.get_shader_param("noise_texture").noise.period)
	
	var new_noise = OpenSimplexNoise.new()
	new_noise.period = 100
	var new_texture = NoiseTexture.new()
	new_texture.noise = new_noise
	material.set_shader_param("noise_texture", new_texture)
	
	print(material.get_shader_param("noise_texture").noise.period)

The result will be:

200
100

Anyone knows another way??

Thanks