change: improve gamerness

This commit is contained in:
ZtereoHYPE 2022-11-07 16:20:09 +01:00
parent fd4668c877
commit 7de8129fb7

View file

@ -33,33 +33,31 @@ public class NebulaSkyboxPainter extends SkyboxPainter {
z = Mth.clamp(z + offset/5f, -1f, 1f);
// Value of noise at coord, 0..1
double noiseValue = Mth.clamp(noise.getValue(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR) + 0.5, 0D, 1D);
double noiseValue = Mth.clamp(noise.getValue(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR) + 0.5, 0, 1);
// Value to be subtracted from noise at coord, 0..1
double subtractionValue = Mth.clamp(noise.getOctaveNoise(1).noise(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR) + 0.5, 0D, 1D);
double[] derivates = new double[3];
noise.getOctaveNoise(0).noiseWithDerivative(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR, derivates);
double[] ds = new double[3];
noise.getOctaveNoise(0).noiseWithDerivative(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR, ds);
// Find a base background colour to use (xyz interpoaltion across sky, gamer mode)
int blueness, greenness, redness;
blueness = (int) ((x/2 + 0.5) * 127);
greenness = (int) ((y/2 + 0.5) * 127);
redness = (int) ((z/2 + 0.5) * 127);
int baseB = (int) ((x/2 + 0.5) * 127);
int baseG = (int) ((y/2 + 0.5) * 127);
int baseR = (int) ((z/2 + 0.5) * 127);
int alpha = (int)(Mth.clamp((noiseValue * (1D / BASE_NOISE_AMOUNT) - (1D / BASE_NOISE_AMOUNT - 1)) * 255D, 20D, 254.99D)); // otherwise death occurs
int alpha = (int)(Mth.clamp((noiseValue * (1 / BASE_NOISE_AMOUNT) - (1 / BASE_NOISE_AMOUNT - 1)) * 255, 20, 254.99f)); // otherwise death occurs
alpha = (int) Mth.clamp(alpha - subtractionValue * 128, 50, 255);
double colourValue = (Mth.clamp((noiseValue * (1D / BASE_NOISE_AMOUNT) - (1D / BASE_NOISE_AMOUNT - 1)), 0.01D, 0.9999D));
Color color = nebulaGradient.getAt(colourValue);
double bgPresence = Mth.clamp(Math.log10(-colourValue + 1) + 1, 0D, 1D);
double nebulaFactor = (Mth.clamp((noiseValue * (1D / BASE_NOISE_AMOUNT) - (1D / BASE_NOISE_AMOUNT - 1)), 0.01, 0.9999));
Color nebula = nebulaGradient.getAt(nebulaFactor);
double bgFactor = Mth.clamp(Math.log10(-nebulaFactor + 1) + 1, 0, 1);
int red, green, blue;
red = Mth.clamp((int) ((colourValue * color.getRed()) + redness * bgPresence) - (int)(derivates[0] * colourValue * 127), 0, 255);
green = Mth.clamp((int) ((colourValue * color.getGreen()) + greenness * bgPresence) - (int)(derivates[1] * colourValue * 64), 0, 255);
blue = Mth.clamp((int) ((colourValue * color.getBlue()) + blueness * bgPresence) - (int)(derivates[2] * colourValue * 127), 0, 255);
int r = Mth.clamp((int) ((nebulaFactor * nebula.getRed()) + baseR * bgFactor) - (int)(ds[0] * nebulaFactor * 127), 0, 255);
int g = Mth.clamp((int) ((nebulaFactor * nebula.getGreen()) + baseG * bgFactor) - (int)(ds[1] * nebulaFactor * 64), 0, 255);
int b = Mth.clamp((int) ((nebulaFactor * nebula.getBlue()) + baseB * bgFactor) - (int)(ds[2] * nebulaFactor * 127), 0, 255);
return FastColor.ARGB32.color(alpha, blue, green, red);
return FastColor.ARGB32.color(alpha, b, g, r);
}
}