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

@ -0,0 +1,97 @@
#include "/lib/settings.glsl"
varying vec4 pos;
varying vec4 gcolor;
varying vec2 lightmapCoords;
varying vec4 normals_and_materials;
flat varying float SSSAMOUNT;
flat varying float EMISSIVE;
uniform float far;
// uniform int hideGUI;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
vec3 viewToWorld(vec3 viewPosition) {
vec4 pos;
pos.xyz = viewPosition;
pos.w = 0.0;
pos = gbufferModelViewInverse * pos;
return pos.xyz;
}
vec3 worldToView(vec3 worldPos) {
vec4 pos = vec4(worldPos, 0.0);
pos = gbufferModelView * pos;
return pos.xyz;
}
vec4 encode (vec3 n, vec2 lightmaps){
n.xy = n.xy / dot(abs(n), vec3(1.0));
n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy;
vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0);
return vec4(encn,vec2(lightmaps.x,lightmaps.y));
}
//encoding by jodie
float encodeVec2(vec2 a){
const vec2 constant1 = vec2( 1., 256.) / 65535.;
vec2 temp = floor( a * 255. );
return temp.x*constant1.x+temp.y*constant1.y;
}
float encodeVec2(float x,float y){
return encodeVec2(vec2(x,y));
}
// uniform sampler2D depthtex0;
// uniform vec2 texelSize;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
/* RENDERTARGETS:1,7,8 */
void main() {
// overdraw prevention
// if(clamp(1.0-length(pos.xyz)/max(far-16,0.0),0,1) > 0 ) discard;
vec3 normals = viewToWorld(normals_and_materials.xyz);
float materials = normals_and_materials.a;
vec4 data1 = clamp( encode(normals.xyz, vec2(lightmapCoords)), 0.0, 1.0);
// alpha is material masks, set it to 0.65 to make a DH LODs mask.
vec4 Albedo = vec4(gcolor.rgb, 1.0);
#ifdef WhiteWorld
Albedo.rgb = vec3(0.5);
#endif
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w, materials));
gl_FragData[1].a = 0.0;
#if EMISSIVE_TYPE == 0
gl_FragData[2].a = 0.0;
#else
gl_FragData[2].a = EMISSIVE;
#endif
#if SSS_TYPE == 0
gl_FragData[2].b = 0.0;
#else
gl_FragData[2].b = SSSAMOUNT;
#endif
}

View File

@ -0,0 +1,49 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
varying vec4 pos;
varying vec4 gcolor;
varying vec2 lightmapCoords;
varying vec4 normals_and_materials;
flat varying float SSSAMOUNT;
flat varying float EMISSIVE;
uniform vec2 texelSize;
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
void main() {
gl_Position = ftransform();
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
lightmapCoords = gl_MultiTexCoord1.xy * 0.975; // is this even correct? lol'
gcolor = gl_Color;
pos = gl_ModelViewMatrix * gl_Vertex;
EMISSIVE = 0.0;
if(dhMaterialId == DH_BLOCK_ILLUMINATED || gl_MultiTexCoord1.x >= 0.95) EMISSIVE = 0.5;
SSSAMOUNT = 0.0;
if (dhMaterialId == DH_BLOCK_LEAVES ) SSSAMOUNT = 1.0;
if (dhMaterialId == DH_BLOCK_SNOW) SSSAMOUNT = 0.5;
// a mask for DH terrain in general.
float MATERIALS = 0.65;
normals_and_materials = vec4(normalize(gl_NormalMatrix * gl_Normal), MATERIALS);
}

View File

