mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-23 11:49:17 +02:00
change: tweak nebulas and unhardcode variables
This commit is contained in:
parent
e377193e0e
commit
21b6b4d4c8
1 changed files with 15 additions and 22 deletions
|
@ -5,11 +5,10 @@ import net.minecraft.util.FastColor;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.levelgen.synth.PerlinNoise;
|
import net.minecraft.world.level.levelgen.synth.PerlinNoise;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
public class NebulaSkyboxPainter extends SkyboxPainter {
|
public class NebulaSkyboxPainter extends SkyboxPainter {
|
||||||
private static final float SCALING_FACTOR = 1f;
|
private static final float SCALING_FACTOR = 1f;
|
||||||
private static final float BASE_NOISE_AMOUNT = 0.56f; // the amount of base noise to keep
|
private static final float NOISE_AMOUNT = 0.51f; // the amount of base noise to keep
|
||||||
|
private static final int BASE_COLOUR_STRENGTH = 128;
|
||||||
|
|
||||||
private final Gradient nebulaGradient;
|
private final Gradient nebulaGradient;
|
||||||
|
|
||||||
|
@ -42,25 +41,19 @@ public class NebulaSkyboxPainter extends SkyboxPainter {
|
||||||
noise.getOctaveNoise(0).noiseWithDerivative(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR, ds);
|
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)
|
// Find a base background colour to use (xyz interpoaltion across sky, gamer mode)
|
||||||
int baseB = (int) ((x/2 + 0.5) * 127);
|
int baseB = (int) ((x / 2 + 0.5) * BASE_COLOUR_STRENGTH);
|
||||||
int baseG = (int) ((y/2 + 0.5) * 127);
|
int baseG = (int) ((y / 2 + 0.5) * BASE_COLOUR_STRENGTH);
|
||||||
int baseR = (int) ((z/2 + 0.5) * 127);
|
int baseR = (int) ((z / 2 + 0.5) * BASE_COLOUR_STRENGTH);
|
||||||
|
|
||||||
// double noiseAmount = (Mth.clamp((noiseValue * (1 / BASE_NOISE_AMOUNT) - (1 / BASE_NOISE_AMOUNT - 1)) * 255, 0, 255)); // otherwise death occurs
|
double nebulaFactor = (Mth.clamp((noiseValue * (1D / NOISE_AMOUNT) - (1D / NOISE_AMOUNT - 1)), 0, 0.99));
|
||||||
//
|
int[] nebula = nebulaGradient.getAt(nebulaFactor);
|
||||||
// int alpha = (int) Mth.clamp((int)noiseAmount - subtractionValue * 128, 50, 255);
|
|
||||||
|
|
||||||
double nebulaFactor = (Mth.clamp((noiseValue * (1D / BASE_NOISE_AMOUNT) - (1D / BASE_NOISE_AMOUNT - 1)), 0, 0.99));
|
|
||||||
Color nebula = nebulaGradient.getAt(nebulaFactor);
|
|
||||||
double bgFactor = Mth.clamp(Math.log10(-nebulaFactor + 1) + 1, 0, 1);
|
double bgFactor = Mth.clamp(Math.log10(-nebulaFactor + 1) + 1, 0, 1);
|
||||||
|
|
||||||
int r = Mth.clamp((int) ((nebulaFactor * nebula.getRed()) + baseR * bgFactor) - (int)(ds[0] * nebulaFactor * 127), 0, 255);
|
// todo: try and reduce brownish colours by reducing the green channel smoothly [failed attempt]
|
||||||
int g = Mth.clamp((int) ((nebulaFactor * nebula.getGreen()) + baseG * bgFactor) - (int)(ds[1] * nebulaFactor * 63), 0, 255);
|
|
||||||
int b = Mth.clamp((int) ((nebulaFactor * nebula.getBlue()) + baseB * bgFactor) - (int)(ds[2] * nebulaFactor * 127), 0, 255);
|
|
||||||
|
|
||||||
// int r = Mth.clamp((int) (baseR * bgFactor), 0, 255);
|
int r = Mth.clamp((int) ((nebulaFactor * nebula[0]) + baseR * bgFactor) - (int) (ds[0] * nebulaFactor * 128), 0, 255);
|
||||||
// int g = Mth.clamp((int) (baseG * bgFactor), 0, 255);
|
int g = Mth.clamp((int) ((nebulaFactor * nebula[1]) + baseG * bgFactor) - (int) (ds[1] * nebulaFactor * 64 * subtractionValue), 0, 255);
|
||||||
// int b = Mth.clamp((int) (baseB * bgFactor), 0, 255);
|
int b = Mth.clamp((int) ((nebulaFactor * nebula[2]) + baseB * bgFactor) - (int) (ds[2] * nebulaFactor * 128), 0, 255);
|
||||||
|
|
||||||
int alpha = Mth.clamp((int) ((1 - bgFactor) * 255), 50, 255);
|
int alpha = Mth.clamp((int) ((1 - bgFactor) * 255), 50, 255);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue