refactor: static hell is now dynamic hell! fuck oop xdd

This commit is contained in:
ZtereoHYPE 2022-09-23 12:45:39 +02:00
parent 885d2b1059
commit 5f77c6d483
4 changed files with 166 additions and 130 deletions

View file

@ -0,0 +1,25 @@
package codes.ztereohype.example.nebula;
import net.minecraft.util.Mth;
import net.minecraft.world.level.levelgen.synth.PerlinNoise;
public abstract class SkyboxPainter {
protected final PerlinNoise noise;
SkyboxPainter(PerlinNoise noise) {
this.noise = noise;
}
abstract int getColour(float x, float y, float z);
public float[] projectOnSphere(float x, float y, float z) {
float invDistance = Mth.fastInvSqrt(x * x + y * y + z * z);
//divide by distance to get projection on sphere (shorten the vector)
x *= invDistance;
y *= invDistance;
z *= invDistance;
return new float[] {x, y, z};
}
}