Skip to content

Commit

Permalink
new version optifine compat
Browse files Browse the repository at this point in the history
  • Loading branch information
qouteall committed Feb 20, 2021
1 parent 34c8b15 commit 04feea6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,120 +498,7 @@ public PerDimensionContext() {
//reset the fields that will be changed by init()
//do not reset the fields that was initialized by loadShaderPack()
public void doSpecialInit() {
// shaderPackLoaded = true;

// sunPosition = new float[4];
// moonPosition = new float[4];
// shadowLightPosition = new float[4];
//upPosition = new float[4]; //Fix Sildurs shader black entities in nether
// shadowLightPositionVector = new float[4];
// upPosModelView = new float[]{0.0F, 100.0F, 0.0F, 0.0F};
// sunPosModelView = new float[]{0.0F, 100.0F, 0.0F, 0.0F};
// moonPosModelView = new float[]{0.0F, -100.0F, 0.0F, 0.0F};
// tempMat = new float[16];
// shaderUniforms = new ShaderUniforms();

// uniform_entityColor = shaderUniforms.make4f("entityColor");
// uniform_entityId = shaderUniforms.make1i("entityId");
// uniform_blockEntityId = shaderUniforms.make1i("blockEntityId");
// uniform_texture = shaderUniforms.make1i("texture");
// uniform_lightmap = shaderUniforms.make1i("lightmap");
// uniform_normals = shaderUniforms.make1i("normals");
// uniform_specular = shaderUniforms.make1i("specular");
// uniform_shadow = shaderUniforms.make1i("shadow");
// uniform_watershadow = shaderUniforms.make1i("watershadow");
// uniform_shadowtex0 = shaderUniforms.make1i("shadowtex0");
// uniform_shadowtex1 = shaderUniforms.make1i("shadowtex1");
// uniform_depthtex0 = shaderUniforms.make1i("depthtex0");
// uniform_depthtex1 = shaderUniforms.make1i("depthtex1");
// uniform_shadowcolor = shaderUniforms.make1i("shadowcolor");
// uniform_shadowcolor0 = shaderUniforms.make1i("shadowcolor0");
// uniform_shadowcolor1 = shaderUniforms.make1i("shadowcolor1");
// uniform_noisetex = shaderUniforms.make1i("noisetex");
// uniform_gcolor = shaderUniforms.make1i("gcolor");
// uniform_gdepth = shaderUniforms.make1i("gdepth");
// uniform_gnormal = shaderUniforms.make1i("gnormal");
// uniform_composite = shaderUniforms.make1i("composite");
// uniform_gaux1 = shaderUniforms.make1i("gaux1");
// uniform_gaux2 = shaderUniforms.make1i("gaux2");
// uniform_gaux3 = shaderUniforms.make1i("gaux3");
// uniform_gaux4 = shaderUniforms.make1i("gaux4");
// uniform_colortex0 = shaderUniforms.make1i("colortex0");
// uniform_colortex1 = shaderUniforms.make1i("colortex1");
// uniform_colortex2 = shaderUniforms.make1i("colortex2");
// uniform_colortex3 = shaderUniforms.make1i("colortex3");
// uniform_colortex4 = shaderUniforms.make1i("colortex4");
// uniform_colortex5 = shaderUniforms.make1i("colortex5");
// uniform_colortex6 = shaderUniforms.make1i("colortex6");
// uniform_colortex7 = shaderUniforms.make1i("colortex7");
// uniform_gdepthtex = shaderUniforms.make1i("gdepthtex");
// uniform_depthtex2 = shaderUniforms.make1i("depthtex2");
// uniform_tex = shaderUniforms.make1i("tex");
// uniform_heldItemId = shaderUniforms.make1i("heldItemId");
// uniform_heldBlockLightValue = shaderUniforms.make1i("heldBlockLightValue");
// uniform_heldItemId2 = shaderUniforms.make1i("heldItemId2");
// uniform_heldBlockLightValue2 = shaderUniforms.make1i("heldBlockLightValue2");
// uniform_fogMode = shaderUniforms.make1i("fogMode");
// uniform_fogDensity = shaderUniforms.make1f("fogDensity");
// uniform_fogColor = shaderUniforms.make3f("fogColor");
// uniform_skyColor = shaderUniforms.make3f("skyColor");
// uniform_worldTime = shaderUniforms.make1i("worldTime");
// uniform_worldDay = shaderUniforms.make1i("worldDay");
// uniform_moonPhase = shaderUniforms.make1i("moonPhase");
// uniform_frameCounter = shaderUniforms.make1i("frameCounter");
// uniform_frameTime = shaderUniforms.make1f("frameTime");
// uniform_frameTimeCounter = shaderUniforms.make1f("frameTimeCounter");
// uniform_sunAngle = shaderUniforms.make1f("sunAngle");
// uniform_shadowAngle = shaderUniforms.make1f("shadowAngle");
// uniform_rainStrength = shaderUniforms.make1f("rainStrength");
// uniform_aspectRatio = shaderUniforms.make1f("aspectRatio");
// uniform_viewWidth = shaderUniforms.make1f("viewWidth");
// uniform_viewHeight = shaderUniforms.make1f("viewHeight");
// uniform_near = shaderUniforms.make1f("near");
// uniform_far = shaderUniforms.make1f("far");
// uniform_sunPosition = shaderUniforms.make3f("sunPosition");
// uniform_moonPosition = shaderUniforms.make3f("moonPosition");
// uniform_shadowLightPosition = shaderUniforms.make3f("shadowLightPosition");
// uniform_upPosition = shaderUniforms.make3f("upPosition");
// uniform_previousCameraPosition = shaderUniforms.make3f("previousCameraPosition");
// uniform_cameraPosition = shaderUniforms.make3f("cameraPosition");
// uniform_gbufferModelView = shaderUniforms.makeM4("gbufferModelView");
// uniform_gbufferModelViewInverse = shaderUniforms.makeM4("gbufferModelViewInverse");
// uniform_gbufferPreviousProjection = shaderUniforms.makeM4("gbufferPreviousProjection");
// uniform_gbufferProjection = shaderUniforms.makeM4("gbufferProjection");
// uniform_gbufferProjectionInverse = shaderUniforms.makeM4("gbufferProjectionInverse");
// uniform_gbufferPreviousModelView = shaderUniforms.makeM4("gbufferPreviousModelView");
// uniform_shadowProjection = shaderUniforms.makeM4("shadowProjection");
// uniform_shadowProjectionInverse = shaderUniforms.makeM4("shadowProjectionInverse");
// uniform_shadowModelView = shaderUniforms.makeM4("shadowModelView");
// uniform_shadowModelViewInverse = shaderUniforms.makeM4("shadowModelViewInverse");
// uniform_wetness = shaderUniforms.make1f("wetness");
// uniform_eyeAltitude = shaderUniforms.make1f("eyeAltitude");
// uniform_eyeBrightness = shaderUniforms.make2i("eyeBrightness");
// uniform_eyeBrightnessSmooth = shaderUniforms.make2i("eyeBrightnessSmooth");
// uniform_terrainTextureSize = shaderUniforms.make2i("terrainTextureSize");
// uniform_terrainIconSize = shaderUniforms.make1i("terrainIconSize");
// uniform_isEyeInWater = shaderUniforms.make1i("isEyeInWater");
// uniform_nightVision = shaderUniforms.make1f("nightVision");
// uniform_blindness = shaderUniforms.make1f("blindness");
// uniform_screenBrightness = shaderUniforms.make1f("screenBrightness");
// uniform_hideGUI = shaderUniforms.make1i("hideGUI");
// uniform_centerDepthSmooth = shaderUniforms.make1f("centerDepthSmooth");
// uniform_atlasSize = shaderUniforms.make2i("atlasSize");
// uniform_blendFunc = shaderUniforms.make4i("blendFunc");
// shadowPassInterval = 0;
// needResizeShadow = false;
// shadowMapWidth = 1024;
// shadowMapHeight = 1024;
// spShadowMapWidth = 1024;
// spShadowMapHeight = 1024;
// shadowMapFOV = 90.0F;
// shadowMapHalfPlane = 160.0F;
// shadowMapIsOrtho = true;
// shadowDistanceRenderMul = -1.0F;
// shadowPassCounter = 0;
// shouldSkipDefaultShadow = false;
// waterShadowEnabled = false;

usedColorBuffers = 0;
usedDepthBuffers = 0;
usedShadowColorBuffers = 0;
Expand Down Expand Up @@ -772,6 +659,9 @@ public void doSpecialInit() {

entityData = new int[32];
entityDataIndex = 0;

dfb = null;
sfb = null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ public void prepareRendering() {

deferredFb.fb.endWrite();
}

OFGlobal.bindToShaderFrameBuffer.run();
}

private void updateNeedsPortalRendering() {
Expand Down Expand Up @@ -221,7 +219,7 @@ protected void doRenderPortal(PortalLike portal, MatrixStack matrixStack) {

PortalRendering.pushPortalLayer(portal);

OFGlobal.bindToShaderFrameBuffer.run();
// OFGlobal.bindToShaderFrameBuffer.run();
renderPortalContent(portal);

int innerLayer = PortalRendering.getPortalLayer();
Expand Down Expand Up @@ -283,7 +281,7 @@ public void invokeWorldRendering(
worldRenderInfo,
runnable -> {
OFGlobal.shaderContextManager.switchContextAndRun(() -> {
OFGlobal.bindToShaderFrameBuffer.run();
// OFGlobal.bindToShaderFrameBuffer.run();
runnable.run();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.optifine.shaders.Shaders;
import net.optifine.shaders.uniform.CustomUniforms;
import net.optifine.shaders.uniform.ShaderUniforms;
import net.optifine.util.LineBuffer;
import org.lwjgl.BufferUtils;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -123,7 +124,7 @@ private static void redirectInitOnBeginRender() {
}
}

@Inject(method = "loadShaderPack", at = @At("TAIL"))
@Inject(method = "loadShaderPack", at = @At("RETURN"))
private static void onShaderPackLoaded(CallbackInfo ci) {
OFGlobal.shaderContextManager.updateTemplateContext();
}
Expand Down Expand Up @@ -167,19 +168,25 @@ private static void onCreateFragShader(
shouldModifyShaderCode = ShaderClippingManager.shouldModifyShaderCode(program);
}

// @ModifyVariable(
// method = "createFragShader",
// at = @At(
// value = "FIELD",
// target = "Lnet/optifine/shaders/Shaders;saveFinalShaders:Z"
// )
// )
// private static StringBuilder modifyFragShaderCode(StringBuilder shaderCode) {
// if (!shouldModifyShaderCode) {
// return shaderCode;
// }
// return ShaderClippingManager.modifyFragShaderCode(shaderCode);
// }
@Redirect(
method = "createFragShader",
at = @At(
value = "INVOKE",
target = "Lnet/optifine/util/LineBuffer;toString()Ljava/lang/String;"
)
)
private static String modifyFragShaderCode(LineBuffer lineBuffer) {
String result = lineBuffer.toString();
if (!shouldModifyShaderCode) {
return result;
}

StringBuilder stringBuilder = new StringBuilder(result);

StringBuilder modified = ShaderClippingManager.modifyFragShaderCode(stringBuilder);

return modified.toString();
}

@Inject(
method = "useProgram",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void prepare(int width, int height) {
true,//has depth attachment
MinecraftClient.IS_SYSTEM_MAC
);
Helper.log("Deferred buffer init");
}
if (width != fb.viewportWidth ||
height != fb.viewportHeight
Expand Down

0 comments on commit 04feea6

Please sign in to comment.