Setting a uniform Sampler2D in code not working
Asked Answered
B

1

0

Hi!

I was trying to set a uniform sampler 2D in code with set_shader_param, but I was noticing that it wasn't working. I generate a NoiseTexture in code, try to pass it to the shader but it doesn't seem to be working.

        noise.period = per
	noise.octaves = oct
	noise.persistence = pers
	noise.lacunarity
	noise.seed = randi()
	var gridName = {}
	
	var imgn = NoiseTexture.new()
	imgn.noise = noise
	var mat = $ShaderProcess/ShaderProcess.get_material()
	mat.set_shader_param("island_tex", imgn)

thats the code in question. When I check the remote access and look at the island_tex, it's the same as my editor example noise.

I also tried it with ImageTexture before this (instead of NoiseTexture), but that also wasn't working.

        noise.period = per
	noise.octaves = oct
	noise.persistence = pers
	noise.lacunarity
	noise.seed = randi()
	var gridName = {}
	
       	var imgt = ImageTexture.new()
	imgt.create_from_image(noise.get_image(512, 512))
	var mat = $ShaderProcess/ShaderProcess.get_material()
	mat.set_shader_param("island_tex", imgt)

I appreciate your help!

Bobolink answered 9/5, 2023 at 14:12 Comment(0)
S
0

Bobolink Does it work if you assign an image loaded from a file?

Siamese answered 9/5, 2023 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.