add DISTANT HORIZONS SHADER PROGRAMS, and then make them work.

This commit is contained in:
Xonk
2024-02-05 16:04:37 -05:00
parent 4b7ef65541
commit 1b15799911
51 changed files with 1912 additions and 351 deletions

View File

@ -62,6 +62,40 @@ float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
}
// uniform float viewWidth;
// uniform float viewHeight;
// uniform sampler2D depthtex0;
uniform sampler2D dhDepthTex;
// uniform mat4 gbufferProjectionInverse;
uniform mat4 dhProjectionInverse;
vec3 getViewPos() {
ivec2 uv = ivec2(gl_FragCoord.xy);
vec2 viewSize = vec2(viewWidth, viewHeight);
vec2 texcoord = gl_FragCoord.xy / viewSize;
vec4 viewPos = vec4(0.0);
float depth = texelFetch(depthtex0, uv, 0).r;
if (depth < 1.0) {
vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
viewPos = gbufferProjectionInverse * ndcPos;
viewPos.xyz /= viewPos.w;
} else {
depth = texelFetch(dhDepthTex, ivec2(gl_FragCoord.xy), 0).r;
vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
viewPos = dhProjectionInverse * ndcPos;
viewPos.xyz /= viewPos.w;
}
return viewPos.xyz;
}
#define linear_to_srgb(x) (pow(x, vec3(1.0/2.2)))
void main() {
/* DRAWBUFFERS:7 */
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
@ -126,6 +160,12 @@ void main() {
col = mix(lum * vec3(Purkinje_R, Purkinje_G, Purkinje_B) * Purkinje_Multiplier, col, rodCurve);
// gl_FragColor = vec4(getViewPos() * 0.001,1.0);
// gl_FragColor.rgb = linear_to_srgb(gl_FragColor.rgb);
#ifndef USE_ACES_COLORSPACE_APPROXIMATION
col = LinearTosRGB(TONEMAP(col));
#else