@ -0,0 +1,360 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
#include "/lib/color_transforms.glsl"
#include "/lib/projections.glsl"
uniform vec2 texelSize;
// uniform int moonPhase;
uniform float frameTimeCounter;
uniform sampler2D noisetex;
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2D dhDepthTex;
// uniform sampler2D dhDepthTex0;
uniform sampler2D dhDepthTex1;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex12;
// uniform sampler2D colortex7;
uniform sampler2D colortex5;
#include "/lib/sky_gradient.glsl"
#include "/lib/waterBump.glsl"
#include "/lib/Shadow_Params.glsl"
varying vec4 pos;
varying vec4 gcolor;
varying vec4 normals_and_materials;
varying vec2 lightmapCoords;
flat varying int isWater;
// uniform float far;
uniform float dhFarPlane;
uniform float dhNearPlane;
uniform vec3 previousCameraPosition;
// uniform vec3 cameraPosition;
// uniform mat4 gbufferModelView;
uniform mat4 gbufferPreviousModelView;
// uniform mat4 shadowModelView;
// uniform mat4 shadowModelViewInverse;
// uniform mat4 shadowProjection;
// uniform mat4 shadowProjectionInverse;
uniform int frameCounter;
// uniform sampler2D colortex4;
flat varying vec3 averageSkyCol_Clouds;
flat varying vec4 lightCol;
flat varying vec3 WsunVec;
flat varying vec3 WsunVec2;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
// uniform mat4 dhPreviousProjection;
// uniform mat4 dhProjectionInverse;
// uniform mat4 dhProjection;
#include "/lib/DistantHorizons_projections.glsl"
vec3 DH_toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
// float DH_ld(float dist) {
// return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
// }
// float DH_invLinZ (float lindepth){
// return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
// }
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
uniform int isEyeInWater;
uniform float rainStrength;
#include "/lib/volumetricClouds.glsl"
vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
r = pow(r,2.5);
// r*=r;
vec3 h = l + v;
float hn = inversesqrt(dot(h, h));
float dotLH = clamp(dot(h,l)*hn,0.,1.);
float dotNH = clamp(dot(h,n)*hn,0.,1.) ;
float dotNL = clamp(dot(n,l),0.,1.);
float dotNHsq = dotNH*dotNH;
float denom = dotNHsq * r - dotNHsq + 1.;
float D = r / (3.141592653589793 * denom * denom);
vec3 F = 0.2 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
float k2 = .25 * r;
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
}
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater){
float quality = mix(15,SSR_STEPS,fresnel);
vec3 clipPosition = DH_toClipSpace3(position);
float rayLength = ((position.z + dir.z * dhFarPlane*sqrt(3.)) > -dhNearPlane) ?
(-dhNearPlane -position.z) / dir.z : dhFarPlane*sqrt(3.);
vec3 direction = normalize(DH_toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space
direction.xy = normalize(direction.xy);
//get at which length the ray intersects with the edge of the screen
vec3 maxLengths = (step(0.,direction)-clipPosition) / direction;
float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z);
vec3 stepv = direction * mult / quality * vec3(RENDER_SCALE,1.0);
vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv;
float minZ = clipPosition.z;
float maxZ = spos.z+stepv.z*0.5;
spos.xy += offsets[framemod8]*texelSize*0.5/RENDER_SCALE;
float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases
for (int i = 0; i <= int(quality); i++) {
float sp = sqrt(texelFetch2D(colortex12,ivec2(spos.xy/texelSize/4),0).a/65000.0);
sp = DH_inv_ld(sp);
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
spos += stepv;
//small bias
minZ = maxZ-0.00035/DH_ld(spos.z);
maxZ += stepv.z;
}
return vec3(1.1);
}
float R2_dither(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715) ) );
return noise ;
}
vec3 viewToWorld(vec3 viewPos) {
vec4 pos;
pos.xyz = viewPos;
pos.w = 0.0;
pos = gbufferModelViewInverse * pos;
return pos.xyz;
}
vec3 worldToView(vec3 worldPos) {
vec4 pos = vec4(worldPos, 0.0);
pos = gbufferModelView * pos;
return pos.xyz;
}
vec4 encode (vec3 n, vec2 lightmaps){
n.xy = n.xy / dot(abs(n), vec3(1.0));
n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy;
vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0);
return vec4(encn,vec2(lightmaps.x,lightmaps.y));
}
//encoding by jodie
float encodeVec2(vec2 a){
const vec2 constant1 = vec2( 1., 256.) / 65535.;
vec2 temp = floor( a * 255. );
return temp.x*constant1.x+temp.y*constant1.y;
}
float encodeVec2(float x,float y){
return encodeVec2(vec2(x,y));
}
uniform float near;
// uniform float far;
float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near));
}
/* RENDERTARGETS:2,7 */
void main() {
bool iswater = isWater > 0;
vec3 normals = normals_and_materials.xyz;
vec3 playerPos = mat3(gbufferModelViewInverse) * pos.xyz;
float transition = exp(-25* pow(clamp(1.0 - length(playerPos)/(far-8),0.0,1.0),2));
if(iswater){
vec3 posxz = playerPos+cameraPosition;
posxz.xz -= posxz.y;
vec3 waterHeightmap = normalize(getWaveHeight(posxz.xz,1.0));
float bumpmult = WATER_WAVE_STRENGTH;
waterHeightmap = waterHeightmap * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
waterHeightmap = normalize(waterHeightmap);
vec2 TangentNormal = waterHeightmap.xy*0.5+0.5;
// gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(vec2(1.0)), encodeVec2(vec2(1.0)), 1.0);
if(normals.y > 0.0) normals = vec3(waterHeightmap.x,normals.y,waterHeightmap.y);
}
normals = worldToView(normals);
vec3 Albedo = toLinear(gcolor.rgb);
gl_FragData[0] = vec4(Albedo, gcolor.a);
vec4 COLORTEST = gl_FragData[0];
if(iswater){
Albedo = vec3(0.0);
gl_FragData[0].a = 1.0/255.0;
}
// diffuse
vec3 Direct_lighting = lightCol.rgb/80.0;
float NdotL = max(dot(normals, WsunVec2), 0.0f);
Direct_lighting *= NdotL;
#ifdef CLOUDS_SHADOWS
Direct_lighting *= GetCloudShadow(playerPos);
#endif
#ifdef DISTANT_HORIZONS_SHADOWMAP
float Shadows = 1.0;
mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection);
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * pos.xyz + gbufferModelViewInverse[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(DH_shadowProjection) * projectedShadowPosition + DH_shadowProjection[3].xyz;
//apply distortion
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#else
float distortFactor = 1.0;
#endif
float smallbias = -0.0035;
bool ShadowBounds = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0;
if(ShadowBounds){
Shadows = 0.0;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
Shadows = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x;
}
Direct_lighting *= Shadows;
#endif
vec3 Indirect_lighting = averageSkyCol_Clouds/30.0;
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
// specular
vec3 reflectedVector = reflect(normalize(pos.xyz), normals);
float fresnel = pow(clamp(1.0 + dot(normals, normalize(pos.xyz)), 0.0, 1.0),5.0);
fresnel = mix(0.02, 1.0, fresnel);
#ifdef WATER_REFLECTIONS
vec4 ssReflections = vec4(0);
#ifdef SCREENSPACE_REFLECTIONS
vec3 rtPos = rayTrace(reflectedVector, pos.xyz, interleaved_gradientNoise(), fresnel, false);
if (rtPos.z < 1.){
vec3 previousPosition = mat3(gbufferModelViewInverse) * DH_toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
previousPosition.xy = projMAD(dhPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) {
ssReflections.a = 1.0;
ssReflections.rgb = texture2D(colortex5, previousPosition.xy).rgb;
}
}
#endif
vec3 skyReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0 ;
skyReflection = mix(skyReflection, ssReflections.rgb, ssReflections.a);
vec3 sunReflection = Direct_lighting * GGX(normals, -normalize(pos.xyz), WsunVec2, 0.05, vec3(0.02));
gl_FragData[0].rgb = mix(gl_FragData[0].rgb, skyReflection, fresnel) + sunReflection ;
gl_FragData[0].a = mix(gl_FragData[0].a, 1.0, fresnel);
#endif
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, min(max(1.0 - length(pos.xz)/far,0.0)*2.0,1.0) );
float material = 1.0;
if(texture2D(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){
gl_FragData[0].a = 0.0;
material = 0.0;
}
// gl_FragData[0] = vec4(ld(texture2D(depthtex0, gl_FragCoord.xy*texelSize).x) * vec3(1.0), 1.0);
// if(gl_FragCoord.x*texelSize.x > 0.53) gl_FragData[0] = vec4(0.0);
gl_FragData[1] = vec4(Albedo, material);
}

View File

@ -0,0 +1,76 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
varying vec4 pos;
varying vec4 gcolor;
varying vec4 normals_and_materials;
varying vec2 lightmapCoords;
flat varying int isWater;
uniform sampler2D colortex4;
flat varying vec3 averageSkyCol_Clouds;
flat varying vec4 lightCol;
varying mat4 normalmatrix;
uniform mat4 gbufferModelViewInverse;
flat varying vec3 WsunVec;
flat varying vec3 WsunVec2;
uniform vec3 sunPosition;
uniform float sunElevation;
uniform vec2 texelSize;
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
void main() {
gl_Position = ftransform();
isWater = 0;
if (dhMaterialId == DH_BLOCK_WATER){
isWater = 1;
// gl_Position.y -= 6.0/16.0;
}
normals_and_materials = vec4(normalize(gl_Normal), 1.0);
gcolor = gl_Color;
lightmapCoords = gl_MultiTexCoord1.xy;
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0;
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition);
WsunVec2 = lightCol.a * normalize(sunPosition);
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
pos = gl_ModelViewMatrix * gl_Vertex;
}

View File

