Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hopefully fix obliterating people's gpu memory #3297

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading