Invalid set index 'texture_albedo' (on base: 'ShaderMaterial') with value of type 'ViewportTexture'

Godot Version

4.1.3-stable

Question

I’m trying to make an FPS game, I have a sniper rifle and I’m trying to make it have a functioning scope, I set up the UVs correctly and used a modified StandardMaterial3D shader to multiply the pixels with a scope texture.

I used a Viewport Texture and it was working properly, but in-game it was purple.

Searching around turns out it’s a known issue and found a workaround by setting the texture using a function in _ready()

I thought it would work, but apperantely I can’t set the texture to a texture.

When you convert a StandardMaterial3D to a ShaderMaterial to modify it you lose all the properties of the StandardMaterial3D so you won’t be able to assign texture_albedo because it does not exist.

You’ll need to use ShaderMaterial.set_shader_parameter() to assign the texture to the correct parameter.

1 Like

Thanks! I tried to use it like a property but that fixed it!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.