mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
suddenly and magically, contraption rendering is 100% accurate
This commit is contained in:
parent
33e66c6e89
commit
697a7df59c
@ -1,6 +1,7 @@
|
||||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||
import com.simibubi.create.foundation.render.light.LightVolume;
|
||||
@ -51,12 +52,7 @@ public class ContraptionRenderDispatcher {
|
||||
|
||||
if (renderers.isEmpty()) return;
|
||||
|
||||
FastKineticRenderer.setup(Minecraft.getInstance().gameRenderer);
|
||||
// if (renderType == RenderType.getTranslucent()) {
|
||||
// GL30.glEnable(GL11.GL_DEPTH_TEST);
|
||||
// GL20.glDepthFunc(GL20.GL_LESS);
|
||||
// RenderSystem.defaultBlendFunc();
|
||||
// }
|
||||
renderType.startDrawing();
|
||||
GL11.glEnable(GL13.GL_TEXTURE_3D);
|
||||
GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4
|
||||
|
||||
@ -85,12 +81,9 @@ public class ContraptionRenderDispatcher {
|
||||
|
||||
ShaderHelper.releaseShader();
|
||||
|
||||
// if (renderType == RenderType.getTranslucent()) {
|
||||
// GL30.glEnable(GL11.GL_DEPTH_TEST);
|
||||
// GL20.glDepthFunc(GL20.GL_LEQUAL);
|
||||
// }
|
||||
|
||||
renderType.endDrawing();
|
||||
GL11.glDisable(GL13.GL_TEXTURE_3D);
|
||||
FastKineticRenderer.teardown();
|
||||
GL13.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
|
@ -147,53 +147,6 @@ public class FastKineticRenderer {
|
||||
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) {
|
||||
rotating.put(instance, CacheBuilder.newBuilder().build());
|
||||
belts.put(instance, CacheBuilder.newBuilder().build());
|
||||
|
@ -19,5 +19,5 @@ vec4 light() {
|
||||
void main() {
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user