@ -4,6 +4,10 @@
varying vec4 lmtexcoord;
varying vec4 color;
#ifdef LINES
flat varying int SELECTION_BOX;
#endif
#ifdef OVERWORLD_SHADER
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
@ -86,6 +90,13 @@ float phaseg(float x, float g){
/* DRAWBUFFERS:29 */
void main() {
#ifdef LINES
#ifndef SELECT_BOX
if(SELECTION_BOX > 0) discard;
#endif
#endif
vec2 tempOffset = offsets[framemod8];
vec3 viewPos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
@ -137,8 +148,12 @@ void main() {
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#else
float distortFactor = 1.0;
#endif
//do shadows only if on shadow map
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){

View File

@ -11,12 +11,18 @@ Read the terms of modification and sharing before changing something below pleas
varying vec4 lmtexcoord;
varying vec4 color;
#ifdef LINES
flat varying int SELECTION_BOX;
#endif
#ifdef OVERWORLD_SHADER
flat varying vec3 averageSkyCol_Clouds;
flat varying vec4 lightCol;
flat varying vec3 WsunVec;
uniform sampler2D colortex4;
#endif
uniform vec3 sunPosition;
uniform float sunElevation;
@ -89,9 +95,12 @@ void main() {
color = gl_Color;
// color.rgb = worldpos;
#ifdef LINES
color.a = 1.0;
SELECTION_BOX = 0;
if(dot(color.rgb,vec3(0.33333)) < 0.00001) SELECTION_BOX = 1;
#endif
#ifdef OVERWORLD_SHADER
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0;

View File

@ -29,6 +29,7 @@ flat varying float HELD_ITEM_BRIGHTNESS;
const bool colortex4MipmapEnabled = true;
uniform sampler2D noisetex;
uniform sampler2D depthtex1;
uniform sampler2D depthtex0;
uniform sampler2D colortex5;
uniform sampler2D texture;
@ -246,7 +247,7 @@ vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater)
#else
vec2 testthing = spos.xy/texelSize/4.0;
#endif
float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a+0.1)/65000.0);
float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a)/65000.0);
sp = invLinZ(sp);
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
@ -276,12 +277,15 @@ vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
float denom = dotNHsq * r - dotNHsq + 1.;
float D = r / (3.141592653589793 * denom * denom);
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
vec3 F = 0.2 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
float k2 = .25 * r;
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
}
uniform float dhFarPlane;
#include "/lib/DistantHorizons_projections.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -293,7 +297,9 @@ void main() {
if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) {
vec2 tempOffset = offsets[framemod8];
vec3 viewPos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
@ -399,14 +405,20 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection);
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
// vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos_shadow + Custom_ViewMatrix[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
projectedShadowPosition = diagonal3(DH_shadowProjection) * projectedShadowPosition + DH_shadowProjection[3].xyz;
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#else
float distortFactor = 1.0;
#endif
bool ShadowBounds = false;
if(shadowDistanceRenderMul > 0.0) ShadowBounds = length(feetPlayerPos_shadow) < max(shadowDistance - 20,0.0);
@ -597,7 +609,9 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
gl_FragData[0].a = mix(gl_FragData[0].a, 1.0, fresnel);
#endif
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
#ifdef DISTANT_HORIZONS
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, 1.0-min(max(1.0 - length(feetPlayerPos.xz)/far,0.0)*2.0,1.0) );
#endif
} else {
gl_FragData[0].rgb = FinalColor;
@ -611,6 +625,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
gl_FragData[1] = vec4(Albedo, iswater);
#endif
// if(gl_FragCoord.x*texelSize.x < 0.47) gl_FragData[0] = vec4(0.0);
gl_FragData[3].a = max(lmtexcoord.w*blueNoise()*0.05 + lmtexcoord.w,0.0);
}
}

View File

