Compare commits

...

2 Commits

Author SHA1 Message Date
James Seibel 269f2c30fd Initial changes for Vulkan 2026-05-11 21:56:53 -05:00
James Seibel b674f49600 up version number 3.0.3 -> 3.0.4 2026-05-04 07:41:32 -05:00
4 changed files with 36 additions and 12 deletions
@@ -43,7 +43,7 @@ public final class ModInfo
public static final String NAME = "DistantHorizons"; public static final String NAME = "DistantHorizons";
/** Human-readable version of NAME */ /** Human-readable version of NAME */
public static final String READABLE_NAME = "Distant Horizons"; public static final String READABLE_NAME = "Distant Horizons";
public static final String VERSION = "3.0.3-b"; public static final String VERSION = "3.0.4-b-dev";
/** Returns true if the current build is an unstable developer build, false otherwise. */ /** Returns true if the current build is an unstable developer build, false otherwise. */
public static final boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev"); public static final boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev");
@@ -28,9 +28,32 @@ layout (std140) uniform fragUniformBlock
vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj)
{ {
// normalized device coordinates // normalized device coordinates
vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); vec4 ndc = vec4(
TexCoord.x, // UV [0,1]
TexCoord.y,
fragmentDepth, // depth [0,1]
1.0
);
// AKA: remap the [0,1] UV coordinates and depth value
// into the [-1,1] positions used by
// the NDC cube rendering stage
ndc.xyz = ndc.xyz * 2.0 - 1.0; ndc.xyz = ndc.xyz * 2.0 - 1.0;
vec4 eyeCoord = invMvmProj * ndc;
return eyeCoord.xyz / eyeCoord.w;
}
// TODO vulkan
vec3 calcReversedZViewPosition(float fragmentDepth, mat4 invMvmProj)
{
// Vulkan NDC: xy in [-1,+1], z already in [0,1] — don't remap z
vec4 ndc = vec4(
TexCoord.x * 2.0 - 1.0, // UV [0,1] -> NDC [-1,+1]
TexCoord.y * 2.0 - 1.0,
fragmentDepth, // no remapping needed, this depth is already in the [0,1] range
1.0 // w=1 placeholder for matrix multiplication
);
vec4 eyeCoord = invMvmProj * ndc; vec4 eyeCoord = invMvmProj * ndc;
return eyeCoord.xyz / eyeCoord.w; return eyeCoord.xyz / eyeCoord.w;
} }
@@ -71,12 +94,13 @@ void main()
{ {
fragColor = vec4(combinedMcDhColor.rgb, 0.0); fragColor = vec4(combinedMcDhColor.rgb, 0.0);
} }
// a fragment depth of "1" means the fragment wasn't drawn to, // // a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to fade vanilla rendered objects, not to the sky or LODs // // we only want to fade vanilla rendered objects, not to the sky or LODs
else if (mcFragmentDepth < 1.0) // else if (mcFragmentDepth < 1.0)
else if (mcFragmentDepth > 0)
{ {
// fade based on distance from the camera // fade based on distance from the camera
vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj); vec3 mcVertexWorldPos = calcReversedZViewPosition(mcFragmentDepth, uMcInvMvmProj);
float mcFragmentDistance = length(mcVertexWorldPos.xzy); float mcFragmentDistance = length(mcVertexWorldPos.xzy);
@@ -1,7 +1,6 @@
#version 150 core #version 150 core
in vec2 vPosition; in vec2 vPosition;
in vec4 vColor;
out vec4 fColor; out vec4 fColor;
out vec2 TexCoord; out vec2 TexCoord;
@@ -113,12 +113,13 @@ void main()
float fadeDistance = uFadeDistanceInBlocks; float fadeDistance = uFadeDistanceInBlocks;
if (distanceFromCamera < fadeDistance) if (distanceFromCamera < fadeDistance)
{ {
#ifdef GL_ARB_derivative_control // TODO vulkan
// Get higher precision derivatives when available // #ifdef GL_ARB_derivative_control
vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz)); // // Get higher precision derivatives when available
#else // vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz));
// #else
vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz)); vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz));
#endif // #endif
viewNormal = normalize(viewNormal); viewNormal = normalize(viewNormal);
occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal); occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal);