mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-23 03:39:18 +02:00
25 lines
679 B
Java
25 lines
679 B
Java
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};
|
|
}
|
|
}
|