@ -72,6 +72,7 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
}
varying vec4 pos;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -87,6 +88,8 @@ void main() {
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
gl_Position = toClipSpace3(position);
pos = vec4(position,1);
HELD_ITEM_BRIGHTNESS = 0.0;
#ifdef Hand_Held_lights

View File

@ -7,6 +7,9 @@ flat varying vec2 TAA_Offset;
#include "/lib/res_params.glsl"
uniform sampler2D depthtex1;
uniform sampler2D dhDepthTex;
uniform sampler2D dhDepthTex1;
uniform sampler2D colortex1;
uniform sampler2D colortex6; // Noise
uniform sampler2D colortex8; // Noise
@ -29,8 +32,11 @@ uniform vec3 cameraPosition;
uniform float viewWidth;
uniform float aspectRatio;
uniform float viewHeight;
// uniform float far;
uniform float near;
uniform float dhFarPlane;
uniform float dhNearPlane;
#define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0)
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
@ -41,6 +47,8 @@ vec3 toScreenSpace(vec3 p) {
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
vec3 worldToView(vec3 worldPos) {
vec4 pos = vec4(worldPos, 0.0);
pos = gbufferModelView * pos;
@ -142,11 +150,29 @@ vec2 SpiralSample(
return vec2(x, y);
}
#include "/lib/DistantHorizons_projections.glsl"
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
void main() {
/* DRAWBUFFERS:3 */
vec2 texcoord = gl_FragCoord.xy*texelSize;
float z = texture2D(depthtex1,texcoord).x;
float DH_depth1 = texture2D(depthtex1,texcoord).x;
vec2 tempOffset=TAA_Offset;
@ -194,28 +220,32 @@ void main() {
gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0);
gl_FragData[0].y = 0;
// vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5, z, DH_depth1);
#ifdef Variable_Penumbra_Shadows
if (NdotL > 0.001 || LabSSS > 0.0) {
if (LabSSS > 0.0) {
mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection);
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
// GriAndEminShadowFix(p3, viewToWorld(FlatNormals), vanillAO, lightmap.y, entities);
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
// vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos + Custom_ViewMatrix[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
projectedShadowPosition = diagonal3(DH_shadowProjection) * projectedShadowPosition + DH_shadowProjection[3].xyz;
//apply distortion
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#else
float distortFactor = 1.0;
#endif
//do shadows only if on shadow map
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0){
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0 || length(feetPlayerPos) < far){
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor;
float diffthresh = distortThresh/6000.0*threshMul;

View File

@ -1,6 +1,9 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
const bool colortex5MipmapEnabled = true;
#ifdef OVERWORLD_SHADER
@ -38,9 +41,12 @@ const bool colortex5MipmapEnabled = true;
uniform int hideGUI;
uniform sampler2D noisetex; //noise
uniform sampler2D depthtex0; //depth
uniform sampler2D depthtex1; //depth
uniform sampler2D depthtex2; //depth
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
uniform sampler2D dhDepthTex;
uniform sampler2D dhDepthTex1;
uniform sampler2D colortex0; //clouds
uniform sampler2D colortex1; //albedo(rgb),material(alpha) RGBA16
@ -75,6 +81,8 @@ uniform vec3 previousCameraPosition;
// uniform float far;
uniform float near;
uniform float dhFarPlane;
uniform float dhNearPlane;
uniform vec2 texelSize;
uniform float viewWidth;
@ -104,6 +112,9 @@ vec3 toScreenSpace(vec3 p) {
return viewPos.xyz / viewPos.w;
}
#include "/lib/color_transforms.glsl"
#include "/lib/waterBump.glsl"
#include "/lib/sky_gradient.glsl"
@ -127,6 +138,24 @@ float ld(float dist) {
#include "/lib/specular.glsl"
#include "/lib/DistantHorizons_projections.glsl"
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
float invertlinearDepthFast(const in float depth, const in float near, const in float far) {
return ((2.0*near/depth)-far-near)/(far-near);
}
vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec));
}
@ -206,9 +235,12 @@ vec4 blueNoise(vec2 coord){
}
vec3 toShadowSpaceProjected(vec3 feetPlayerPos){
mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection);
feetPlayerPos = mat3(gbufferModelViewInverse) * feetPlayerPos + gbufferModelViewInverse[3].xyz;
feetPlayerPos = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz;
feetPlayerPos = diagonal3(shadowProjection) * feetPlayerPos + shadowProjection[3].xyz;
feetPlayerPos = diagonal3(DH_shadowProjection) * feetPlayerPos + DH_shadowProjection[3].xyz;
return feetPlayerPos;
}
@ -372,7 +404,12 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
vec3 progressW = start.xyz+cameraPosition+dVWorld;
//project into biased shadowmap space
float distortFactor = calcDistort(spPos.xy);
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(spPos.xy);
#else
float distortFactor = 1.0;
#endif
vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
float sh = 1.0;
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
@ -408,18 +445,30 @@ void Emission(
if( Emission < 255.0/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve);
}
void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool inshadowmap, inout float Shadow, inout float SSS){
vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, bool isSSS){
float steps = 16.0;
vec3 clipPosition = toClipSpace3(viewPos);
float Shadow = 1.0;
float SSS = 0.0;
float _near = near; float _far = far*4.0;
if (depthCheck) {
_near = dhNearPlane;
_far = dhFarPlane;
}
vec3 clipPosition = toClipSpace3_DH(viewPos, depthCheck);
//prevents the ray from going behind the camera
float rayLength = ((viewPos.z + lightDir.z * far*sqrt(3.)) > -near) ?
(-near -viewPos.z) / lightDir.z : far*sqrt(3.);
float rayLength = ((viewPos.z + lightDir.z * _far*sqrt(3.)) > -_near) ?
(-_near -viewPos.z) / lightDir.z : _far*sqrt(3.);
vec3 direction = toClipSpace3(viewPos + lightDir*rayLength) - clipPosition; //convert to clip space
vec3 direction = toClipSpace3_DH(viewPos + lightDir*rayLength, depthCheck) - clipPosition; //convert to clip space
direction.xyz = direction.xyz / max(abs(direction.x)/texelSize.x, abs(direction.y)/texelSize.y); //fixed step size
vec3 rayDir = direction * (isSSS ? 1.5 : 3.0) * vec3(RENDER_SCALE,1.0);
vec3 rayDir = direction * (isSSS ? 1.5 : (depthCheck ? 6.0 : 3.0)) * vec3(RENDER_SCALE,1.0);
vec3 screenPos = clipPosition * vec3(RENDER_SCALE,1.0) + rayDir*noise;
if(isSSS) screenPos -= rayDir*0.9;
@ -428,9 +477,14 @@ void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool ins
screenPos += rayDir;
float samplePos = texture2D(depthtex2, screenPos.xy).x;
float samplePos = texture2D(depthtex1, screenPos.xy).x;
#ifdef DISTANT_HORIZONS
if(depthCheck) samplePos = texture2D(dhDepthTex1, screenPos.xy).x;
#endif
if(samplePos <= screenPos.z) {
vec2 linearZ = vec2(linZ(screenPos.z), linZ(samplePos));
vec2 linearZ = vec2(linearizeDepthFast(screenPos.z, _near, _far), linearizeDepthFast(samplePos, _near, _far));
float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x;
bool depthThreshold1 = calcthreshold < 0.015;
@ -442,6 +496,8 @@ void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool ins
}
}
return vec2(Shadow, SSS);
}
float CustomPhase(float LightPos){
@ -491,7 +547,6 @@ vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){
return scatter ;
}
#include "/lib/indirect_lighting_effects.glsl"
#include "/lib/PhotonGTAO.glsl"
vec4 renderInfiniteWaterPlane(
@ -525,28 +580,103 @@ vec4 renderInfiniteWaterPlane(
return vec4(color, total_extinction);
}
// 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;
}
vec3 DH_viewSpacePos(vec2 texcoord, float depth) {
vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
vec4 viewPos = dhProjectionInverse * ndcPos;
return viewPos.xyz /= viewPos.w;
}
void main() {
vec3 DEBUG = vec3( 1.0);
vec3 DEBUG = vec3(1.0);
////// --------------- SETUP STUFF --------------- //////
vec2 texcoord = gl_FragCoord.xy*texelSize;
float z0 = texture2D(depthtex0,texcoord).x;
float z = texture2D(depthtex1,texcoord).x;
vec2 bnoise = blueNoise(gl_FragCoord.xy).rg;
int seed = (frameCounter%40000) + frameCounter*2;
float noise = fract(R2_samples(seed).y + bnoise.y);
float noise_2 = R2_dither();
vec2 tempOffset = TAA_Offset;
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z));
float z0 = texture2D(depthtex0,texcoord).x;
float z = texture2D(depthtex1,texcoord).x;
float swappedDepth = z;
bool isDHrange = z >= 1.0;
#ifdef DISTANT_HORIZONS
float DH_depth0 = texture2D(dhDepthTex,texcoord).x;
float DH_depth1 = texture2D(dhDepthTex1,texcoord).x;
float mixedDepth = z;
float _near = near;
float _far = far*4.0;
if (mixedDepth >= 1.0) {
mixedDepth = DH_depth1;
_near = dhNearPlane;
_far = dhFarPlane;
}
mixedDepth = linearizeDepthFast(mixedDepth, _near, _far);
mixedDepth = mixedDepth / dhFarPlane;
swappedDepth = DH_inv_ld(mixedDepth);
if(swappedDepth >= 0.999999) swappedDepth = 1.0;
#else
float DH_depth0 = 0.0;
float DH_depth1 = 0.0;
#endif
#ifdef DISTANT_HORIZONS
vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z, DH_depth1);
#else
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z));
#endif
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
vec3 feetPlayerPos_normalized = normVec(feetPlayerPos);
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
vec4 data = texture2D(colortex1,texcoord);
@ -580,9 +710,15 @@ void main() {
#endif
#endif
float vanilla_AO = clamp(normalAndAO.a,0,1);
float vanilla_AO = z < 1.0 ? clamp(normalAndAO.a,0,1) : 0.0;
normalAndAO.a = clamp(pow(normalAndAO.a*5,4),0,1);
if(isDHrange){
slopednormal = normal;
FlatNormals = worldToView(normal);
}
////// --------------- MASKS/BOOLEANS --------------- //////
bool iswater = texture2D(colortex7,texcoord).a > 0.99;
@ -615,8 +751,6 @@ void main() {
vec3 Indirect_lighting = vec3(1.0);
vec3 AmbientLightColor = vec3(0.0);
vec3 Indirect_SSS = vec3(0.0);
vec3 ambientCoefs = slopednormal/dot(abs(slopednormal),vec3(1.));
vec3 Direct_lighting = vec3(0.0);
vec3 DirectLightColor = vec3(0.0);
@ -625,6 +759,16 @@ void main() {
float Shadows = 1.0;
float NdotL = 1.0;
float shadowMap = 1.0;
#ifdef DISTANT_HORIZONS_SHADOWMAP
float shadowMapFalloff = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / min(shadowDistance, dhFarPlane),0.0)*5.0,1.0),2.0),2.0);
#else
float shadowMapFalloff = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / min(shadowDistance, far),0.0)*5.0,1.0),2.0),2.0);
#endif
float LM_shadowMapFallback = min(max(lightmap.y-0.8, 0.0) * 25,1.0);
#ifdef OVERWORLD_SHADER
DirectLightColor = lightCol.rgb/80.0;
@ -637,12 +781,19 @@ void main() {
vec3 filteredShadow = vec3(1.412,1.0,0.0);
if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb;
float ShadowBlockerDepth = filteredShadow.y;
Shadows = clamp(1.0 - filteredShadow.b,0.0,1.0);
shadowMap = Shadows;
bool inShadowmapBounds = false;
#endif
#ifdef CLOUDS_INFRONT_OF_WORLD
float heightRelativeToClouds = clamp(cameraPosition.y - LAYER0_minHEIGHT,0.0,1.0);
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
#endif
///////////////////////////// start drawin :D
if (z >= 1.0) {
if (swappedDepth >= 1.0) {
#ifdef OVERWORLD_SHADER
vec3 Background = vec3(0.0);
@ -670,8 +821,12 @@ void main() {
Background += Sky;
#ifdef VOLUMETRIC_CLOUDS
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
Background = Background * Clouds.a + Clouds.rgb;
#ifdef CLOUDS_INFRONT_OF_WORLD
if(heightRelativeToClouds < 1.0) Background = Background * Clouds.a + Clouds.rgb;
#else
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
Background = Background * Clouds.a + Clouds.rgb;
#endif
#endif
gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise_2)), 0.0, 65000.);
@ -697,100 +852,77 @@ void main() {
#ifdef OVERWORLD_SHADER
NdotL = clamp((-15 + dot(slopednormal, WsunVec)*255.0) / 240.0 ,0.0,1.0);
// float shadowNDOTL = NdotL;
// #ifndef Variable_Penumbra_Shadows
// shadowNDOTL += LabSSS;
// #endif
float shadowNDOTL = NdotL;
#ifndef Variable_Penumbra_Shadows
shadowNDOTL += LabSSS;
#endif
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
if(!entities){
if(!hand) GriAndEminShadowFix(feetPlayerPos_shadow, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
}
// if(shadowNDOTL > 0.001){
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
// vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos_shadow + Custom_ViewMatrix[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
bool ShadowBounds = false;
if(shadowDistanceRenderMul > 0.0) ShadowBounds = length(feetPlayerPos_shadow) < max(shadowDistance - 20,0.0);
if(shadowDistanceRenderMul < 0.0) ShadowBounds = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0;
mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection);
//do shadows only if on shadow map
if(ShadowBounds){
if (shadowNDOTL >= -0.001){
Shadows = 0.0;
int samples = SHADOW_FILTER_SAMPLE_COUNT;
float smallbias = 0.0;
vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
if(hand){
samples = 1;
noise = 0.5;
smallbias = -0.0004;
}
if(!hand || !entities) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
if(entities) smallbias = -0.0001;
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(DH_shadowProjection) * projectedShadowPosition + DH_shadowProjection[3].xyz;
//apply distortion
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
#else
float distortFactor = 1.0;
#endif
if(shadowDistanceRenderMul < 0.0) shadowMapFalloff = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0 ? 1.0 : 0.0;
if(shadowMapFalloff > 0.0){
shadowMap = 0.0;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
float biasOffset = 0.0;
#ifdef BASIC_SHADOW_FILTER
#ifndef Variable_Penumbra_Shadows
if(LabSSS > 0) smallbias = -0.0002;
#endif
float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution;
for(int i = 0; i < samples; i++){
for(int i = 0; i < SHADOW_FILTER_SAMPLE_COUNT; i++){
vec2 offsetS = tapLocation_simple(i, 7, 9, noise_2) * 0.5;
float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, smallbias) ).x;
Shadows += isShadow/samples;
shadowMap += shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, biasOffset) ).x/SHADOW_FILTER_SAMPLE_COUNT;
}
#else
Shadows = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x;
shadowMap = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, biasOffset)).x;
#endif
Shadows = shadowMap;
}
inShadowmapBounds = true;
}
float lightmapAsShadows = 1.0;
if(!inShadowmapBounds && !iswater){
lightmapAsShadows = min(max(lightmap.y-0.8, 0.0) * 25,1.0);
Shadows = lightmapAsShadows;
}
#ifdef OLD_LIGHTLEAK_FIX
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
#endif
Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff);
#ifdef OLD_LIGHTLEAK_FIX
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
#endif
// }
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// SUN SSS ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#if SSS_TYPE != 0
#ifndef Variable_Penumbra_Shadows
if(LabSSS > 0 ) {
ShadowBlockerDepth = pow(1.0 - Shadows,2);
}
#if defined DISTANT_HORIZONS_SHADOWMAP && defined Variable_Penumbra_Shadows
float DH_SSS_DISTANCE = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / min(shadowDistance, far),0.0)*5.0,1.0),2.0),2.0);
ShadowBlockerDepth = mix(pow(1.0 - Shadows,2.0), ShadowBlockerDepth, DH_SSS_DISTANCE);
#endif
#if !defined Variable_Penumbra_Shadows
ShadowBlockerDepth = pow(1.0 - Shadows,2.0);
#endif
if (!inShadowmapBounds) ShadowBlockerDepth = 0.0;
float sunSSS_density = LabSSS;
#ifndef RENDER_ENTITY_SHADOWS
if(entities) sunSSS_density = 0.0;
#endif
@ -798,29 +930,22 @@ void main() {
if (!hand){
#ifdef SCREENSPACE_CONTACT_SHADOWS
float SS_shadow = 1.0; float SS_shadowSSS = 0.0;
SSRT_Shadows(toScreenSpace(vec3(texcoord/RENDER_SCALE, z)), normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), !inShadowmapBounds && LabSSS > 0.0, inShadowmapBounds, SS_shadow, SS_shadowSSS);
Shadows = min(Shadows, SS_shadow);
vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), sunSSS_density > 0.0);
if (!inShadowmapBounds) ShadowBlockerDepth = max(ShadowBlockerDepth, clamp(SS_shadowSSS,0.0,1.0));
Shadows = min(Shadows, SS_directLight.r);
ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff);
#else
if (!inShadowmapBounds) ShadowBlockerDepth = 1.0-min(max(lightmap.y-0.85,0.0)*10.0,1.0);
ShadowBlockerDepth = mix(1.0, ShadowBlockerDepth, shadowMapFalloff);
#endif
Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), inShadowmapBounds) ;
Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), inShadowmapBounds);
Direct_SSS *= mix(LM_shadowMapFallback, 1.0, shadowMapFalloff);
if (isEyeInWater == 0) Direct_SSS *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
}
if (isEyeInWater == 0) Direct_SSS *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
if (!inShadowmapBounds){
Direct_SSS *= lightmapAsShadows;
// Direct_SSS *= 1.0-NdotL;
}
#endif
#ifdef CLOUDS_SHADOWS
@ -853,6 +978,10 @@ void main() {
///////////////////////////// INDIRECT LIGHTING /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
#if indirect_effect == 1
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
#endif
#if defined OVERWORLD_SHADER && (indirect_effect == 0 || indirect_effect == 1)
vec3 ambientcoefs = slopednormal / dot(abs(slopednormal), vec3(1));
@ -860,10 +989,12 @@ void main() {
float SkylightDir = ambientcoefs.y*1.5;
if(isGrass) SkylightDir = 1.25;
float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.25 + (1.0-lightmap.y) * 0.75) ;
// skylight = 0.0;
#if indirect_effect == 1
skylight = min(skylight, (SSAO_SSS.x*SSAO_SSS.x*SSAO_SSS.x) * 2.5);
#endif
AmbientLightColor *= skylight;
#endif
@ -894,35 +1025,31 @@ void main() {
////////////////////////////////////////////////////////////////////////////////////////////
#ifdef OVERWORLD_SHADER
if ((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)){
#ifdef DISTANT_HORIZONS
vec3 viewPos0 = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z0, DH_depth0);
#else
vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
#endif
vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
float Vdiff = distance(viewPos, viewPos0);
float VdotU = feetPlayerPos_normalized.y;
float estimatedDepth = Vdiff * abs(VdotU); //assuming water plane
estimatedDepth = estimatedDepth;
// make it such that the estimated depth flips to be correct when entering water.
// make it such that the estimated depth flips to be correct when entering water.
if (isEyeInWater == 1) estimatedDepth = (1.0-lightmap.y)*16.0;
float estimatedSunDepth = Vdiff; //assuming water plane
vec3 Absorbtion = exp2(-totEpsilon*estimatedDepth);
// caustics...
float Direct_caustics = waterCaustics(feetPlayerPos + cameraPosition, WsunVec) * cloudShadow;
// float Ambient_Caustics = waterCaustics(p3 + cameraPosition, vec3(0.5, 1, 0.5));
// apply caustics to the lighting
DirectLightColor *= 1.0 + max(pow(Direct_caustics * 3.0, 2.0),0.0);
// Indirect_lighting *= 0.5 + max(pow(Ambient_Caustics, 2.0),0.0);
DirectLightColor *= Absorbtion;
if(isEyeInWater == 1 ) Indirect_lighting = (Indirect_lighting/exp2(-estimatedDepth*0.5)) * Absorbtion;
if(isEyeInWater == 0) DirectLightColor *= max(eyeBrightnessSmooth.y/240., 0.0);
DirectLightColor *= cloudShadow;
// apply caustics to the lighting
float Direct_caustics = waterCaustics(feetPlayerPos + cameraPosition, WsunVec);
DirectLightColor *= 1.0 + max(pow(Direct_caustics * 3.0, 2.0),0.0);
// if(isEyeInWater == 0) DirectLightColor *= max(eyeBrightnessSmooth.y/240., 0.0);
}
#endif
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// EFFECTS FOR INDIRECT /////////////////////////////
@ -933,17 +1060,16 @@ void main() {
#if indirect_effect == 0
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ;
Indirect_lighting *= AO;
Direct_lighting *= AO;
#endif
#if indirect_effect == 1
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
// AO *= exp((1.0-SSAO_SSS.x) * -5.0);
AO *= SSAO_SSS.x*SSAO_SSS.x*SSAO_SSS.x;
AO *= SSAO_SSS.x*SSAO_SSS.x;
SkySSS = SSAO_SSS.y;
Indirect_lighting *= AO;
Direct_lighting *= AO;
#endif
// GTAO
@ -954,6 +1080,7 @@ void main() {
if (!hand) AO = ambient_occlusion(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z), viewPos, worldToView(slopednormal), r2) * vec3(1.0);
Indirect_lighting *= AO;
Direct_lighting *= AO;
#endif
// RTAO and/or SSGI
@ -1007,7 +1134,8 @@ void main() {
#ifdef OVERWORLD_SHADER
// do these here so it gets underwater absorbtion.
Direct_lighting = max(DirectLightColor * (NdotL * Shadows), DirectLightColor * Direct_SSS);
// Direct_lighting = max(DirectLightColor * NdotL * Shadows, DirectLightColor * LabSSS*0);
Direct_lighting = max(DirectLightColor * NdotL * Shadows, DirectLightColor * Direct_SSS);
#endif
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo;
@ -1024,27 +1152,36 @@ void main() {
}
#ifdef OVERWORLD_SHADER
if (iswater && isEyeInWater == 0){
vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
float Vdiff = distance(viewPos,viewPos0);
#ifdef DISTANT_HORIZONS
vec3 viewPos0 = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z0, DH_depth0);
#else
vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
#endif
float Vdiff = distance(viewPos, viewPos0);
float VdotU = feetPlayerPos_normalized.y;
float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane
float estimatedSunDepth = estimatedDepth/abs(WsunVec.y); //assuming water plane
float custom_lightmap_T = clamp(pow(texture2D(colortex14, texcoord).a,3.0),0.0,1.0);
#ifdef DISTANT_HORIZONS
if(isDHrange) custom_lightmap_T = 0.85;
#endif
vec3 lightColVol = lightCol.rgb / 80.;
// if(shadowmapindicator < 1) lightColVol *= clamp((custom_lightmap_T-0.8) * 15,0,1)
vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.);
vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) ;
vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) ;
waterVolumetrics(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedSunDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(feetPlayerPos_normalized, WsunVec));
waterVolumetrics(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth, estimatedSunDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(feetPlayerPos_normalized, WsunVec));
}
#else
if (iswater && isEyeInWater == 0){
@ -1058,6 +1195,43 @@ void main() {
waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol);
}
#endif
//////// DEBUG VIEW STUFF
#if DEBUG_VIEW == debug_SHADOWMAP
gl_FragData[0].rgb = (shadowMapFalloff > 0.0 ? vec3(1.0,1.0,1.0) : vec3(1.0,0.25,0.25)) * shadowMap ;
#endif
#if DEBUG_VIEW == debug_NORMALS
gl_FragData[0].rgb = normal;
#endif
#if DEBUG_VIEW == debug_SPECULAR
gl_FragData[0].rgb = SpecularTex.rgb;
#endif
#if DEBUG_VIEW == debug_INDIRECT
gl_FragData[0].rgb = Indirect_lighting;
#endif
#if DEBUG_VIEW == debug_DIRECT
gl_FragData[0].rgb = Direct_lighting;
#endif
#if DEBUG_VIEW == debug_VIEW_POSITION
gl_FragData[0].rgb = viewPos;
#endif
#ifdef CLOUDS_INFRONT_OF_WORLD
gl_FragData[1] = texture2D(colortex2, texcoord);
if(heightRelativeToClouds > 0.0){
gl_FragData[0].rgb = gl_FragData[0].rgb * Clouds.a + Clouds.rgb;
gl_FragData[1].a = gl_FragData[1].a*Clouds.a*Clouds.a*Clouds.a;
}
/* DRAWBUFFERS:32 */
#else
/* DRAWBUFFERS:3 */
#endif
}

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

