+1 vote

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.

shadertype canvasitem;

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

uniform float intensity : hintrange(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!

in Engine by (22 points)

1 Answer

+1 vote
Best answer

I found one way.

In gdscript i tried this:

func _ready():

    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)


The result will be:


Anyone knows another way??


by (22 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.