aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/goodgenerator/client/render/AntimatterRenderer.java55
-rw-r--r--src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl4
2 files changed, 36 insertions, 23 deletions
diff --git a/src/main/java/goodgenerator/client/render/AntimatterRenderer.java b/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
index 109b362999..a6029b6f24 100644
--- a/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
+++ b/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
@@ -19,6 +19,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
import cpw.mods.fml.client.registry.ClientRegistry;
import goodgenerator.blocks.tileEntity.render.TileAntimatter;
+import gregtech.GTMod;
public class AntimatterRenderer extends TileEntitySpecialRenderer {
@@ -48,6 +49,7 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
private static final int beamVertexCount = particleCount * 6 * 6;
private boolean initialized = false;
+ private boolean hasFailed = false;
// Glowy Ring
private static ShaderProgram glowProgram;
@@ -85,14 +87,12 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
}
private void init() {
- antimatterProgram = new ShaderProgram(
- GoodGenerator.resourceDomain,
- "shaders/antimatter.vert.glsl",
- "shaders/antimatter.frag.glsl");
-
- antimatterProgram.use();
-
try {
+ antimatterProgram = new ShaderProgram(
+ GoodGenerator.resourceDomain,
+ "shaders/antimatter.vert.glsl",
+ "shaders/antimatter.frag.glsl");
+
uScale = antimatterProgram.getUniformLocation("u_Scale");
uScaleSnapshot = antimatterProgram.getUniformLocation("u_ScaleSnapshot");
uTime = antimatterProgram.getUniformLocation("u_Time");
@@ -100,11 +100,13 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
uOpacity = antimatterProgram.getUniformLocation("u_Opacity");
uColorCore = antimatterProgram.getUniformLocation("u_ColorCore");
uColorSpike = antimatterProgram.getUniformLocation("u_ColorSpike");
- } catch (NullPointerException e) {
- System.out.println(e.getMessage());
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
return;
}
+ antimatterProgram.use();
+
GL20.glUniform3f(uColorCore, TileAntimatter.coreR, TileAntimatter.coreG, TileAntimatter.coreB);
GL20.glUniform3f(uColorSpike, TileAntimatter.spikeR, TileAntimatter.spikeG, TileAntimatter.spikeB);
GL20.glUniform1f(uOpacity, 1);
@@ -113,25 +115,27 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
loadModels();
- protomatterProgram = new ShaderProgram(
- GoodGenerator.resourceDomain,
- "shaders/protomatter.vert.glsl",
- "shaders/protomatter.frag.glsl");
+ int uCubeCount = -1;
+ int uProtomatterVertices = -1;
- int uCubeCount;
- int uProtomatterVertices;
try {
+ protomatterProgram = new ShaderProgram(
+ GoodGenerator.resourceDomain,
+ "shaders/protomatter.vert.glsl",
+ "shaders/protomatter.frag.glsl");
+
uProtomatterVertices = protomatterProgram.getUniformLocation("u_Vertices");
uCubeCount = protomatterProgram.getUniformLocation("u_CubeCount");
uProtomatterTime = protomatterProgram.getUniformLocation("u_Time");
uProtomatterScale = protomatterProgram.getUniformLocation("u_Scale");
uProtomatterColor = protomatterProgram.getUniformLocation("u_Color");
uProtomatterSpiralRadius = protomatterProgram.getUniformLocation("u_SpiralRadius");
- } catch (NullPointerException e) {
- return;
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
}
protomatterProgram.use();
+
FloatBuffer bufferBeamVertexID = BufferUtils.createFloatBuffer(beamVertexCount * 3);
for (int i = 0; i < beamVertexCount; i++) {
bufferBeamVertexID.put(i * 3, i);
@@ -146,6 +150,7 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
.flip();
GL20.glUniform3(uProtomatterVertices, bufferBeamVertex);
GL20.glUniform1f(uCubeCount, particleCount);
+
ShaderProgram.clear();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
@@ -154,13 +159,16 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
GoodGenerator.resourceDomain,
"shaders/glow.vert.glsl",
"shaders/glow.frag.glsl");
- uGlowColor = glowProgram.getUniformLocation("u_Color");
- glowProgram.use();
- GL20.glUniform3f(uGlowColor, 0, 1f, 1f);
- } catch (NullPointerException e) {
+ uGlowColor = glowProgram.getUniformLocation("u_Color");
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
return;
}
+
+ glowProgram.use();
+ GL20.glUniform3f(uGlowColor, 0, 1f, 1f);
+
ShaderProgram.clear();
initialized = true;
@@ -260,12 +268,17 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
if (!Antimatter.shouldRender) return;
+ if (hasFailed) return;
+
if (!initialized) {
init();
if (!initialized) {
+ GTMod.GT_FML_LOGGER.error("Failed to properly initialize antimatter forge render");
+ hasFailed = true;
return;
}
}
+
float tx = (float) x + 0.5f;
float ty = (float) y + 0.5f;
float tz = (float) z + 0.5f;
diff --git a/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl b/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl
index 066225eddb..d34a364ad0 100644
--- a/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl
+++ b/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl
@@ -17,8 +17,8 @@ float wave ( vec3 input){
const float PI = 3.14159265358979323846;
-float lazyHash(vec3 input){
- vec3 v = fract(input*1.23456 + 3.1456);
+float lazyHash(vec3 toHash){
+ vec3 v = fract(toHash*1.23456 + 3.1456);
v*=7;
return fract(v.y + v.x*(v.z+1));
}