Fix shader compatibility in default renderer

Disable shaders in cubic and stereoscopic rendering
This commit is contained in:
johni0702
2015-06-04 14:21:44 +02:00
parent a8c5e98c29
commit edd01b3981
6 changed files with 45 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import eu.crushedpixel.replaymod.replay.ReplayHandler;
import eu.crushedpixel.replaymod.settings.RenderOptions;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class CubicEntityRenderer extends CustomEntityRenderer {
@@ -51,6 +52,15 @@ public class CubicEntityRenderer extends CustomEntityRenderer {
super.gluPerspective(90, 1, zNear, zFar);
}
@Override
public void loadShader(ResourceLocation resourceLocation) {
if (proxied.theShaderGroup != null) {
proxied.theShaderGroup.deleteShaderGroup();
proxied.theShaderGroup = null;
}
proxied.useShader = false;
}
@Override
protected void setupCameraTransform(float partialTicks) {
Entity entity = mc.getRenderViewEntity();

View File

@@ -20,6 +20,7 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.util.glu.Project;
import java.awt.image.BufferedImage;
import java.lang.reflect.Field;
import static net.minecraft.client.renderer.GlStateManager.*;
import static org.lwjgl.opengl.GL11.*;
@@ -70,10 +71,20 @@ public abstract class CustomEntityRenderer {
}
}
System.out.println("CustomEntityRenderer using " + renderingStrategy);
// Install entity renderer hooks
try {
Field hookField = EntityRenderer.class.getField("hook");
hookField.set(proxied, this);
} catch (NoSuchFieldException e) {
throw new Error(e);
} catch (IllegalAccessException e) {
throw new Error(e);
}
}
@SuppressWarnings("unused") // Method called by ASM hook
protected void loadShader(ResourceLocation resourceLocation) {
public void loadShader(ResourceLocation resourceLocation) {
if (loadShaderHook != null) {
loadShaderHook.loadShader(resourceLocation);
} else {
@@ -300,6 +311,15 @@ public abstract class CustomEntityRenderer {
}
public void cleanup() {
try {
Field hookField = EntityRenderer.class.getField("hook");
hookField.set(proxied, null);
} catch (NoSuchFieldException e) {
throw new Error(e);
} catch (IllegalAccessException e) {
throw new Error(e);
}
renderingStrategy.cleanup();
spectatorRenderer.cleanup();
}

View File

@@ -3,6 +3,7 @@ package eu.crushedpixel.replaymod.video.entity;
import eu.crushedpixel.replaymod.settings.RenderOptions;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import java.awt.image.BufferedImage;
@@ -28,6 +29,15 @@ public class StereoscopicEntityRenderer extends CustomEntityRenderer {
super.renderFrame(partialTicks, into, x, y);
}
@Override
public void loadShader(ResourceLocation resourceLocation) {
if (proxied.theShaderGroup != null) {
proxied.theShaderGroup.deleteShaderGroup();
proxied.theShaderGroup = null;
}
proxied.useShader = false;
}
protected void translateStereoscopic() {
GlStateManager.translate(leftEye ? 0.07 : -0.07, 0, 0);
}

View File

@@ -54,11 +54,8 @@ public class VanillaFrameBufferRenderingStrategy implements FrameRenderingStrate
if (frameBuffer == null) {
frameBuffer = new Framebuffer(renderer.resultWidth, renderer.resultHeight, true);
ShaderGroup theShaderGroup = renderer.proxied.theShaderGroup;
if (theShaderGroup != null) {
theShaderGroup.deleteShaderGroup();
renderer.proxied.theShaderGroup = null;
}
renderer.loadShaderHook = this;
renderer.proxied.loadEntityShader(renderer.mc.getRenderViewEntity());
}
return frameBuffer;
}