- Edited
What I want is random generation of water on the floor I just want these every once in a while. I have 15 of 2 textures for the water. The albedo and the roughness. so for the second noise I need something between 0 - 14;
This is my code
FastNoiseLite noise2 = new FastNoiseLite();
FastNoiseLite noise3 = new FastNoiseLite();
public override void _Ready(){
for (int i=0;i<15;i++){
flooralb[i] = Godot.Image.LoadFromFile(string.Format("res://Textures/Floors/watfloor{0}.png", i));
floorshine[i] = Godot.Image.LoadFromFile(string.Format("res://Textures/Floors/watrefl{0}.png", i));
}
floorNorm = Godot.Image.LoadFromFile("res://Textures/mynormal1_tile.png");
noise2.NoiseType = FastNoiseLite.NoiseTypeEnum.Perlin;
noise2.Seed = 45;
noise3.NoiseType = FastNoiseLite.NoiseTypeEnum.Perlin;
noise3.Seed = 67;
noise2.FractalType = FastNoiseLite.FractalTypeEnum.Fbm;
noise3.FractalType = FastNoiseLite.FractalTypeEnum.Fbm;
}
private void makefloor(){
Node3D floorInst = (Node3D)floorScene.Instantiate();
floorInst.Position = new Vector3(x * 2, -1, z * 2);
floorInst.Name = string.Format("Wall {0}", getAvail());
double val = 0;
if (noise2.GetNoise2D(x, z) > .1){
GD.Print("Placed");
val = noise3.GetNoise2D(x, z);
if (val >= 0){
val -= .0000001;
val = Math.Floor(val * 15);
if (val < 0) val = 0;
int ival = (int)val;
StandardMaterial3D flrmat = new StandardMaterial3D();
Texture2D flrrough = (Texture2D)ImageTexture.CreateFromImage(floorshine[ival]);
Texture2D flralbe = (Texture2D)ImageTexture.CreateFromImage(flooralb[ival]);
Texture2D flrnorm = (Texture2D)ImageTexture.CreateFromImage(floorNorm);
flrmat.AlbedoTexture = flralbe;
flrmat.RoughnessTexture = flrrough;
flrmat.NormalTexture = flrnorm;
MeshInstance3D flrchild = (MeshInstance3D)floorInst.GetChild(1);
flrchild.MaterialOverride = flrmat;
}
}
Wallnum++;
AddChild(floorInst);
}