View File

@ -6,6 +6,7 @@ flat varying vec3 averageSkyCol;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
uniform sampler2D dhDepthTex;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
@ -15,7 +16,10 @@ uniform sampler2D colortex6;
flat varying vec3 WsunVec;
uniform vec3 sunVec;
uniform float sunElevation;
// uniform float far;
uniform float dhFarPlane;
uniform float dhNearPlane;
uniform int frameCounter;
uniform float frameTimeCounter;
@ -27,8 +31,12 @@ uniform vec2 texelSize;
uniform int isEyeInWater;
uniform float rainStrength;
uniform ivec2 eyeBrightnessSmooth;
uniform float eyeAltitude;
#define DHVLFOG
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
#include "/lib/color_transforms.glsl"
#include "/lib/color_dither.glsl"
#include "/lib/projections.glsl"
@ -36,8 +44,21 @@ uniform float eyeAltitude;
#include "/lib/sky_gradient.glsl"
#include "/lib/Shadow_Params.glsl"
#include "/lib/DistantHorizons_projections.glsl"
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
#ifdef OVERWORLD_SHADER
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
@ -186,7 +207,11 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
vec3 spPos = start.xyz + dV*d;
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
//project into biased shadowmap space
float distortFactor = calcDistort(spPos.xy);
#ifdef DISTORT_SHADOWMAP
float distortFactor = calcDistort(spPos.xy);
#else
float distortFactor = 1.0;
#endif
vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
float sh = 1.0;
@ -222,11 +247,7 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
inColor += vL;
}
#endif
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
vec4 blueNoise(vec2 coord){
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
}
@ -234,18 +255,31 @@ vec2 R2_samples(int n){
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha * n);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:0 */
// vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize;
vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize;
float z = texture2D(depthtex0,tc).x;
vec3 viewPos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
float noise_1 = R2_dither();
float noise_2 = blueNoise();
vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize;
float z = texture2D(depthtex0,tc).x;
#ifdef DISTANT_HORIZONS
float DH_z = texture2D(dhDepthTex,tc).x;
#else
float DH_z = 0.0;
#endif
vec3 viewPos = toScreenSpace_DH(tc/RENDER_SCALE, z, DH_z);
// vec3 viewPos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
if (isEyeInWater == 0){
@ -257,8 +291,6 @@ void main() {
vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, noise_2);
#endif
// VolumetricFog = vec4(0,0,0,1);
gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0);
}
@ -282,6 +314,7 @@ void main() {
vec3 vl = vec3(0.0);
waterVolumetrics(vl, vec3(0.0), viewPos, estEyeDepth, estEyeDepth, length(viewPos), noise_1, totEpsilon, scatterCoef, ambientColVol, lightColVol*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)) , dot(normalize(viewPos), normalize(sunVec* lightCol.a ) ));
gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.);
#else
vec3 fragpos0 = toScreenSpace(vec3(tc,z));
@ -289,5 +322,6 @@ void main() {
gl_FragData[0].a = 1;
waterVolumetrics_notoverworld(gl_FragData[0].rgb, fragpos0, viewPos, 1.0, 1.0, 1.0, blueNoise(), totEpsilon, scatterCoef, ambientColVol);
#endif
}
}

