Sky rendering cleanup & refactoring
This commit is contained in:
parent
3c19dad176
commit
4fddd1d258
3 changed files with 206 additions and 283 deletions
|
@ -11,26 +11,12 @@ import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.mojang.math.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import com.mojang.math.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
|
||||||
import net.minecraft.client.renderer.RenderBuffers;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import ru.bclib.util.BackgroundInfo;
|
import ru.bclib.util.BackgroundInfo;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.client.ClientOptions;
|
|
||||||
import ru.betterend.mixin.client.LevelRendererAccessor;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -44,30 +30,24 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
private static final ResourceLocation STARS = BetterEnd.makeID("textures/sky/stars.png");
|
private static final ResourceLocation STARS = BetterEnd.makeID("textures/sky/stars.png");
|
||||||
private static final ResourceLocation FOG = BetterEnd.makeID("textures/sky/fog.png");
|
private static final ResourceLocation FOG = BetterEnd.makeID("textures/sky/fog.png");
|
||||||
|
|
||||||
private static VertexBuffer stars1;
|
private VertexBuffer nebula1;
|
||||||
private static VertexBuffer stars2;
|
private VertexBuffer nebula2;
|
||||||
private static VertexBuffer stars3;
|
private VertexBuffer horizon;
|
||||||
private static VertexBuffer stars4;
|
private VertexBuffer stars1;
|
||||||
private static VertexBuffer nebulas1;
|
private VertexBuffer stars2;
|
||||||
private static VertexBuffer nebulas2;
|
private VertexBuffer stars3;
|
||||||
private static VertexBuffer horizon;
|
private VertexBuffer stars4;
|
||||||
private static VertexBuffer fog;
|
private VertexBuffer fog;
|
||||||
private static Vector3f axis1;
|
private Vector3f axis1;
|
||||||
private static Vector3f axis2;
|
private Vector3f axis2;
|
||||||
private static Vector3f axis3;
|
private Vector3f axis3;
|
||||||
private static Vector3f axis4;
|
private Vector3f axis4;
|
||||||
private static float time;
|
|
||||||
private static float time2;
|
|
||||||
private static float time3;
|
|
||||||
private static float blind02;
|
|
||||||
private static float blind06;
|
|
||||||
|
|
||||||
private boolean initalized = false;
|
private boolean initalized = false;
|
||||||
|
|
||||||
public void initalize() {
|
private void initialise() {
|
||||||
|
|
||||||
if(!initalized) {
|
if(!initalized) {
|
||||||
be_initStars();
|
initStars();
|
||||||
Random random = new Random(131);
|
Random random = new Random(131);
|
||||||
axis1 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
|
axis1 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
|
||||||
axis2 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
|
axis2 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
|
||||||
|
@ -77,144 +57,104 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
axis2.normalize();
|
axis2.normalize();
|
||||||
axis3.normalize();
|
axis3.normalize();
|
||||||
axis4.normalize();
|
axis4.normalize();
|
||||||
|
|
||||||
this.initalized = true;
|
this.initalized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(WorldRenderContext context) {
|
public void render(WorldRenderContext context) {
|
||||||
initalize();
|
if (context.world() == null || context.matrixStack() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initialise();
|
||||||
|
|
||||||
|
Matrix4f projectionMatrix = context.projectionMatrix();
|
||||||
PoseStack matrices = context.matrixStack();
|
PoseStack matrices = context.matrixStack();
|
||||||
|
|
||||||
Matrix4f matrix4f = context.projectionMatrix();
|
float time = ((context.world().getDayTime() + context.tickDelta()) % 360000) * 0.000017453292F;
|
||||||
float tickDelta = context.tickDelta();
|
float time2 = time * 2;
|
||||||
|
float time3 = time * 3;
|
||||||
time = (((LevelRendererAccessor) context.gameRenderer().getMinecraft().levelRenderer).getTick() + context.tickDelta() % 360000) * 0.000017453292F;
|
|
||||||
time2 = time * 2;
|
FogRenderer.levelFogColor();
|
||||||
time3 = time * 3;
|
RenderSystem.depthMask(false);
|
||||||
|
RenderSystem.enableTexture();
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.setShaderColor(1.0F ,1.0F ,1.0F ,1.0F);
|
||||||
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
float blindA = 1F - BackgroundInfo.blindness;
|
||||||
|
float blind02 = blindA * 0.2F;
|
||||||
|
float blind06 = blindA * 0.6F;
|
||||||
|
|
||||||
|
if (blindA > 0) {
|
||||||
|
matrices.pushPose();
|
||||||
|
matrices.mulPose(new Quaternion(0, time, 0, false));
|
||||||
|
RenderSystem.setShaderTexture(0, HORIZON);
|
||||||
|
renderBuffer(matrices, projectionMatrix, horizon, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, 0.7F * blindA);
|
||||||
|
matrices.popPose();
|
||||||
|
|
||||||
FogRenderer.levelFogColor();
|
matrices.pushPose();
|
||||||
RenderSystem.depthMask(false);
|
matrices.mulPose(new Quaternion(0, -time, 0, false));
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.setShaderTexture(0, NEBULA_1);
|
||||||
RenderSystem.enableBlend();
|
renderBuffer(matrices, projectionMatrix, nebula1, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
|
||||||
RenderSystem.setShaderColor(1,1,1,1);
|
matrices.popPose();
|
||||||
RenderSystem.blendFunc(
|
|
||||||
GlStateManager.SourceFactor.SRC_ALPHA,
|
|
||||||
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA
|
|
||||||
);
|
|
||||||
|
|
||||||
float blindA = 1F - BackgroundInfo.blindness;
|
matrices.pushPose();
|
||||||
blind02 = blindA * 0.2F;
|
matrices.mulPose(new Quaternion(0, time2, 0, false));
|
||||||
blind06 = blindA * 0.6F;
|
RenderSystem.setShaderTexture(0, NEBULA_2);
|
||||||
|
renderBuffer(matrices, projectionMatrix, nebula2, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
|
||||||
|
matrices.popPose();
|
||||||
|
|
||||||
if (blindA > 0) {
|
RenderSystem.setShaderTexture(0, STARS);
|
||||||
matrices.pushPose();
|
|
||||||
matrices.mulPose(new Quaternion(0, time, 0, false));
|
|
||||||
RenderSystem.setShaderTexture(0, HORIZON);
|
|
||||||
be_renderBuffer(
|
|
||||||
matrices,
|
|
||||||
matrix4f,
|
|
||||||
horizon,
|
|
||||||
DefaultVertexFormat.POSITION_TEX,
|
|
||||||
0.77F,
|
|
||||||
0.31F,
|
|
||||||
0.73F,
|
|
||||||
0.7F * blindA
|
|
||||||
);
|
|
||||||
matrices.popPose();
|
|
||||||
|
|
||||||
matrices.pushPose();
|
|
||||||
matrices.mulPose(new Quaternion(0, -time, 0, false));
|
|
||||||
RenderSystem.setShaderTexture(0, NEBULA_1);
|
|
||||||
be_renderBuffer(
|
|
||||||
matrices,
|
|
||||||
matrix4f,
|
|
||||||
nebulas1,
|
|
||||||
DefaultVertexFormat.POSITION_TEX,
|
|
||||||
0.77F,
|
|
||||||
0.31F,
|
|
||||||
0.73F,
|
|
||||||
blind02
|
|
||||||
);
|
|
||||||
matrices.popPose();
|
|
||||||
|
|
||||||
matrices.pushPose();
|
|
||||||
matrices.mulPose(new Quaternion(0, time2, 0, false));
|
|
||||||
RenderSystem.setShaderTexture(0, NEBULA_2);
|
|
||||||
be_renderBuffer(
|
|
||||||
matrices,
|
|
||||||
matrix4f,
|
|
||||||
nebulas2,
|
|
||||||
DefaultVertexFormat.POSITION_TEX,
|
|
||||||
0.77F,
|
|
||||||
0.31F,
|
|
||||||
0.73F,
|
|
||||||
blind02
|
|
||||||
);
|
|
||||||
matrices.popPose();
|
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, STARS);
|
|
||||||
|
|
||||||
matrices.pushPose();
|
|
||||||
matrices.mulPose(axis3.rotation(time));
|
|
||||||
be_renderBuffer(
|
|
||||||
matrices,
|
|
||||||
matrix4f,
|
|
||||||
stars3,
|
|
||||||
DefaultVertexFormat.POSITION_TEX,
|
|
||||||
0.77F,
|
|
||||||
0.31F,
|
|
||||||
0.73F,
|
|
||||||
blind06
|
|
||||||
);
|
|
||||||
matrices.popPose();
|
|
||||||
|
|
||||||
matrices.pushPose();
|
|
||||||
matrices.mulPose(axis4.rotation(time2));
|
|
||||||
be_renderBuffer(matrices, matrix4f, stars4, DefaultVertexFormat.POSITION_TEX, 1F, 1F, 1F, blind06);
|
|
||||||
matrices.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
float a = (BackgroundInfo.fogDensity - 1F);
|
matrices.pushPose();
|
||||||
if (a > 0) {
|
matrices.mulPose(axis3.rotation(time));
|
||||||
if (a > 1) a = 1;
|
renderBuffer(matrices, projectionMatrix, stars3, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind06);
|
||||||
RenderSystem.setShaderTexture(0, FOG);
|
matrices.popPose();
|
||||||
be_renderBuffer(
|
|
||||||
matrices,
|
|
||||||
matrix4f,
|
|
||||||
fog,
|
|
||||||
DefaultVertexFormat.POSITION_TEX,
|
|
||||||
BackgroundInfo.fogColorRed,
|
|
||||||
BackgroundInfo.fogColorGreen,
|
|
||||||
BackgroundInfo.fogColorBlue,
|
|
||||||
a
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderSystem.disableTexture();
|
matrices.pushPose();
|
||||||
|
matrices.mulPose(axis4.rotation(time2));
|
||||||
|
renderBuffer(matrices, projectionMatrix, stars4, DefaultVertexFormat.POSITION_TEX, 1F, 1F, 1F, blind06);
|
||||||
|
matrices.popPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
float a = (BackgroundInfo.fogDensity - 1F);
|
||||||
|
if (a > 0) {
|
||||||
|
if (a > 1) a = 1;
|
||||||
|
RenderSystem.setShaderTexture(0, FOG);
|
||||||
|
renderBuffer(
|
||||||
|
matrices,
|
||||||
|
projectionMatrix,
|
||||||
|
fog,
|
||||||
|
DefaultVertexFormat.POSITION_TEX,
|
||||||
|
BackgroundInfo.fogColorRed,
|
||||||
|
BackgroundInfo.fogColorGreen,
|
||||||
|
BackgroundInfo.fogColorBlue,
|
||||||
|
a);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderSystem.disableTexture();
|
||||||
|
|
||||||
|
if (blindA > 0) {
|
||||||
|
matrices.pushPose();
|
||||||
|
matrices.mulPose(axis1.rotation(time3));
|
||||||
|
renderBuffer(matrices, projectionMatrix, stars1, DefaultVertexFormat.POSITION, 1, 1, 1, blind06);
|
||||||
|
matrices.popPose();
|
||||||
|
|
||||||
if (blindA > 0) {
|
matrices.pushPose();
|
||||||
matrices.pushPose();
|
matrices.mulPose(axis2.rotation(time2));
|
||||||
matrices.mulPose(axis1.rotation(time3));
|
renderBuffer(matrices, projectionMatrix, stars2, DefaultVertexFormat.POSITION, 0.95F, 0.64F, 0.93F, blind06);
|
||||||
be_renderBuffer(matrices, matrix4f, stars1, DefaultVertexFormat.POSITION, 1, 1, 1, blind06);
|
matrices.popPose();
|
||||||
matrices.popPose();
|
}
|
||||||
|
|
||||||
matrices.pushPose();
|
RenderSystem.enableTexture();
|
||||||
matrices.mulPose(axis2.rotation(time2));
|
RenderSystem.depthMask(true);
|
||||||
be_renderBuffer(matrices, matrix4f, stars2, DefaultVertexFormat.POSITION, 0.95F, 0.64F, 0.93F, blind06);
|
RenderSystem.defaultBlendFunc();
|
||||||
matrices.popPose();
|
RenderSystem.disableBlend();
|
||||||
}
|
|
||||||
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
RenderSystem.depthMask(true);
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_renderBuffer(PoseStack matrices, Matrix4f matrix4f, VertexBuffer buffer, VertexFormat format, float r, float g, float b, float a) {
|
private void renderBuffer(PoseStack matrices, Matrix4f matrix4f, VertexBuffer buffer, VertexFormat format, float r, float g, float b, float a) {
|
||||||
RenderSystem.setShaderColor(r, g, b, a);
|
RenderSystem.setShaderColor(r, g, b, a);
|
||||||
if (format == DefaultVertexFormat.POSITION) {
|
if (format == DefaultVertexFormat.POSITION) {
|
||||||
buffer.drawWithShader(matrices.last().pose(), matrix4f, GameRenderer.getPositionShader());
|
buffer.drawWithShader(matrices.last().pose(), matrix4f, GameRenderer.getPositionShader());
|
||||||
|
@ -224,91 +164,84 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_initStars() {
|
private void initStars() {
|
||||||
BufferBuilder buffer = Tesselator.getInstance().getBuilder();
|
BufferBuilder buffer = Tesselator.getInstance().getBuilder();
|
||||||
stars1 = be_buildBufferStars(buffer, stars1, 0.1, 0.30, 3500, 41315);
|
stars1 = buildBufferStars(buffer, stars1, 0.1, 0.30, 3500, 41315);
|
||||||
stars2 = be_buildBufferStars(buffer, stars2, 0.1, 0.35, 2000, 35151);
|
stars2 = buildBufferStars(buffer, stars2, 0.1, 0.35, 2000, 35151);
|
||||||
stars3 = be_buildBufferUVStars(buffer, stars3, 0.4, 1.2, 1000, 61354);
|
stars3 = buildBufferUVStars(buffer, stars3, 0.4, 1.2, 1000, 61354);
|
||||||
stars4 = be_buildBufferUVStars(buffer, stars4, 0.4, 1.2, 1000, 61355);
|
stars4 = buildBufferUVStars(buffer, stars4, 0.4, 1.2, 1000, 61355);
|
||||||
nebulas1 = be_buildBufferFarFog(buffer, nebulas1, 40, 60, 30, 11515);
|
nebula1 = buildBufferFarFog(buffer, nebula1, 40, 60, 30, 11515);
|
||||||
nebulas2 = be_buildBufferFarFog(buffer, nebulas2, 40, 60, 10, 14151);
|
nebula2 = buildBufferFarFog(buffer, nebula2, 40, 60, 10, 14151);
|
||||||
horizon = be_buildBufferHorizon(buffer, horizon);
|
horizon = buildBufferHorizon(buffer, horizon);
|
||||||
fog = be_buildBufferFog(buffer, fog);
|
fog = buildBufferFog(buffer, fog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private VertexBuffer be_buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
private VertexBuffer buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
buffer.close();
|
buffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Test if this is working correct
|
|
||||||
//Format is set in the DrawState
|
|
||||||
//buffer = new VertexBuffer(DefaultVertexFormat.POSITION);
|
|
||||||
buffer = new VertexBuffer();
|
buffer = new VertexBuffer();
|
||||||
be_makeStars(bufferBuilder, minSize, maxSize, count, seed);
|
makeStars(bufferBuilder, minSize, maxSize, count, seed);
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
buffer.upload(bufferBuilder);
|
buffer.upload(bufferBuilder);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VertexBuffer be_buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
private VertexBuffer buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
buffer.close();
|
buffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
|
||||||
buffer = new VertexBuffer();
|
buffer = new VertexBuffer();
|
||||||
be_makeUVStars(bufferBuilder, minSize, maxSize, count, seed);
|
makeUVStars(bufferBuilder, minSize, maxSize, count, seed);
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
buffer.upload(bufferBuilder);
|
buffer.upload(bufferBuilder);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VertexBuffer be_buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
private VertexBuffer buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
buffer.close();
|
buffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
|
||||||
buffer = new VertexBuffer();
|
buffer = new VertexBuffer();
|
||||||
be_makeFarFog(bufferBuilder, minSize, maxSize, count, seed);
|
makeFarFog(bufferBuilder, minSize, maxSize, count, seed);
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
buffer.upload(bufferBuilder);
|
buffer.upload(bufferBuilder);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VertexBuffer be_buildBufferHorizon(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
private VertexBuffer buildBufferHorizon(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
buffer.close();
|
buffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
|
||||||
buffer = new VertexBuffer();
|
buffer = new VertexBuffer();
|
||||||
be_makeCylinder(bufferBuilder, 16, 50, 100);
|
makeCylinder(bufferBuilder, 16, 50, 100);
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
buffer.upload(bufferBuilder);
|
buffer.upload(bufferBuilder);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VertexBuffer be_buildBufferFog(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
private VertexBuffer buildBufferFog(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
buffer.close();
|
buffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
|
||||||
buffer = new VertexBuffer();
|
buffer = new VertexBuffer();
|
||||||
be_makeCylinder(bufferBuilder, 16, 50, 70);
|
makeCylinder(bufferBuilder, 16, 50, 70);
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
buffer.upload(bufferBuilder);
|
buffer.upload(bufferBuilder);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_makeStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
private void makeStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
Random random = new Random(seed);
|
Random random = new Random(seed);
|
||||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
||||||
|
|
||||||
|
@ -318,40 +251,43 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
double posZ = random.nextDouble() * 2.0 - 1.0;
|
double posZ = random.nextDouble() * 2.0 - 1.0;
|
||||||
double size = MHelper.randRange(minSize, maxSize, random);
|
double size = MHelper.randRange(minSize, maxSize, random);
|
||||||
double length = posX * posX + posY * posY + posZ * posZ;
|
double length = posX * posX + posY * posY + posZ * posZ;
|
||||||
|
|
||||||
if (length < 1.0 && length > 0.001) {
|
if (length < 1.0 && length > 0.001) {
|
||||||
length = 1.0 / Math.sqrt(length);
|
length = 1.0 / Math.sqrt(length);
|
||||||
posX *= length;
|
posX *= length;
|
||||||
posY *= length;
|
posY *= length;
|
||||||
posZ *= length;
|
posZ *= length;
|
||||||
double j = posX * 100.0;
|
|
||||||
double k = posY * 100.0;
|
|
||||||
double l = posZ * 100.0;
|
|
||||||
double m = Math.atan2(posX, posZ);
|
|
||||||
double n = Math.sin(m);
|
|
||||||
double o = Math.cos(m);
|
|
||||||
double p = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
|
||||||
double q = Math.sin(p);
|
|
||||||
double r = Math.cos(p);
|
|
||||||
double s = random.nextDouble() * Math.PI * 2.0;
|
|
||||||
double t = Math.sin(s);
|
|
||||||
double u = Math.cos(s);
|
|
||||||
|
|
||||||
for (int v = 0; v < 4; ++v) {
|
double px = posX * 100.0;
|
||||||
double x = (double) ((v & 2) - 1) * size;
|
double py = posY * 100.0;
|
||||||
double y = (double) ((v + 1 & 2) - 1) * size;
|
double pz = posZ * 100.0;
|
||||||
double aa = x * u - y * t;
|
|
||||||
double ab = y * u + x * t;
|
double angle = Math.atan2(posX, posZ);
|
||||||
double ad = aa * q + 0.0 * r;
|
double sin1 = Math.sin(angle);
|
||||||
double ae = 0.0 * q - aa * r;
|
double cos1 = Math.cos(angle);
|
||||||
double af = ae * n - ab * o;
|
angle = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
||||||
double ah = ab * n + ae * o;
|
double sin2 = Math.sin(angle);
|
||||||
buffer.vertex(j + af, k + ad, l + ah).endVertex();
|
double cos2 = Math.cos(angle);
|
||||||
|
angle = random.nextDouble() * Math.PI * 2.0;
|
||||||
|
double sin3 = Math.sin(angle);
|
||||||
|
double cos3 = Math.cos(angle);
|
||||||
|
|
||||||
|
for (int index = 0; index < 4; ++index) {
|
||||||
|
double x = (double) ((index & 2) - 1) * size;
|
||||||
|
double y = (double) ((index + 1 & 2) - 1) * size;
|
||||||
|
double aa = x * cos3 - y * sin3;
|
||||||
|
double ab = y * cos3 + x * sin3;
|
||||||
|
double dy = aa * sin2 + 0.0 * cos2;
|
||||||
|
double ae = 0.0 * sin2 - aa * cos2;
|
||||||
|
double dx = ae * sin1 - ab * cos1;
|
||||||
|
double dz = ab * sin1 + ae * cos1;
|
||||||
|
buffer.vertex(px + dx, py + dy, pz + dz).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_makeUVStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
private void makeUVStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
Random random = new Random(seed);
|
Random random = new Random(seed);
|
||||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
||||||
|
|
||||||
|
@ -361,45 +297,46 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
double posZ = random.nextDouble() * 2.0 - 1.0;
|
double posZ = random.nextDouble() * 2.0 - 1.0;
|
||||||
double size = MHelper.randRange(minSize, maxSize, random);
|
double size = MHelper.randRange(minSize, maxSize, random);
|
||||||
double length = posX * posX + posY * posY + posZ * posZ;
|
double length = posX * posX + posY * posY + posZ * posZ;
|
||||||
|
|
||||||
if (length < 1.0 && length > 0.001) {
|
if (length < 1.0 && length > 0.001) {
|
||||||
length = 1.0 / Math.sqrt(length);
|
length = 1.0 / Math.sqrt(length);
|
||||||
posX *= length;
|
posX *= length;
|
||||||
posY *= length;
|
posY *= length;
|
||||||
posZ *= length;
|
posZ *= length;
|
||||||
double j = posX * 100.0;
|
|
||||||
double k = posY * 100.0;
|
|
||||||
double l = posZ * 100.0;
|
|
||||||
double m = Math.atan2(posX, posZ);
|
|
||||||
double n = Math.sin(m);
|
|
||||||
double o = Math.cos(m);
|
|
||||||
double p = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
|
||||||
double q = Math.sin(p);
|
|
||||||
double r = Math.cos(p);
|
|
||||||
double s = random.nextDouble() * Math.PI * 2.0;
|
|
||||||
double t = Math.sin(s);
|
|
||||||
double u = Math.cos(s);
|
|
||||||
|
|
||||||
int pos = 0;
|
double px = posX * 100.0;
|
||||||
|
double py = posY * 100.0;
|
||||||
|
double pz = posZ * 100.0;
|
||||||
|
|
||||||
|
double angle = Math.atan2(posX, posZ);
|
||||||
|
double sin1 = Math.sin(angle);
|
||||||
|
double cos1 = Math.cos(angle);
|
||||||
|
angle = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
||||||
|
double sin2 = Math.sin(angle);
|
||||||
|
double cos2 = Math.cos(angle);
|
||||||
|
angle = random.nextDouble() * Math.PI * 2.0;
|
||||||
|
double sin3 = Math.sin(angle);
|
||||||
|
double cos3 = Math.cos(angle);
|
||||||
|
|
||||||
float minV = random.nextInt(4) / 4F;
|
float minV = random.nextInt(4) / 4F;
|
||||||
for (int v = 0; v < 4; ++v) {
|
for (int index = 0; index < 4; ++index) {
|
||||||
double x = (double) ((v & 2) - 1) * size;
|
double x = (double) ((index & 2) - 1) * size;
|
||||||
double y = (double) ((v + 1 & 2) - 1) * size;
|
double y = (double) ((index + 1 & 2) - 1) * size;
|
||||||
double aa = x * u - y * t;
|
double aa = x * cos3 - y * sin3;
|
||||||
double ab = y * u + x * t;
|
double ab = y * cos3 + x * sin3;
|
||||||
double ad = aa * q + 0.0 * r;
|
double dy = aa * sin2 + 0.0 * cos2;
|
||||||
double ae = 0.0 * q - aa * r;
|
double ae = 0.0 * sin2 - aa * cos2;
|
||||||
double af = ae * n - ab * o;
|
double dx = ae * sin1 - ab * cos1;
|
||||||
double ah = ab * n + ae * o;
|
double dz = ab * sin1 + ae * cos1;
|
||||||
float texU = (pos >> 1) & 1;
|
float texU = (index >> 1) & 1;
|
||||||
float texV = (((pos + 1) >> 1) & 1) / 4F + minV;
|
float texV = (((index + 1) >> 1) & 1) / 4F + minV;
|
||||||
pos++;
|
buffer.vertex(px + dx, py + dy, pz + dz).uv(texU, texV).endVertex();
|
||||||
buffer.vertex(j + af, k + ad, l + ah).uv(texU, texV).endVertex();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_makeFarFog(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
private void makeFarFog(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||||
Random random = new Random(seed);
|
Random random = new Random(seed);
|
||||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
||||||
|
|
||||||
|
@ -410,47 +347,46 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
|
||||||
double size = MHelper.randRange(minSize, maxSize, random);
|
double size = MHelper.randRange(minSize, maxSize, random);
|
||||||
double length = posX * posX + posY * posY + posZ * posZ;
|
double length = posX * posX + posY * posY + posZ * posZ;
|
||||||
double distance = 2.0;
|
double distance = 2.0;
|
||||||
double delta = 1.0 / count;
|
|
||||||
if (length < 1.0 && length > 0.001) {
|
if (length < 1.0 && length > 0.001) {
|
||||||
length = distance / Math.sqrt(length);
|
length = distance / Math.sqrt(length);
|
||||||
size *= distance;
|
size *= distance;
|
||||||
distance -= delta;
|
|
||||||
posX *= length;
|
posX *= length;
|
||||||
posY *= length;
|
posY *= length;
|
||||||
posZ *= length;
|
posZ *= length;
|
||||||
double j = posX * 100.0;
|
|
||||||
double k = posY * 100.0;
|
|
||||||
double l = posZ * 100.0;
|
|
||||||
double m = Math.atan2(posX, posZ);
|
|
||||||
double n = Math.sin(m);
|
|
||||||
double o = Math.cos(m);
|
|
||||||
double p = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
|
||||||
double q = Math.sin(p);
|
|
||||||
double r = Math.cos(p);
|
|
||||||
double s = random.nextDouble() * Math.PI * 2.0;
|
|
||||||
double t = Math.sin(s);
|
|
||||||
double u = Math.cos(s);
|
|
||||||
|
|
||||||
int pos = 0;
|
double px = posX * 100.0;
|
||||||
for (int v = 0; v < 4; ++v) {
|
double py = posY * 100.0;
|
||||||
double x = (double) ((v & 2) - 1) * size;
|
double pz = posZ * 100.0;
|
||||||
double y = (double) ((v + 1 & 2) - 1) * size;
|
|
||||||
double aa = x * u - y * t;
|
double angle = Math.atan2(posX, posZ);
|
||||||
double ab = y * u + x * t;
|
double sin1 = Math.sin(angle);
|
||||||
double ad = aa * q + 0.0 * r;
|
double cos1 = Math.cos(angle);
|
||||||
double ae = 0.0 * q - aa * r;
|
angle = Math.atan2(Math.sqrt(posX * posX + posZ * posZ), posY);
|
||||||
double af = ae * n - ab * o;
|
double sin2 = Math.sin(angle);
|
||||||
double ah = ab * n + ae * o;
|
double cos2 = Math.cos(angle);
|
||||||
float texU = (pos >> 1) & 1;
|
angle = random.nextDouble() * Math.PI * 2.0;
|
||||||
float texV = ((pos + 1) >> 1) & 1;
|
double sin3 = Math.sin(angle);
|
||||||
pos++;
|
double cos3 = Math.cos(angle);
|
||||||
buffer.vertex(j + af, k + ad, l + ah).uv(texU, texV).endVertex();
|
|
||||||
|
for (int index = 0; index < 4; ++index) {
|
||||||
|
double x = (double) ((index & 2) - 1) * size;
|
||||||
|
double y = (double) ((index + 1 & 2) - 1) * size;
|
||||||
|
double aa = x * cos3 - y * sin3;
|
||||||
|
double ab = y * cos3 + x * sin3;
|
||||||
|
double dy = aa * sin2 + 0.0 * cos2;
|
||||||
|
double ae = 0.0 * sin2 - aa * cos2;
|
||||||
|
double dx = ae * sin1 - ab * cos1;
|
||||||
|
double dz = ab * sin1 + ae * cos1;
|
||||||
|
float texU = (index >> 1) & 1;
|
||||||
|
float texV = ((index + 1) >> 1) & 1;
|
||||||
|
buffer.vertex(px + dx, py + dy, pz + dz).uv(texU, texV).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void be_makeCylinder(BufferBuilder buffer, int segments, double height, double radius) {
|
private void makeCylinder(BufferBuilder buffer, int segments, double height, double radius) {
|
||||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
||||||
for (int i = 0; i < segments; i++) {
|
for (int i = 0; i < segments; i++) {
|
||||||
double a1 = (double) i * Math.PI * 2.0 / (double) segments;
|
double a1 = (double) i * Math.PI * 2.0 / (double) segments;
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package ru.betterend.mixin.client;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
|
||||||
|
|
||||||
@Mixin(LevelRenderer.class)
|
|
||||||
public interface LevelRendererAccessor {
|
|
||||||
@Accessor("ticks")
|
|
||||||
int getTick();
|
|
||||||
}
|
|
|
@ -5,17 +5,16 @@
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"client": [
|
"client": [
|
||||||
"AbstractSoundInstanceAccessor",
|
"AbstractSoundInstanceAccessor",
|
||||||
"ArmorStandRendererMixin",
|
|
||||||
"BiomeColorsMixin",
|
|
||||||
"CapeLayerMixin",
|
|
||||||
"HumanoidMobRendererMixin",
|
"HumanoidMobRendererMixin",
|
||||||
"ItemStackMixin",
|
"ArmorStandRendererMixin",
|
||||||
"LocalPlayerMixin",
|
|
||||||
"MinecraftClientMixin",
|
"MinecraftClientMixin",
|
||||||
"ModelLoaderMixin",
|
|
||||||
"MusicTrackerMixin",
|
|
||||||
"PlayerRendererMixin",
|
"PlayerRendererMixin",
|
||||||
"LevelRendererAccessor"
|
"MusicTrackerMixin",
|
||||||
|
"BiomeColorsMixin",
|
||||||
|
"LocalPlayerMixin",
|
||||||
|
"ModelLoaderMixin",
|
||||||
|
"CapeLayerMixin",
|
||||||
|
"ItemStackMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue