fix xray for high intersection count models

I don't understand why, but any deviation from this produces worse results
This commit is contained in:
Tim Kuipers 2020-02-27 18:42:27 +01:00
parent b51b699715
commit 5d90fd31d9
2 changed files with 12 additions and 12 deletions

View file

@ -51,9 +51,9 @@ fragment =
result = layer0 * layer0.a + result * (1.0 - layer0.a); result = layer0 * layer0.a + result * (1.0 - layer0.a);
float intersection_count = texture2D(u_layer2, v_uvs).r * 50; // 1 / .02 float intersection_count = texture2D(u_layer2, v_uvs).r * 51; // (1 / .02) + 1 (+1 magically fixes issues with high intersection count models)
float rest = mod(intersection_count, 2.0); float rest = mod(intersection_count + .01, 2.0);
if (rest > 0.5 && rest < 1.5) if (rest > 1.0 && rest < 1.5)
{ {
vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0); vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0);
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling); result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling);
@ -127,9 +127,9 @@ fragment41core =
result = layer0 * layer0.a + result * (1.0 - layer0.a); result = layer0 * layer0.a + result * (1.0 - layer0.a);
float intersection_count = texture(u_layer2, v_uvs).r * 50; // 1 / .02 float intersection_count = texture(u_layer2, v_uvs).r * 51; // (1 / .02) + 1 (+1 magically fixes issues with high intersection count models)
float rest = mod(intersection_count, 2.0); float rest = mod(intersection_count + .01, 2.0);
if (rest > 0.5 && rest < 1.5) if (rest > 1.0 && rest < 1.5)
{ {
vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0); vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0);
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling); result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling);

View file

@ -50,9 +50,9 @@ fragment =
result = layer0 * layer0.a + result * (1.0 - layer0.a); result = layer0 * layer0.a + result * (1.0 - layer0.a);
float intersection_count = texture2D(u_layer2, v_uvs).r * 50; // 1 / .02 float intersection_count = texture2D(u_layer2, v_uvs).r * 51; // (1 / .02) + 1 (+1 magically fixes issues with high intersection count models)
float rest = mod(intersection_count, 2.0); float rest = mod(intersection_count + .01, 2.0);
if (rest > 0.5 && rest < 1.5) if (rest > 1.0 && rest < 1.5)
{ {
result = u_error_color; result = u_error_color;
} }
@ -122,9 +122,9 @@ fragment41core =
result = layer0 * layer0.a + result * (1.0 - layer0.a); result = layer0 * layer0.a + result * (1.0 - layer0.a);
float intersection_count = texture(u_layer2, v_uvs).r * 50; // 1 / .02 float intersection_count = texture(u_layer2, v_uvs).r * 51; // (1 / .02) + 1 (+1 magically fixes issues with high intersection count models)
float rest = mod(intersection_count, 2.0); float rest = mod(intersection_count + .01, 2.0);
if (rest > 0.5 && rest < 1.5) if (rest > 1.0 && rest < 1.5)
{ {
result = u_error_color; result = u_error_color;
} }