View File

@ -1,14 +1,16 @@
#include "/lib/settings.glsl"
flat varying vec3 zMults;
flat varying vec2 TAA_Offset;
flat varying vec2 TAA_Offset;
flat varying vec3 skyGroundColor;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
uniform sampler2D dhDepthTex;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
@ -37,6 +39,9 @@ uniform float frameTimeCounter;
uniform int frameCounter;
uniform float far;
uniform float near;
uniform float dhNearPlane;
uniform float dhFarPlane;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferModelView;
uniform mat4 gbufferPreviousModelView;
@ -87,8 +92,18 @@ vec3 toScreenSpace(vec3 p) {
return fragposition.xyz / fragposition.w;
}
#include "/lib/DistantHorizons_projections.glsl"
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
// #include "/lib/specular.glsl"
@ -192,6 +207,7 @@ void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, vec2 depths, bool
if(DistortedAlpha <= 0.001) Texcoord = UnalteredTexcoord; // remove distortion on non-translucents
}
uniform float dhRenderDistance;
uniform float eyeAltitude;
void main() {
@ -204,10 +220,33 @@ void main() {
float z2 = texture2D(depthtex1,texcoord).x;
float frDepth = ld(z2);
vec2 tempOffset = TAA_Offset;
vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2));
float swappedDepth = z;
#ifdef DISTANT_HORIZONS
float DH_depth0 = texture2D(dhDepthTex,texcoord).x;
#else
float DH_depth0 = 0.0;
#endif
#ifdef DISTANT_HORIZONS
float mixedDepth = z;
float _near = near;
float _far = far*4.0;
if (mixedDepth >= 1.0) {
mixedDepth = DH_depth0;
_near = dhNearPlane;
_far = dhFarPlane;
}
mixedDepth = linearizeDepthFast(mixedDepth, _near, _far);
mixedDepth = mixedDepth / dhFarPlane;
swappedDepth = DH_inv_ld(mixedDepth);
if(swappedDepth >= 0.999999) swappedDepth = 1.0;
#endif
vec3 fragpos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z, DH_depth0);
// vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5,z));
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
vec3 np3 = normVec(p3);
@ -223,7 +262,9 @@ void main() {
vec4 albedo = vec4(unpack0.ba,unpack1.rg);
vec2 tangentNormals = unpack0.xy*2.0-1.0;
if(albedo.a < 0.01) tangentNormals = vec2(0.0);
vec4 TranslucentShader = texture2D(colortex2, texcoord);
////// --------------- UNPACK MISC --------------- //////
@ -252,9 +293,15 @@ void main() {
//////////// and do border fog on opaque and translucents
#if defined BorderFog
float fog = exp(-50.0 * pow(clamp(1.0-linearDistance/far,0.0,1.0),2.0));
fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0));
if(z >= 1.0 || isEyeInWater != 0) fog = 0.0;
#ifdef DISTANT_HORIZONS
float fog = exp(-25.0 * pow(clamp(1.0-linearDistance/max(dhFarPlane-1000,0.0),0.0,1.0),2.0));
#else
float fog = exp(-50.0 * pow(clamp(1.0-linearDistance/far,0.0,1.0),2.0));
#endif
fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0));
if(swappedDepth >= 1.0 || isEyeInWater != 0) fog = 0.0;
if(lightleakfixfast < 1.0) fog *= lightleakfix;
@ -354,7 +401,7 @@ void main() {
color.rgb *= mix(1.0,clamp( exp(pow(linearDistance*(blindness*0.2),2) * -5),0.,1.) , blindness);
//////// --------------- darkness effect
color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor);
color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor);
////// --------------- FINALIZE
#ifdef display_LUT

