diff --git a/assets/shaders/confictura/portal-forcefield.frag b/assets/shaders/confictura/portal-forcefield.frag index 4866c87..0c7ff40 100644 --- a/assets/shaders/confictura/portal-forcefield.frag +++ b/assets/shaders/confictura/portal-forcefield.frag @@ -224,4 +224,10 @@ void main(){ vec3 outlineColor = v_color.xyz * pow(max(1.0 - v_color.a - 0.5, 0.0) * 2.0, 4.0) * outline; gl_FragColor = vec4(baseColor + outlineColor, 1.0); + + #ifdef HAS_GL_FRAGDEPTH + float far = gl_DepthRange.far, near = gl_DepthRange.near; + vec4 clip = u_proj * vec4(u_camPos + ray * intersect.x, 1.0); + gl_FragDepth = (((far - near) * (clip.z / clip.w)) + near + far) / 2.0; + #endif } diff --git a/src/confictura/graphics/CShaders.java b/src/confictura/graphics/CShaders.java index 22fe549..eff21bb 100644 --- a/src/confictura/graphics/CShaders.java +++ b/src/confictura/graphics/CShaders.java @@ -2,9 +2,11 @@ import arc.files.*; import arc.graphics.gl.*; +import arc.graphics.gl.GLVersion.*; import confictura.graphics.shaders.*; import mindustry.*; +import static arc.Core.*; import static mindustry.Vars.*; /** @@ -23,10 +25,19 @@ private CShaders(){ /** Loads the shaders. Client-side and main thread only! */ public static void load(){ + String prevVert = Shader.prependVertexCode, prevFrag = Shader.prependFragmentCode; + + if(graphics.getGLVersion().type == GlType.OpenGL){ + Shader.prependFragmentCode = "#define HAS_GL_FRAGDEPTH\n"; + } + depth = new DepthShader(); depthAtmosphere = new DepthAtmosphereShader(); portalForcefield = new PortalForcefieldShader(); celestial = new CelestialShader(); + + Shader.prependVertexCode = prevVert; + Shader.prependFragmentCode = prevFrag; } /**