Skip to content

Commit

Permalink
Hopefully fix obliterating people's gpu memory
Browse files Browse the repository at this point in the history
  • Loading branch information
CookieBrigade committed Sep 28, 2024
1 parent e08a304 commit c350dc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/main/java/tectech/thing/block/RenderForgeOfGods.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class RenderForgeOfGods extends TileEntitySpecialRenderer {
private static float modelNormalize = .0067f * 2;

private static boolean initialized = false;
private static boolean failedInit = false;
private static int u_Color = -1, u_ModelMatrix = -1, u_Gamma = -1;
private Matrix4fStack starModelMatrix = new Matrix4fStack(3);

Expand Down Expand Up @@ -402,13 +403,24 @@ private void RenderRings(TileEntityForgeOfGods tile, double x, double y, double

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) {
if (failedInit) return;
if (!(tile instanceof TileEntityForgeOfGods forgeTile)) return;
if (forgeTile.getRingCount() < 1) return;

// If something ever fails, just early return and never try again this session
if (!initialized) {
init();
initRings();
if (!initialized) return;
if (!initialized) {
failedInit = true;
return;
}
try {
initRings();
} catch (Exception e) {
System.out.println(e.getMessage());
failedInit = true;
return;
}
}

// Based on system time to prevent tps issues from causing stutters
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/tectech/shaders/star.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() {
vec3 originalYIQ = toYIQ(texture);
vec3 yiqColor = vec3(original.x,targetYIQ.yz);
vec3 finalrgb = toRGB(yiqColor);
finalrgb = pow(finalrgb,vec3(1/u_Gamma));
finalrgb = pow(finalrgb,vec3(1.0/u_Gamma));
gl_FragColor = vec4(finalrgb,u_Color.a);
}
}

0 comments on commit c350dc1

Please sign in to comment.