View File

@ -14,6 +14,8 @@ const int colortex9Format = RGBA8; // rain in alpha
const int colortex10Format = RGBA16; // resourcepack Skies
const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals
const int colortex12Format = RGBA16F; // DISTANT HORIZONS + VANILLA MIXED DEPTHs
const int colortex14Format = RGBA8; // a = skylightmap for translucents.
const int colortex15Format = RGBA8; // flat normals and vanilla AO
*/
@ -36,6 +38,7 @@ const bool colortex13Clear = false;
const bool colortex14Clear = true;
const bool colortex15Clear = false;
#ifdef SCREENSHOT_MODE
/*
const int colortex5Format = RGBA32F; //TAA buffer (everything)
@ -54,6 +57,7 @@ uniform sampler2D colortex3;
uniform sampler2D colortex5;
uniform sampler2D colortex6;
uniform sampler2D colortex10;
uniform sampler2D colortex12;
uniform sampler2D depthtex0;
uniform vec2 texelSize;
@ -189,6 +193,30 @@ vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
return dmin;
}
uniform sampler2D dhDepthTex;
uniform float dhFarPlane;
uniform float dhNearPlane;
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
uniform mat4 dhProjectionInverse;
uniform mat4 dhProjection;
vec3 DH_toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
@ -208,7 +236,11 @@ vec4 TAA_hq(){
//use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion
#ifdef CLOSEST_VELOCITY
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
#ifdef DISTANT_HORIZONS
vec3 closestToCamera = closestToCamera5taps(adjTC, texture2D(depthtex0,adjTC).x < 1.0 ? depthtex0 : dhDepthTex);
#else
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
#endif
#endif
#ifndef CLOSEST_VELOCITY
@ -216,7 +248,12 @@ vec4 TAA_hq(){
#endif
//reproject previous frame
vec3 viewPos = toScreenSpace(closestToCamera);
#ifdef DISTANT_HORIZONS
vec3 viewPos = DH_toScreenSpace(closestToCamera);
#else
vec3 viewPos = toScreenSpace(closestToCamera);
#endif
viewPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * viewPos + gbufferPreviousModelView[3].xyz;

View File

@ -68,8 +68,53 @@ float blueNoise(){
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
}
#define DHVLFOG
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
uniform float dhFarPlane;
uniform float dhNearPlane;
#include "/lib/DistantHorizons_projections.glsl"
vec3 DH_toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
// float DH_ld(float dist) {
// return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
// }
// float DH_invLinZ (float lindepth){
// return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
// }
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
#ifdef OVERWORLD_SHADER
// uniform sampler2D colortex12;
// const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
@ -88,7 +133,18 @@ float blueNoise(){
uniform sampler2D colortex4;
#include "/lib/end_fog.glsl"
#endif
vec3 rodSample(vec2 Xi)
{
float r = sqrt(1.0f - Xi.x*Xi.y);
float phi = 2 * 3.14159265359 * Xi.y;
return normalize(vec3(cos(phi) * r, sin(phi) * r, Xi.x)).xzy;
}
//Low discrepancy 2D sequence, integration error is as low as sobol but easier to compute : http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
vec2 R2_samples(float n){
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha * n);
}
void main() {
/* DRAWBUFFERS:4 */
@ -195,9 +251,14 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*1.75, skyGroundCol/30.0);
sky = sky*clouds.a + clouds.rgb / 5.0;
vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), lightSourceColor*1.75, skyGroundCol/30.0);
// vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), lightSourceColor*1.75, skyGroundCol/30.0);
vec4 VL_Fog = DH_GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), lightSourceColor*1.75, skyGroundCol/30.0);
sky = sky * VL_Fog.a + VL_Fog.rgb / 5.0;
// if(p.y < 0.05) sky = averageSkyCol_Clouds;
gl_FragData[0] = vec4(sky,1.0);
}
#endif

