Skip to content

Commit

Permalink
Log error when can't create shader debug output folder
Browse files Browse the repository at this point in the history
  • Loading branch information
grondag committed Jun 18, 2020
1 parent 1cb7f62 commit 91ac511
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ group=grondag
mod_name=canvas
canvas_version=1.0

fermion_version=2.0
fermion_version=2.1
special_circumstances_version=1.6
fermion_varia_version=2.0
fermion_varia_version=2.1
fermion_orientation_version=1.0
frex_version=2.2
frex_version=2.3

jankson_version=3.0.0+j1.2.0
clothconfig_version=4.5.3
Expand Down
70 changes: 35 additions & 35 deletions src/main/java/grondag/canvas/light/LightmapHdCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,39 +254,39 @@ static void computeAo(int[] light, AoFaceData faceData) {
// }
}

private static void computeQuadrantAo(float center, float uSide, float vSide, float corner, int light[], Int2IntFunction uFunc, Int2IntFunction vFunc) {
//FIX: handle error case when center is missing
if(uSide == AoFaceData.OPAQUE) {
if(vSide == AoFaceData.OPAQUE) {
// fully enclosed
computeOpen(center, center - 0.5f, center - 0.5f, center - 0.5f, light, uFunc, vFunc);
} else if (corner == AoFaceData.OPAQUE) {
// U + corner enclosing
uSide = center - 0.25f;
computeClamped(center, uSide, (vSide + center) * 0.5f, (uSide + vSide - 0.25f) * 0.5f, light, uFunc, vFunc);
} else {
// U side enclosing
final float join = (center + vSide + corner) / 3f;
computeClamped(center, center - 0.25f, (vSide + center) * 0.5f, join, light, uFunc, vFunc);
}
} else if(vSide == AoFaceData.OPAQUE) {
if(corner == AoFaceData.OPAQUE) {
// V + corner enclosing
vSide = center - 0.25f;
computeClamped(center, (uSide + center) * 0.5f, vSide, (uSide + vSide - 0.25f) * 0.5f, light, uFunc, vFunc);
} else {
// V side enclosing
final float join = (center + uSide + corner) / 3f;
computeClamped(center, (uSide + center) * 0.5f, center - 0.25f, join, light, uFunc, vFunc);
}

} else if(corner == AoFaceData.OPAQUE) {
// opaque corner
final float join = (center + uSide + vSide) / 3f;
computeClamped(center, (uSide + center) * 0.5f, (vSide + center) * 0.5f, join, light, uFunc, vFunc);
} else {
// all open
computeOpen(center, uSide, vSide, corner, light, uFunc, vFunc);
}
}
// private static void computeQuadrantAo(float center, float uSide, float vSide, float corner, int light[], Int2IntFunction uFunc, Int2IntFunction vFunc) {
// //FIX: handle error case when center is missing
// if(uSide == AoFaceData.OPAQUE) {
// if(vSide == AoFaceData.OPAQUE) {
// // fully enclosed
// computeOpen(center, center - 0.5f, center - 0.5f, center - 0.5f, light, uFunc, vFunc);
// } else if (corner == AoFaceData.OPAQUE) {
// // U + corner enclosing
// uSide = center - 0.25f;
// computeClamped(center, uSide, (vSide + center) * 0.5f, (uSide + vSide - 0.25f) * 0.5f, light, uFunc, vFunc);
// } else {
// // U side enclosing
// final float join = (center + vSide + corner) / 3f;
// computeClamped(center, center - 0.25f, (vSide + center) * 0.5f, join, light, uFunc, vFunc);
// }
// } else if(vSide == AoFaceData.OPAQUE) {
// if(corner == AoFaceData.OPAQUE) {
// // V + corner enclosing
// vSide = center - 0.25f;
// computeClamped(center, (uSide + center) * 0.5f, vSide, (uSide + vSide - 0.25f) * 0.5f, light, uFunc, vFunc);
// } else {
// // V side enclosing
// final float join = (center + uSide + corner) / 3f;
// computeClamped(center, (uSide + center) * 0.5f, center - 0.25f, join, light, uFunc, vFunc);
// }
//
// } else if(corner == AoFaceData.OPAQUE) {
// // opaque corner
// final float join = (center + uSide + vSide) / 3f;
// computeClamped(center, (uSide + center) * 0.5f, (vSide + center) * 0.5f, join, light, uFunc, vFunc);
// } else {
// // all open
// computeOpen(center, uSide, vSide, corner, light, uFunc, vFunc);
// }
// }
}
7 changes: 6 additions & 1 deletion src/main/java/grondag/canvas/shader/GlShader.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ private static void clearDebugSource() {
}
}

private static boolean needsDebugOutputWarning = true;

private void outputDebugSource(String source, String error) {
final String key = shaderSource.toString().replace("/", "-") + "." + context.name;
final File gameDir = FabricLoader.getInstance().getGameDirectory();
Expand All @@ -190,7 +192,10 @@ private void outputDebugSource(String source, String error) {
writer.write(source);
writer.close();
} catch (final IOException e) {
// TODO: log failure to output source
if (needsDebugOutputWarning) {
CanvasMod.LOG.error(I18n.translate("error.canvas.fail_create_shader_output", shaderDir), e);
needsDebugOutputWarning = false;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/canvas/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"debug.canvas.missing_uniform" : "Canvas unable to find uniform %s in shaders %s, %s. This is normal if the uniform isn't used in the shader.",
"info.canvas.reloading" : "Canvas Renderer is initializing.",
"error.canvas.fail_create_shader" : "Canvas unable to create shader %s with property index %d due to unexpected error: %s.",
"error.canvas.fail_create_shader_output" : "Canvas unable to create shader output folder %s due to unexpected error.",
"error.canvas.fail_create_any_shader" : "Canvas unable to create one or more shaders due to compilation errors. See canvas_shader_debug folder for details.",
"error.canvas.program_link_failure" : "Canvas unable to create linked shader due to unexpected error.",
"error.canvas.fail_create_lightmap" : "Canvas unable to create HD lightmap(s) - out of space. \nSome blocks will not render with proper lighting. \nReduce view distance or disable HD lightmaps. F3+A will temporarily clear this problem.",
Expand Down

0 comments on commit 91ac511

Please sign in to comment.