- Edited
If I weren't applying the texture the object would show up.
This is my code I can show with <-- where I get the
Node3D keyInst = (Node3D)keyScene.Instantiate();
keyInst.Position = new Vector3(cx * 2, -0.9f, cz * 2);
keyInst.Name = "The key";
MeshInstance3D keychild = (MeshInstance3D)keyInst.GetChild(0);
StandardMaterial3D keymat = keychild.GetActiveMaterial(3) as StandardMaterial3D;
//ShaderMaterial keyshad = (ShaderMaterial) keymat;
int num1 = currentKey % 36;
int num2 = currentKey / 36;
int x1 = (num1 % 6) * 128;
int y1 = (num1 / 6) * 256;
int x2 = (num2 % 6) * 128;
int y2 = (num2 / 6) * 256;
Godot.Image numimg = new Godot.Image();
numimg = Godot.Image.Create(256, 256, true, Godot.Image.Format.Rgba8);
for (int iy = 0;iy < 256;iy++){
for (int ix1 = 0;ix1 < 128;ix1++){
if (sampleImg.GetPixel(ix1 + x1, iy + y1).R < .5){
numimg.SetPixel(ix1, iy, Colors.Black);
}else{{
numimg.SetPixel(ix1, iy, Colors.White);
}}
}
for (int ix2 = 0;ix2 < 128;ix2++){
if (sampleImg.GetPixel(ix2 + x2, iy + y2).R < .5){
numimg.SetPixel(ix2 + 128, iy, Colors.Black);
}else{{
numimg.SetPixel(ix2 + 128, iy, Colors.White);
}}
}
}
ImageTexture numtex = ImageTexture.CreateFromImage(numimg);
Godot.Material addtokey = new Godot.Material();
Texture2D atex = (Texture2D) numtex;
keymat.AlbedoTexture = numtex; <--
AddChild(keyInst);