View File

@ -51,7 +51,13 @@ vec3 sunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
float luma(vec3 color) {
return dot(color,vec3(0.21, 0.72, 0.07));
}
vec3 rodSample(vec2 Xi)
{
float r = sqrt(1.0f - Xi.x*Xi.y);
float phi = 2 * 3.14159265359 * Xi.y;
return normalize(vec3(cos(phi) * r, sin(phi) * r, Xi.x)).xzy;
}
//Low discrepancy 2D sequence, integration error is as low as sobol but easier to compute : http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
vec2 R2_samples(int n){
vec2 alpha = vec2(0.75487765, 0.56984026);
@ -98,20 +104,20 @@ void main() {
);
// sample in a 3x3 pattern to get a good area for average color
vec3 pos = normalize(vec3(0,1,0));
int maxIT = 9;
// int maxIT = 20;
for (int i = 0; i < maxIT; i++) {
pos = normalize(vec3(0,1,0));
pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.90);
vec3 pos = vec3(0.0,1.0,0.0);
pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.9000);
averageSkyCol_Clouds += 1.5*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.;
averageSkyCol += 1.5*skyFromTex(pos,colortex4).rgb/maxIT/150.;
averageSkyCol_Clouds += 1.5 * (skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.0);
averageSkyCol += 1.5 * (skyFromTex(pos,colortex4).rgb/maxIT/150.0);
}
// only need to sample one spot for this
vec3 minimumlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.003 + nightVision);
averageSkyCol_Clouds = max(averageSkyCol_Clouds, minimumlight);
averageSkyCol_Clouds = max(averageSkyCol_Clouds * (1.0/(luma(averageSkyCol_Clouds)*0.25+0.75)), minimumlight);
averageSkyCol = max(averageSkyCol*PLANET_GROUND_BRIGHTNESS, minimumlight);
////////////////////////////////////////

View File

@ -1,8 +1,14 @@
#include "/lib/settings.glsl"
uniform sampler2D colortex4;
uniform sampler2D colortex12;
uniform vec2 texelSize;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
uniform sampler2D dhDepthTex;
uniform sampler2D dhDepthTex1;
uniform float near;
uniform float far;
@ -11,6 +17,18 @@ float linZ(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
uniform float dhFarPlane;
uniform float dhNearPlane;
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_invLinZ (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -18,12 +36,44 @@ float linZ(float depth) {
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:4 */
/* RENDERTARGETS:4,12 */
vec3 oldTex = texelFetch2D(colortex4, ivec2(gl_FragCoord.xy), 0).xyz;
float newTex = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy*4), 0).x;
if (newTex < 1.0)
#ifdef DISTANT_HORIZONS
float QuarterResDepth = texelFetch2D(dhDepthTex, ivec2(gl_FragCoord.xy*4), 0).x;
if(newTex >= 1.0) newTex = QuarterResDepth;
#endif
if (newTex < 1.0)
gl_FragData[0] = vec4(oldTex, linZ(newTex)*linZ(newTex)*65000.0);
else
else
gl_FragData[0] = vec4(oldTex, 2.0);
}
float depth = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy*4), 0).x;
#ifdef DISTANT_HORIZONS
float _near = near;
float _far = far*4.0;
if (depth >= 1.0) {
depth = texelFetch2D(dhDepthTex1, ivec2(gl_FragCoord.xy*4), 0).x;
_near = dhNearPlane;
_far = dhFarPlane;
}
depth = linearizeDepthFast(depth, _near, _far);
depth = depth / dhFarPlane;
#endif
if(depth < 1.0)
gl_FragData[1] = vec4(vec3(0.0), depth * depth * 65000.0);
else
gl_FragData[1] = vec4(vec3(0.0), 65000.0);
#ifdef DISTANT_HORIZONS
gl_FragData[1].a = DH_ld(QuarterResDepth)*DH_ld(QuarterResDepth)*65000.0;
#endif
}

View File

@ -14,9 +14,12 @@ flat varying float tempOffsets;
// uniform float far;
uniform float near;
uniform sampler2D depthtex0;
uniform sampler2D dhDepthTex;
// uniform sampler2D colortex4;
uniform sampler2D noisetex;
uniform sampler2D colortex12;
flat varying vec3 WsunVec;
uniform vec3 sunVec;
uniform vec2 texelSize;
@ -71,12 +74,39 @@ vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec));
}
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
uniform mat4 dhPreviousProjection;
uniform mat4 dhProjectionInverse;
uniform mat4 dhProjection;
vec3 DH_toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
uniform float dhFarPlane;
uniform float dhNearPlane;
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
#include "/lib/lightning_stuff.glsl"
#include "/lib/sky_gradient.glsl"
#include "/lib/volumetricClouds.glsl"
#include "/lib/res_params.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -91,7 +121,7 @@ void main() {
#ifdef VOLUMETRIC_CLOUDS
vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5);
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize,1));
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize,1.0));
vec4 VolumetricClouds = renderClouds(viewPos, vec2(R2_dither(),blueNoise2()), sunColor/80.0, averageSkyCol/30.0);

View File

@ -6,9 +6,10 @@ uniform sampler2D colortex7;
uniform vec2 texelSize;
uniform float frameTimeCounter;
// uniform sampler2D shadowcolor0;
// uniform sampler2D shadowtex0;
// uniform sampler2D shadowtex1;
uniform sampler2D shadowcolor0;
uniform sampler2D shadowcolor1;
uniform sampler2D shadowtex0;
uniform sampler2D shadowtex1;
#include "/lib/color_transforms.glsl"
#include "/lib/color_dither.glsl"
@ -162,4 +163,9 @@ void main() {
applyContrast(FINAL_COLOR, CONTRAST); // for fun
gl_FragColor.rgb = FINAL_COLOR;
// vec2 texrood = texcoord * vec2(2.0, 1.0) - vec2(1.0, 0.0);
// if(texcoord.x > 0.5) gl_FragColor.rgb = texture2D(shadowcolor0, texrood).rgb;
}