Skip to content

[Distant Horizons] Beacon beams depth-test #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion shaders/lib/util/spaceConversion.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ vec3 ShadowClipToShadowView(vec3 pos) {

vec3 ShadowViewToPlayer(vec3 pos) {
return mat3(shadowModelViewInverse) * pos;
}
}

// Distant Horizon
#ifdef DISTANT_HORIZONS

vec3 ScreenToViewDH(vec3 pos) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x,
dhProjectionInverse[1].y,
dhProjectionInverse[2].zw);
vec3 p3 = pos * 2.0 - 1.0;
vec4 viewPos = iProjDiag * p3.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}

#endif
13 changes: 13 additions & 0 deletions shaders/program/gbuffers_beaconbeam.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ void main() {
#else
vec3 viewPos = ScreenToView(screenPos);
#endif

#ifdef DISTANT_HORIZONS
vec3 screenPosDH = vec3(screenPos.xy, texture2D(dhDepthTex, screenPos.xy).r);
#ifdef TAA
vec3 viewPosDH = ScreenToViewDH(vec3(TAAJitter(screenPosDH.xy, -0.5), screenPosDH.z));
#else
vec3 viewPosDH = ScreenToViewDH(screenPosDH);
#endif

if (viewPos.z < viewPosDH.z)
discard;
#endif

float lViewPos = length(viewPos);

#ifdef IPBR
Expand Down