suddenly and magically, contraption rendering is 100% accurate

This commit is contained in:
JozsefA 2021-01-21 12:26:55 -08:00
parent 33e66c6e89
commit 697a7df59c
3 changed files with 5 additions and 59 deletions

View file

@ -1,6 +1,7 @@
package com.simibubi.create.foundation.render; package com.simibubi.create.foundation.render;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.light.LightVolume; import com.simibubi.create.foundation.render.light.LightVolume;
@ -51,12 +52,7 @@ public class ContraptionRenderDispatcher {
if (renderers.isEmpty()) return; if (renderers.isEmpty()) return;
FastKineticRenderer.setup(Minecraft.getInstance().gameRenderer); renderType.startDrawing();
// if (renderType == RenderType.getTranslucent()) {
// GL30.glEnable(GL11.GL_DEPTH_TEST);
// GL20.glDepthFunc(GL20.GL_LESS);
// RenderSystem.defaultBlendFunc();
// }
GL11.glEnable(GL13.GL_TEXTURE_3D); GL11.glEnable(GL13.GL_TEXTURE_3D);
GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4
@ -85,12 +81,9 @@ public class ContraptionRenderDispatcher {
ShaderHelper.releaseShader(); ShaderHelper.releaseShader();
// if (renderType == RenderType.getTranslucent()) {
// GL30.glEnable(GL11.GL_DEPTH_TEST); renderType.endDrawing();
// GL20.glDepthFunc(GL20.GL_LEQUAL);
// }
GL11.glDisable(GL13.GL_TEXTURE_3D); GL11.glDisable(GL13.GL_TEXTURE_3D);
FastKineticRenderer.teardown();
GL13.glActiveTexture(GL40.GL_TEXTURE0); GL13.glActiveTexture(GL40.GL_TEXTURE0);
} }

View file

@ -147,53 +147,6 @@ public class FastKineticRenderer {
layer.endDrawing(); layer.endDrawing();
} }
public static void setup(GameRenderer gameRenderer) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.enableLighting();
RenderSystem.enableDepthTest();
RenderSystem.enableCull();
GL11.glCullFace(GL11.GL_BACK);
LightTexture lightManager = gameRenderer.getLightmapTextureManager();
Texture blockAtlasTexture = Minecraft.getInstance().textureManager.getTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE);
Texture lightTexture = Minecraft.getInstance().textureManager.getTexture(lightManager.resourceLocation);
// bind the block atlas texture to 0
GL13.glActiveTexture(GL40.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockAtlasTexture.getGlTextureId());
GL40.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL40.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
// bind the light texture to 1 and setup the mysterious filtering options
GL13.glActiveTexture(GL40.GL_TEXTURE1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, lightTexture.getGlTextureId());
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, 10241, 9729);
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, 10240, 9729);
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, 10242, 10496);
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, 10243, 10496);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.enableTexture();
}
public static void teardown() {
GL13.glActiveTexture(GL40.GL_TEXTURE1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
GL13.glActiveTexture(GL40.GL_TEXTURE0);
GL40.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL40.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
RenderSystem.disableCull();
RenderSystem.disableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableDepthTest();
RenderSystem.disableLighting();
}
public void registerCompartment(SuperByteBufferCache.Compartment<?> instance) { public void registerCompartment(SuperByteBufferCache.Compartment<?> instance) {
rotating.put(instance, CacheBuilder.newBuilder().build()); rotating.put(instance, CacheBuilder.newBuilder().build());
belts.put(instance, CacheBuilder.newBuilder().build()); belts.put(instance, CacheBuilder.newBuilder().build());

View file

@ -19,5 +19,5 @@ vec4 light() {
void main() { void main() {
vec4 tex = texture2D(BlockAtlas, TexCoords); vec4 tex = texture2D(BlockAtlas, TexCoords);
fragColor = vec4(tex.rgb * light().rgb * Diffuse, tex.a) * Color; fragColor = vec4(tex.rgb * light().rgb * Diffuse * Color.rgb, tex.a);
} }