mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-22 17:47:34 +08:00
surprise commit
new stuff reworked clouds, general lighting, end and nether shaders still WIP lighting is more balanced in general.
This commit is contained in:
parent
7fc3d17c05
commit
2ee6634935
@ -7,7 +7,7 @@
|
||||
block.10001 = minecraft:beetroots minecraft:potatoes minecraft:carrots minecraft:wheat minecraft:nether_wart minecraft:kelp minecraft:large_fern:half=upper minecraft:peony:half=upper minecraft:rose_bush:half=upper minecraft:lilac:half=upper minecraft:crimson_roots minecraft:nether_sprouts minecraft:warped_roots minecraft:seagrass minecraft:tall_seagrass:half=upper minecraft:sunflower:half=upper minecraft:tall_grass:half=upper minecraft:wither_rose minecraft:lily_of_the_valley minecraft:cornflower minecraft:sweet_berry_bush minecraft:oxeye_daisy minecraft:pink_tulip minecraft:white_tulip minecraft:orange_tulip minecraft:red_tulip minecraft:azure_bluet minecraft:allium minecraft:blue_orchid minecraft:poppy minecraft:dandelion minecraft:grass minecraft:dead_bush minecraft:oak_sapling minecraft:spruce_sapling minecraft:birch_sapling minecraft:jungle_sapling minecraft:acacia_sapling minecraft:dark_oak_sapling minecraft:fern
|
||||
|
||||
##air waving
|
||||
block.10003 = minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves
|
||||
block.10003 = minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves
|
||||
|
||||
####### ----- SSS ----- #######
|
||||
|
||||
|
@ -195,7 +195,6 @@ void main() {
|
||||
float LabSSS = 0.0;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef Variable_Penumbra_Shadows
|
||||
if (translucent && !hand) minshadowfilt += 25;
|
||||
#endif
|
||||
@ -217,7 +216,7 @@ void main() {
|
||||
|
||||
#ifdef Variable_Penumbra_Shadows
|
||||
|
||||
if (NdotL > 0.000 || LabSSS > 0.0 || translucent || translucent2 || translucent3 || translucent4) {
|
||||
if (NdotL > 0.0 || LabSSS >= 0.0) {
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
|
||||
|
1267
shaders/composite1.fsh
Normal file
1267
shaders/composite1.fsh
Normal file
File diff suppressed because it is too large
Load Diff
70
shaders/composite1.vsh
Normal file
70
shaders/composite1.vsh
Normal file
@ -0,0 +1,70 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 avgAmbient;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying float tempOffsets;
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying vec3 zMults;
|
||||
|
||||
attribute vec4 mc_Entity;
|
||||
uniform sampler2D colortex4;
|
||||
varying vec4 lmtexcoord;
|
||||
// varying float vanilla_ao;
|
||||
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
uniform int frameCounter;
|
||||
|
||||
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.);
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
// vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
// ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
// ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
// ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
// ambientRight = texelFetch2D(colortex4,ivec2(3,37),0).rgb;
|
||||
// ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb;
|
||||
// ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb;
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
|
||||
|
||||
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
zMults = vec3((far * near)*2.0,far+near,far-near);
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,12 +1,80 @@
|
||||
#version 120
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
//downsample 1st pass (half res) for bloom
|
||||
//Merge and upsample the blurs into a 1/4 res bloom buffer
|
||||
#include "lib/res_params.glsl"
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex6;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
||||
float w0(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w1(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*(3.0*a - 6.0) + 4.0);
|
||||
}
|
||||
|
||||
float w2(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-3.0*a + 3.0) + 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w3(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*a);
|
||||
}
|
||||
|
||||
float g0(float a)
|
||||
{
|
||||
return w0(a) + w1(a);
|
||||
}
|
||||
|
||||
float g1(float a)
|
||||
{
|
||||
return w2(a) + w3(a);
|
||||
}
|
||||
|
||||
float h0(float a)
|
||||
{
|
||||
return -1.0 + w1(a) / (w0(a) + w1(a));
|
||||
}
|
||||
|
||||
float h1(float a)
|
||||
{
|
||||
return 1.0 + w3(a) / (w2(a) + w3(a));
|
||||
}
|
||||
|
||||
vec4 texture2D_bicubic(sampler2D tex, vec2 uv)
|
||||
{
|
||||
vec4 texelSize = vec4(texelSize,1.0/texelSize);
|
||||
uv = uv*texelSize.zw;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
|
||||
float g0x = g0(fuv.x);
|
||||
float g1x = g1(fuv.x);
|
||||
float h0x = h0(fuv.x);
|
||||
float h1x = h1(fuv.x);
|
||||
float h0y = h0(fuv.y);
|
||||
float h1y = h1(fuv.y);
|
||||
|
||||
vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
|
||||
return g0(fuv.y) * (g0x * texture2D(tex, p0) +
|
||||
g1x * texture2D(tex, p1)) +
|
||||
g1(fuv.y) * (g0x * texture2D(tex, p2) +
|
||||
g1x * texture2D(tex, p3));
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -14,31 +82,24 @@ uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:3 */
|
||||
vec2 resScale = vec2(1920.,1080.)/(max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/BLOOM_QUALITY);
|
||||
vec2 texcoord = ((gl_FragCoord.xy)*2.+0.5)*texelSize;
|
||||
vec3 bloom = texture2D_bicubic(colortex3,texcoord/2.0).rgb; //1/4 res
|
||||
|
||||
/* DRAWBUFFERS:6 */
|
||||
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
|
||||
vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.;
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/4.).rgb; //1/8 res
|
||||
|
||||
//0.5
|
||||
gl_FragData[0] = texture2D(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res
|
||||
|
||||
//0.25
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125;
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb*1.0; //1/64 res
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb*1.0; //1/128 res
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb*1.0; //1/256 res
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC)*0.125;
|
||||
//bloom = texture2D_bicubic(colortex6,texcoord).rgb*6.; //1/8 res
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
gl_FragData[0].rgb = bloom*2.;
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ void main() {
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
gl_Position = ftransform();
|
||||
//*0.51 to avoid errors when sampling outside since clearing is disabled
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2-1.0;
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
|
||||
}
|
||||
|
@ -1,62 +1,149 @@
|
||||
#version 120
|
||||
#include "lib/settings.glsl"
|
||||
//6 Horizontal gaussian blurs and horizontal downsampling
|
||||
#include "lib/res_params.glsl"
|
||||
//Vignetting, applies bloom, applies exposure and tonemaps the final image
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform sampler2D colortex6;
|
||||
uniform vec2 texelSize;
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
|
||||
flat varying vec4 exposure;
|
||||
flat varying vec2 rodExposureDepth;
|
||||
varying vec2 texcoord;
|
||||
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
// uniform sampler2D colortex10;
|
||||
// uniform sampler2D colortex8; // specular
|
||||
// uniform sampler2D colortex9; // specular
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D noisetex;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY;
|
||||
vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
|
||||
vec4 tot = vec4(0.);
|
||||
float maxTC = 0.25*resScale.x;
|
||||
float minTC = 0.;
|
||||
for (int i = -maxIT;i<maxIT+1;i++){
|
||||
float weight = exp2(-i*i*alpha*4.0);
|
||||
//here we take advantage of bilinear filtering for 2x less sample, as a side effect the gaussian won't be totally centered for small blurs
|
||||
vec2 spCoord = coord+dir*texelSize*(2.0*i+0.5);
|
||||
tot += vec4(texture2D(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.x > minTC && spCoord.x < maxTC);
|
||||
}
|
||||
return tot.rgb/max(1.0,tot.a);
|
||||
uniform float frameTimeCounter;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform float near;
|
||||
uniform float aspectRatio;
|
||||
uniform float far;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform vec4 Moon_Weather_properties; // R = cloud coverage G = fog density
|
||||
|
||||
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.);
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
vec4 Weather_properties = Moon_Weather_properties;
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
#include "/lib/bokeh.glsl"
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float ld(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
// blindness fogs
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:6 */
|
||||
/* DRAWBUFFERS:7 */
|
||||
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
|
||||
vec3 col = texture2D(colortex5,texcoord).rgb;
|
||||
|
||||
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
|
||||
vec2 gaussDir = vec2(1.0,0.0);
|
||||
gl_FragData[0].rgb = vec3(0.0);
|
||||
vec2 tc2 = texcoord*vec2(2.0,1.)/2.;
|
||||
if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0);
|
||||
#if DOF_QUALITY >= 0
|
||||
/*--------------------------------*/
|
||||
float z = ld(texture2D(depthtex0, texcoord.st*RENDER_SCALE).r)*far;
|
||||
#ifdef AUTOFOCUS
|
||||
float focus = rodExposureDepth.y*far;
|
||||
#else
|
||||
float focus = MANUAL_FOCUS*screenBrightness;
|
||||
#endif
|
||||
float pcoc = min(abs(aperture * (focal/100.0 * (z - focus)) / (z * (focus - focal/100.0))),texelSize.x*15.0);
|
||||
#ifdef FAR_BLUR_ONLY
|
||||
pcoc *= float(z > focus);
|
||||
#endif
|
||||
float noise = blueNoise()*6.28318530718;
|
||||
mat2 noiseM = mat2( cos( noise ), -sin( noise ),
|
||||
sin( noise ), cos( noise )
|
||||
);
|
||||
vec3 bcolor = vec3(0.);
|
||||
float nb = 0.0;
|
||||
vec2 bcoord = vec2(0.0);
|
||||
/*--------------------------------*/
|
||||
float dofLodLevel = pcoc * 200.0;
|
||||
for ( int i = 0; i < BOKEH_SAMPLES; i++) {
|
||||
bcolor += texture2DLod(colortex5, texcoord.xy + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).rgb;
|
||||
}
|
||||
col = bcolor/BOKEH_SAMPLES;
|
||||
#endif
|
||||
|
||||
vec2 tc4 = texcoord*vec2(4.0,1.)/2.-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*2.0;
|
||||
if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3);
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
|
||||
vec2 tc8 = texcoord*vec2(8.0,1.)/2.-vec2(0.75*resScale.x+8.*texelSize.x,0.)*4.0;
|
||||
if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6);
|
||||
|
||||
vec2 tc16 = texcoord*vec2(8.0,1./2.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*8.0;
|
||||
if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12);
|
||||
|
||||
vec2 tc32 = texcoord*vec2(16.0,1./2.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*16.0;
|
||||
if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28);
|
||||
vec3 bloom = texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5*BLOOM_QUALITY).rgb/2./7.0;
|
||||
|
||||
vec2 tc64 = texcoord*vec2(32.0,1./2.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*32.0;
|
||||
if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60);
|
||||
float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette;
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
float VL_abs = texture2D(colortex7,texcoord*RENDER_SCALE).r;
|
||||
float purkinje = rodExposureDepth.x/(1.0+rodExposureDepth.x)*Purkinje_strength;
|
||||
|
||||
VL_abs = clamp( (1.0-VL_abs)*BLOOMY_FOG*0.75*(1.0-purkinje),0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0);
|
||||
|
||||
float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0);
|
||||
|
||||
col = (mix(col,bloom,VL_abs)+bloom*lightScat)* mix(exposure.rgb,min(exposure.rgb,0.01), 0);
|
||||
|
||||
//Purkinje Effect
|
||||
float lum = dot(col,vec3(0.15,0.3,0.55));
|
||||
float lum2 = dot(col,vec3(0.85,0.7,0.45))/2;
|
||||
float rodLum = lum2*400.;
|
||||
float rodCurve = mix(1.0, rodLum/(2.5+rodLum), purkinje);
|
||||
col = mix(clamp(lum,0.0,0.05)*Purkinje_Multiplier*vec3(Purkinje_R, Purkinje_G, Purkinje_B)+1.5e-3, col, rodCurve);
|
||||
|
||||
// #ifdef display_LUT
|
||||
// vec2 movedTC = texcoord ;
|
||||
// if(movedTC.x < 0.4 ) col.rgb = texture2D(colortex4,movedTC/2).rgb * 0.001;
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef USE_ACES_COLORSPACE_APPROXIMATION
|
||||
col = LinearTosRGB(TONEMAP(col));
|
||||
#else
|
||||
col = col * ACESInputMat;
|
||||
col = TONEMAP(col);
|
||||
|
||||
col = LinearTosRGB(clamp(col * ACESOutputMat, 0.0, 1.0));
|
||||
#endif
|
||||
|
||||
|
||||
gl_FragData[0].rgb = clamp(int8Dither(col,texcoord),0.0,1.0);
|
||||
}
|
@ -1,9 +1,24 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec4 exposure;
|
||||
flat varying vec2 rodExposureDepth;
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
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//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -11,11 +26,13 @@ varying vec2 texcoord;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY;
|
||||
|
||||
|
||||
gl_Position = ftransform();
|
||||
//0-0.25
|
||||
gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0;
|
||||
//0-0.5
|
||||
gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0;
|
||||
texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.);
|
||||
|
||||
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r);
|
||||
rodExposureDepth = texelFetch2D(colortex4,ivec2(14,37),0).rg;
|
||||
rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0);
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
#version 120
|
||||
#include "lib/settings.glsl"
|
||||
//6 Vertical gaussian blurs and vertical downsampling
|
||||
#include "lib/res_params.glsl"
|
||||
|
||||
|
||||
uniform sampler2D colortex6;
|
||||
uniform vec2 texelSize;
|
||||
varying vec2 texcoord;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY;
|
||||
vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
|
||||
vec4 tot = vec4(0.);
|
||||
float maxTC = 0.25*resScale.y;
|
||||
float minTC = 0.;
|
||||
for (int i = -maxIT;i<maxIT+1;i++){
|
||||
float weight = exp2(-i*i*alpha*4.0);
|
||||
vec2 spCoord = coord+dir*texelSize*(2.0*i+0.5);
|
||||
tot += vec4(texture2D(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.y > minTC && spCoord.y < maxTC);
|
||||
}
|
||||
return tot.rgb/max(1.0,tot.a);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:6 */
|
||||
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
|
||||
|
||||
vec2 gaussDir = vec2(0.0,1.0);
|
||||
gl_FragData[0].rgb = vec3(0.0);
|
||||
vec2 tc2 = texcoord*vec2(2.0,1.);
|
||||
if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,4.0),gaussDir,0.16,0);
|
||||
|
||||
vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0;
|
||||
if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,2.0),gaussDir,0.16,3);
|
||||
|
||||
vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0;
|
||||
if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6);
|
||||
|
||||
vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.0;
|
||||
if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12);
|
||||
|
||||
vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0;
|
||||
if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30);
|
||||
|
||||
vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.0;
|
||||
if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60);
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#version 120
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
varying vec2 texcoord;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY;
|
||||
gl_Position = ftransform();
|
||||
//0-0.25
|
||||
gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0;
|
||||
//0-0.5
|
||||
gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0;
|
||||
texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.);
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
#version 120
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
//Merge and upsample the blurs into a 1/4 res bloom buffer
|
||||
#include "lib/res_params.glsl"
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex6;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
||||
float w0(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w1(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*(3.0*a - 6.0) + 4.0);
|
||||
}
|
||||
|
||||
float w2(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-3.0*a + 3.0) + 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w3(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*a);
|
||||
}
|
||||
|
||||
float g0(float a)
|
||||
{
|
||||
return w0(a) + w1(a);
|
||||
}
|
||||
|
||||
float g1(float a)
|
||||
{
|
||||
return w2(a) + w3(a);
|
||||
}
|
||||
|
||||
float h0(float a)
|
||||
{
|
||||
return -1.0 + w1(a) / (w0(a) + w1(a));
|
||||
}
|
||||
|
||||
float h1(float a)
|
||||
{
|
||||
return 1.0 + w3(a) / (w2(a) + w3(a));
|
||||
}
|
||||
|
||||
vec4 texture2D_bicubic(sampler2D tex, vec2 uv)
|
||||
{
|
||||
vec4 texelSize = vec4(texelSize,1.0/texelSize);
|
||||
uv = uv*texelSize.zw;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
|
||||
float g0x = g0(fuv.x);
|
||||
float g1x = g1(fuv.x);
|
||||
float h0x = h0(fuv.x);
|
||||
float h1x = h1(fuv.x);
|
||||
float h0y = h0(fuv.y);
|
||||
float h1y = h1(fuv.y);
|
||||
|
||||
vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
|
||||
return g0(fuv.y) * (g0x * texture2D(tex, p0) +
|
||||
g1x * texture2D(tex, p1)) +
|
||||
g1(fuv.y) * (g0x * texture2D(tex, p2) +
|
||||
g1x * texture2D(tex, p3));
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:3 */
|
||||
vec2 resScale = vec2(1920.,1080.)/(max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/BLOOM_QUALITY);
|
||||
vec2 texcoord = ((gl_FragCoord.xy)*2.+0.5)*texelSize;
|
||||
vec3 bloom = texture2D_bicubic(colortex3,texcoord/2.0).rgb; //1/4 res
|
||||
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/4.).rgb; //1/8 res
|
||||
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res
|
||||
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res
|
||||
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb*1.0; //1/64 res
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb*1.0; //1/128 res
|
||||
bloom += texture2D_bicubic(colortex6,texcoord/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb*1.0; //1/256 res
|
||||
|
||||
//bloom = texture2D_bicubic(colortex6,texcoord).rgb*6.; //1/8 res
|
||||
|
||||
gl_FragData[0].rgb = bloom*2.;
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#version 120
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
//Improves performances and makes sure bloom radius stays the same at high resolution (>1080p)
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
gl_Position = ftransform();
|
||||
//*0.51 to avoid errors when sampling outside since clearing is disabled
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
#version 120
|
||||
//Vignetting, applies bloom, applies exposure and tonemaps the final image
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
|
||||
flat varying vec4 exposure;
|
||||
flat varying vec2 rodExposureDepth;
|
||||
varying vec2 texcoord;
|
||||
uniform sampler2D colortex4;
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex8; // specular
|
||||
// uniform sampler2D colortex9; // specular
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D noisetex;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform float near;
|
||||
uniform float aspectRatio;
|
||||
uniform float far;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform vec4 Moon_Weather_properties; // R = cloud coverage G = fog density
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
vec4 Weather_properties = Moon_Weather_properties;
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
#include "/lib/bokeh.glsl"
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float ld(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
|
||||
}
|
||||
|
||||
// blindness fogs
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:7 */
|
||||
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
|
||||
vec3 col = texture2D(colortex5,texcoord).rgb;
|
||||
|
||||
#if DOF_QUALITY >= 0
|
||||
/*--------------------------------*/
|
||||
float z = ld(texture2D(depthtex0, texcoord.st*RENDER_SCALE).r)*far;
|
||||
#ifdef AUTOFOCUS
|
||||
float focus = rodExposureDepth.y*far;
|
||||
#else
|
||||
float focus = MANUAL_FOCUS*screenBrightness;
|
||||
#endif
|
||||
float pcoc = min(abs(aperture * (focal/100.0 * (z - focus)) / (z * (focus - focal/100.0))),texelSize.x*15.0);
|
||||
#ifdef FAR_BLUR_ONLY
|
||||
pcoc *= float(z > focus);
|
||||
#endif
|
||||
float noise = blueNoise()*6.28318530718;
|
||||
mat2 noiseM = mat2( cos( noise ), -sin( noise ),
|
||||
sin( noise ), cos( noise )
|
||||
);
|
||||
vec3 bcolor = vec3(0.);
|
||||
float nb = 0.0;
|
||||
vec2 bcoord = vec2(0.0);
|
||||
/*--------------------------------*/
|
||||
float dofLodLevel = pcoc * 200.0;
|
||||
for ( int i = 0; i < BOKEH_SAMPLES; i++) {
|
||||
bcolor += texture2DLod(colortex5, texcoord.xy + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).rgb;
|
||||
}
|
||||
col = bcolor/BOKEH_SAMPLES;
|
||||
#endif
|
||||
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
|
||||
|
||||
vec3 bloom = texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5*BLOOM_QUALITY).rgb/2./7.0;
|
||||
|
||||
float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette;
|
||||
|
||||
float VL_abs = texture2D(colortex7,texcoord*RENDER_SCALE).r;
|
||||
float purkinje = rodExposureDepth.x/(1.0+rodExposureDepth.x)*Purkinje_strength;
|
||||
|
||||
VL_abs = clamp( (1.0-VL_abs)*BLOOMY_FOG*0.75*(1.0-purkinje),0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0);
|
||||
|
||||
float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0);
|
||||
col = (mix(col,bloom,VL_abs)+bloom*lightScat)* mix(exposure.rgb,min(exposure.rgb,0.01), 0);
|
||||
|
||||
//Purkinje Effect
|
||||
float lum = dot(col,vec3(0.15,0.3,0.55));
|
||||
float lum2 = dot(col,vec3(0.85,0.7,0.45))/2;
|
||||
float rodLum = lum2*400.;
|
||||
float rodCurve = mix(1.0, rodLum/(2.5+rodLum), purkinje);
|
||||
col = mix(clamp(lum,0.0,0.05)*Purkinje_Multiplier*vec3(Purkinje_R, Purkinje_G, Purkinje_B)+1.5e-3, col, rodCurve);
|
||||
|
||||
#ifndef USE_ACES_COLORSPACE_APPROXIMATION
|
||||
col = LinearTosRGB(TONEMAP(col));
|
||||
#else
|
||||
col = col * ACESInputMat;
|
||||
col = TONEMAP(col);
|
||||
col = LinearTosRGB(clamp(col * ACESOutputMat, 0.0, 1.0));
|
||||
#endif
|
||||
gl_FragData[0].rgb = clamp(int8Dither(col,texcoord),0.0,1.0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec4 exposure;
|
||||
flat varying vec2 rodExposureDepth;
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r);
|
||||
rodExposureDepth = texelFetch2D(colortex4,ivec2(14,37),0).rg;
|
||||
rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +1,51 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 avgAmbient;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
|
||||
flat varying vec3 sunColor;
|
||||
flat varying vec3 moonColor;
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying vec3 zMults;
|
||||
|
||||
attribute vec4 mc_Entity;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
flat varying float FogSchedule;
|
||||
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
varying vec4 lmtexcoord;
|
||||
// varying float vanilla_ao;
|
||||
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
uniform float rainStrength;
|
||||
uniform int isEyeInWater;
|
||||
uniform int frameCounter;
|
||||
// uniform int worldTime;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
@ -35,24 +54,27 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
void main() {
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
gl_Position = ftransform();
|
||||
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0;
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
|
||||
sunColor = texelFetch2D(colortex4,ivec2(12,37),0).rgb;
|
||||
moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb;
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
// avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb;
|
||||
|
||||
|
||||
// ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
// ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
// ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
@ -60,16 +82,32 @@ void main() {
|
||||
// ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb;
|
||||
// ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb;
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
|
||||
|
||||
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
#ifndef VL_Clouds_Shadows
|
||||
lightCol.rgb *= (1.0-rainStrength*0.9);
|
||||
#endif
|
||||
// float Time = worldTime%24000;
|
||||
|
||||
// FogSchedule = clamp( (Time - 9000)/9000 ,0,1);
|
||||
// // float fogAmount0 = 1/3000.+FOG_TOD_MULTIPLIER*(1/100.*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.))*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.)) + 1/120.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.));
|
||||
|
||||
// float fogAmount0 = TimeOfDayFog;
|
||||
|
||||
// // VFAmount = CLOUDY_FOG_AMOUNT*(fogAmount0*fogAmount0+FOG_RAIN_MULTIPLIER*1.0/20000.*rainStrength);
|
||||
// VFAmount = fogAmount0;
|
||||
// fogAmount = BASE_FOG_AMOUNT*(fogAmount0+max(FOG_RAIN_MULTIPLIER*1/10.*rainStrength , FOG_TOD_MULTIPLIER*1/50.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.)));
|
||||
|
||||
|
||||
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
zMults = vec3((far * near)*2.0,far+near,far-near);
|
||||
|
||||
|
||||
|
||||
refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333);
|
||||
}
|
||||
|
@ -1,80 +1,305 @@
|
||||
#version 120
|
||||
//Render sky, volumetric clouds, direct lighting
|
||||
//Horizontal bilateral blur for volumetric fog + Forward rendered objects + Draw volumetric fog
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
uniform vec2 texelSize;
|
||||
flat varying vec3 zMults;
|
||||
flat varying vec2 TAA_Offset;
|
||||
|
||||
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
uniform sampler2D colortex11;
|
||||
uniform sampler2D colortex13;
|
||||
uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex15;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
uniform int frameCounter;
|
||||
flat varying vec3 noooormal;
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
flat varying vec2 TAA_Offset;
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
uniform int frameCounter;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferProjection;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform int isEyeInWater;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float rainStrength;
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
uniform float darknessLightFactor;
|
||||
|
||||
#include "lib/waterBump.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
|
||||
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
float ld(float depth) {
|
||||
return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
|
||||
}
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
vec3 toScreenSpace(vec3 p) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
|
||||
|
||||
// #include "lib/specular.glsl"
|
||||
|
||||
|
||||
|
||||
|
||||
vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth, vec2 distort){
|
||||
coord = coord;
|
||||
vec4 vl = vec4(0.0);
|
||||
float sum = 0.0;
|
||||
mat3x3 weights;
|
||||
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION + distort)*scaling;
|
||||
ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION + distort);
|
||||
float dz = zMults.x;
|
||||
ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2;
|
||||
|
||||
ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling;
|
||||
float dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(0) + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
return vl/sum;
|
||||
}
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
n.xy = abs(encn);
|
||||
n.z = 1.0 - n.x - n.y;
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
|
||||
vec3 worldToView(vec3 worldPos) {
|
||||
vec4 pos = vec4(worldPos, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord )%512 , 0);
|
||||
}
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
|
||||
uniform int isEyeInWater;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
|
||||
#include "lib/sky_gradient.glsl"
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
vec3 viewToWorld(vec3 viewPosition) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPosition;
|
||||
pos.w = 0.0;
|
||||
pos = gbufferModelViewInverse * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:3 */
|
||||
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
gl_FragData[0].rgb = texture2D(colortex3, texcoord).rgb;
|
||||
/* DRAWBUFFERS:73 */
|
||||
|
||||
///////////////// border fog
|
||||
vec4 trpData = texture2D(colortex7,texcoord);
|
||||
|
||||
#ifdef BorderFog
|
||||
vec2 tempOffset = TAA_Offset;
|
||||
bool iswater = trpData.a > 0.99;
|
||||
float translucentAlpha = trpData.a;
|
||||
|
||||
// vec4 speculartex = texture2D(colortex8,texcoord); // translucents
|
||||
// float sunlight = speculartex.b;
|
||||
|
||||
//3x3 bilateral upscale from half resolution
|
||||
float z = texture2D(depthtex0,texcoord).x;
|
||||
float z2 = texture2D(depthtex1,texcoord).x;
|
||||
float frDepth = ld(z2);
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord -vec2(tempOffset)*texelSize*0.5,z));
|
||||
// vec4 vl = texture2D(colortex0,texcoord * 0.5);
|
||||
|
||||
|
||||
vec4 data = texture2D(colortex11,texcoord); // translucents
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
|
||||
vec3 normals = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw) );
|
||||
|
||||
vec4 data_terrain = texture2D(colortex1,texcoord); // terraom
|
||||
vec4 dataUnpacked1_terrain = vec4(decodeVec2(data_terrain.z),decodeVec2(data_terrain.w));
|
||||
|
||||
bool hand = (abs(dataUnpacked1_terrain.w-0.75) < 0.01);
|
||||
|
||||
float lightleakfix = clamp((eyeBrightnessSmooth.y )/240.0,0.0,1.0);
|
||||
|
||||
|
||||
float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); // bloomy rain effect
|
||||
|
||||
|
||||
vec4 Translucent_Programs = texture2D(colortex2,texcoord); // the shader for all translucent progams.
|
||||
|
||||
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));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
vec3 worldpos = p3 + (gbufferModelViewInverse[3].xyz+cameraPosition) ;
|
||||
|
||||
vec2 refractedCoord = texcoord;
|
||||
float glassdepth = clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15);
|
||||
|
||||
#ifdef Refraction
|
||||
refractedCoord += (normals.xy * glassdepth) * RENDER_SCALE;
|
||||
|
||||
float refractedalpha = texture2D(colortex13,refractedCoord).a;
|
||||
if(refractedalpha <= 0.0) refractedCoord = texcoord; // remove refracted coords on solids
|
||||
#endif
|
||||
|
||||
// underwater squiggles
|
||||
// if(isEyeInWater == 1 && !iswater) refractedCoord = texcoord + pow(texture2D(noisetex,texcoord - vec2(0,frameTimeCounter/25)).b - 0.5, 2.0)*0.05;
|
||||
|
||||
|
||||
vec3 sky = skyFromTex(np3,colortex4) / 150. * 5.;
|
||||
vec3 color = texture2D(colortex3,refractedCoord).rgb;
|
||||
|
||||
float fog = 1.0 - clamp( exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
|
||||
#ifdef BorderFog
|
||||
vec3 sky = skyFromTex(np3,colortex4) / 150. * 5.0;
|
||||
float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
|
||||
float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ;
|
||||
|
||||
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog*heightFalloff* lightleakfix);
|
||||
#endif
|
||||
|
||||
vec4 vl = BilateralUpscale(colortex0,depthtex1,gl_FragCoord.xy,frDepth, vec2(0.0));
|
||||
|
||||
if (Translucent_Programs.a > 0.0){
|
||||
#ifdef Glass_Tint
|
||||
vec3 GlassAlbedo = texture2D(colortex13,texcoord).rgb * 5.0;
|
||||
color = color*GlassAlbedo.rgb + color * clamp(pow(1.0-luma(GlassAlbedo.rgb),10.),0.0,1.0);
|
||||
#endif
|
||||
|
||||
color = color*(1.0-Translucent_Programs.a) + Translucent_Programs.rgb;
|
||||
|
||||
#ifdef BorderFog
|
||||
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0);
|
||||
float heightFalloff = clamp( pow(abs(np3.y-1.01),10) ,0,1) ;
|
||||
// if(z < 1.0 && isEyeInWater == 0)
|
||||
|
||||
if(z < 1.0 && isEyeInWater == 0) gl_FragData[0].rgb = mix(gl_FragData[0].rgb, sky, fog*lightleakfix*heightFalloff ) ;
|
||||
|
||||
|
||||
#endif
|
||||
//cave fog
|
||||
#ifdef Cave_fog
|
||||
if (isEyeInWater == 0){
|
||||
float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
|
||||
float fogfade = clamp( exp(clamp( np3.y*0.5 +0.5,0,1) * -6.0) ,0.0,1.0);
|
||||
|
||||
color.rgb = mix(color.rgb, vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor)* clamp( 1.5 - np3.y,0.,1)) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// underwater fog
|
||||
if (isEyeInWater == 1){
|
||||
float fogfade = clamp(exp(-length(fragpos) /5. ) ,0.0,1.0);
|
||||
color.rgb *= fogfade;
|
||||
vl.a *= fogfade*0.70+0.3 ;
|
||||
}
|
||||
|
||||
|
||||
color *= vl.a;
|
||||
color += vl.rgb;
|
||||
|
||||
if(rainDrops > 0.0) vl.a *= clamp(exp2(-rainDrops*5),0.,1.); // bloomy rain effect
|
||||
gl_FragData[0].r = vl.a;
|
||||
|
||||
/// lava.
|
||||
if (isEyeInWater == 2){
|
||||
color.rgb = vec3(4.0,0.5,0.1);
|
||||
}
|
||||
|
||||
/// powdered snow
|
||||
if (isEyeInWater == 3){
|
||||
color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.));
|
||||
vl.a = 0.0;
|
||||
}
|
||||
|
||||
// blidnesss
|
||||
color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(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);
|
||||
|
||||
#ifdef display_LUT
|
||||
vec2 movedTC = texcoord ;
|
||||
if(texcoord.x < 0.45 ) color.rgb = texture2D(colortex4,movedTC).rgb / 150. * 5.0;
|
||||
#endif
|
||||
|
||||
gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0);
|
||||
|
||||
}
|
@ -2,13 +2,20 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
flat varying float tempOffsets;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform int frameCounter;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
uniform sampler2D colortex4;
|
||||
flat varying vec3 zMults;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
@ -18,13 +25,30 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
flat varying vec3 noooormal;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
zMults = vec3(1.0/(far * near),far+near,far-near);
|
||||
gl_Position = ftransform();
|
||||
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
|
||||
vec3 noooormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
}
|
||||
|
46
shaders/composite4.fsh
Normal file
46
shaders/composite4.fsh
Normal file
@ -0,0 +1,46 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
uniform sampler2D colortex3;
|
||||
// Compute 3x3 min max for TAA
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:06 */
|
||||
ivec2 center = ivec2(gl_FragCoord.xy);
|
||||
vec3 current = texelFetch2D(colortex3, center, 0).rgb;
|
||||
vec3 cMin = current;
|
||||
vec3 cMax = current;
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, 0), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(0, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(0, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, 0), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
gl_FragData[0].rgb = cMax;
|
||||
gl_FragData[1].rgb = cMin;
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec3 zMults;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -12,8 +11,8 @@ uniform float near;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
zMults = vec3((far * near)*2.0,far+near,far-near);
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
}
|
@ -1,388 +1,518 @@
|
||||
#version 120
|
||||
//Volumetric fog rendering
|
||||
//Temporal Anti-Aliasing + Dynamic exposure calculations (vertex shader)
|
||||
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
//TAA OPTIONS
|
||||
|
||||
const int noiseTextureResolution = 32;
|
||||
|
||||
|
||||
/*
|
||||
const int colortex0Format = RGBA16F; // low res clouds (deferred->composite2) + low res VL (composite5->composite15)
|
||||
const int colortex1Format = RGBA16; //terrain gbuffer (gbuffer->composite2)
|
||||
const int colortex2Format = RGBA16F; //forward + transparencies (gbuffer->composite4)
|
||||
const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6->final)
|
||||
const int colortex4Format = RGBA16F; //light values and skyboxes (everything)
|
||||
|
||||
|
||||
const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final)
|
||||
const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex8Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex9Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex10Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
|
||||
const int colortex13Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
// const int colortex15Format = RGBA16F; // flat normals and vanilla
|
||||
*/
|
||||
//no need to clear the buffers, saves a few fps
|
||||
/*
|
||||
const bool colortex0Clear = false;
|
||||
const bool colortex1Clear = false;
|
||||
const bool colortex2Clear = true;
|
||||
const bool colortex3Clear = false;
|
||||
const bool colortex4Clear = false;
|
||||
const bool colortex5Clear = false;
|
||||
const bool colortex6Clear = false;
|
||||
const bool colortex7Clear = false;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef SCREENSHOT_MODE
|
||||
/*
|
||||
const int colortex5Format = RGBA32F; //TAA buffer (everything)
|
||||
*/
|
||||
#else
|
||||
/*
|
||||
const int colortex5Format = R11F_G11F_B10F; //TAA buffer (everything)
|
||||
*/
|
||||
#endif
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying float exposureA;
|
||||
flat varying float tempOffsets;
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
flat varying float FogSchedule;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex6;
|
||||
// uniform sampler2D colortex10;
|
||||
uniform sampler2D colortex13;
|
||||
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2DShadow shadow;
|
||||
flat varying vec3 refractedSunVec;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex4;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform int frameCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float sunElevation;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
|
||||
#include "lib/Shadow_Params.glsl"
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/color_dither.glsl"
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform int frameCounter;
|
||||
uniform int framemod8;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
#include "lib/projections.glsl"
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
|
||||
#define TIMEOFDAYFOG
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets);
|
||||
}
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
dither = center*inversesqrt(abs(center));
|
||||
return clamp(dither-fsign(center),0.0,1.0);
|
||||
}
|
||||
vec3 fp10Dither(vec3 color,float dither){
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
|
||||
|
||||
//returns the projected coordinates of the closest point to the camera in the 3x3 neighborhood
|
||||
vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
|
||||
{
|
||||
vec2 du = vec2(texelSize.x*2., 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y*2.);
|
||||
|
||||
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x);
|
||||
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x);
|
||||
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x);
|
||||
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x);
|
||||
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x);
|
||||
|
||||
vec3 dmin = dmc;
|
||||
dmin = dmin.z > dtr.z? dtr : dmin;
|
||||
dmin = dmin.z > dtl.z? dtl : dmin;
|
||||
dmin = dmin.z > dbl.z? dbl : dmin;
|
||||
dmin = dmin.z > dbr.z? dbr : dmin;
|
||||
#ifdef TAA_UPSCALING
|
||||
dmin.xy = dmin.xy/RENDER_SCALE;
|
||||
#endif
|
||||
return dmin;
|
||||
}
|
||||
|
||||
//Modified texture interpolation from inigo quilez
|
||||
vec4 smoothfilter(in sampler2D tex, in vec2 uv)
|
||||
{
|
||||
vec2 textureResolution = vec2(viewWidth,viewHeight);
|
||||
uv = uv*textureResolution + 0.5;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
|
||||
uv = (uv - 0.5)/textureResolution;
|
||||
return texture2D( tex, uv);
|
||||
}
|
||||
//Due to low sample count we "tonemap" the inputs to preserve colors and smoother edges
|
||||
vec3 weightedSample(sampler2D colorTex, vec2 texcoord){
|
||||
vec3 wsample = texture2D(colorTex,texcoord).rgb*exposureA;
|
||||
return wsample/(1.0+luma(wsample));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//from : https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
||||
vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
||||
// location [1, 1] in the grid, where [0, 0] is the top left corner.
|
||||
vec2 samplePos = uv * texSize;
|
||||
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
|
||||
|
||||
// Compute the fractional offset from our starting texel to our original sample location, which we'll
|
||||
// feed into the Catmull-Rom spline function to get our filter weights.
|
||||
vec2 f = samplePos - texPos1;
|
||||
|
||||
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
|
||||
// These equations are pre-expanded based on our knowledge of where the texels will be located,
|
||||
// which lets us avoid having to evaluate a piece-wise function.
|
||||
vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f));
|
||||
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f);
|
||||
vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) );
|
||||
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
||||
|
||||
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
|
||||
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 offset12 = w2 / (w1 + w2);
|
||||
|
||||
// Compute the final UV coordinates we'll use for sampling the texture
|
||||
vec2 texPos0 = texPos1 - vec2(1.0);
|
||||
vec2 texPos3 = texPos1 + vec2(2.0);
|
||||
vec2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 *= texelSize;
|
||||
texPos3 *= texelSize;
|
||||
texPos12 *= texelSize;
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float R2_dither2(){
|
||||
//approximation from SMAA presentation from siggraph 2016
|
||||
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount)
|
||||
{
|
||||
vec2 position = rtMetrics.zw * texcoord;
|
||||
vec2 centerPosition = floor(position - 0.5) + 0.5;
|
||||
vec2 f = position - centerPosition;
|
||||
vec2 f2 = f * f;
|
||||
vec2 f3 = f * f2;
|
||||
|
||||
float c = sharpenAmount;
|
||||
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
|
||||
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
|
||||
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
|
||||
vec2 w3 = c * f3 - c * f2;
|
||||
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
|
||||
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
|
||||
|
||||
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
|
||||
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
|
||||
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
|
||||
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
|
||||
vec4(centerColor, 1.0) * (w12.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
|
||||
return color.rgb/color.a;
|
||||
|
||||
}
|
||||
|
||||
vec3 clip_aabb(vec3 q,vec3 aabb_min, vec3 aabb_max)
|
||||
{
|
||||
vec3 p_clip = 0.5 * (aabb_max + aabb_min);
|
||||
vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001;
|
||||
|
||||
vec3 v_clip = q - vec3(p_clip);
|
||||
vec3 v_unit = v_clip.xyz / e_clip;
|
||||
vec3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return vec3(p_clip) + v_clip / ma_unit;
|
||||
else
|
||||
return q;
|
||||
}
|
||||
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 tonemap(vec3 col){
|
||||
return col/(1+luma(col));
|
||||
}
|
||||
vec3 invTonemap(vec3 col){
|
||||
return col/(1-luma(col));
|
||||
}
|
||||
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.);
|
||||
|
||||
|
||||
|
||||
// float maxOf(vec2 v) { return max(v.x, v.y); }
|
||||
// float maxOf(vec3 v) { return max(v.x, max(v.y, v.z)); }
|
||||
// float maxOf(vec4 v) { return max(v.x, max(v.y, max(v.z, v.w))); }
|
||||
// const float eps = 1e-6;
|
||||
|
||||
// vec3 reproject(vec3 screenPos, sampler2D velocitySampler) {
|
||||
// vec3 velocity = texelFetch(velocitySampler, ivec2(screenPos.xy), 0).xyz;
|
||||
|
||||
// if (maxOf(abs(velocity)) < r) {
|
||||
// return reproject(screenPos);
|
||||
// } else {
|
||||
// vec3 pos = screenToViewSpace(screenPos, false);
|
||||
// pos = pos - velocity;
|
||||
// pos = toScreenSpace(pos, false);
|
||||
|
||||
// return pos;
|
||||
// }
|
||||
// }
|
||||
vec3 worldToView(vec3 p3) {
|
||||
vec4 pos = vec4(p3, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
vec3 viewToWorld(vec3 viewPosition) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPosition;
|
||||
pos.w = 0.0;
|
||||
pos = gbufferModelViewInverse * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
vec3 projectAndDivide(mat4 projectionMatrix, vec3 position){
|
||||
vec4 homogeneousPos = projectionMatrix * vec4(position, 1.0);
|
||||
return homogeneousPos.xyz / homogeneousPos.w;
|
||||
}
|
||||
|
||||
vec3 TAA_hq(bool hand, bool istranslucent, vec3 EntityVelocity, inout vec3 DEBUG){
|
||||
#ifdef TAA_UPSCALING
|
||||
vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.);
|
||||
#else
|
||||
vec2 adjTC = texcoord;
|
||||
#endif
|
||||
|
||||
//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);
|
||||
#endif
|
||||
// if( EntityVelocity > vec3(0.0) ) closestToCamera = closestToCamera - EntityVelocity;
|
||||
|
||||
#ifndef CLOSEST_VELOCITY
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x);
|
||||
#endif
|
||||
|
||||
//reproject previous frame
|
||||
vec3 fragposition = toScreenSpace(closestToCamera);
|
||||
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
|
||||
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3Prev(previousPosition) ;
|
||||
|
||||
|
||||
|
||||
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity ;
|
||||
// previousPosition -= abs(EntityVelocity);
|
||||
|
||||
DEBUG = previousPosition;
|
||||
|
||||
//reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
|
||||
return smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
// Interpolating neighboorhood clampling boundaries between pixels
|
||||
vec3 cMax = texture2D(colortex0, adjTC).rgb;
|
||||
vec3 cMin = texture2D(colortex6, adjTC).rgb;
|
||||
#else
|
||||
vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb;
|
||||
vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb;
|
||||
vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb;
|
||||
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
|
||||
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
|
||||
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
|
||||
albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb;
|
||||
#endif
|
||||
|
||||
#ifndef NO_CLIP
|
||||
vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0);
|
||||
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
|
||||
|
||||
//Increases blending factor when far from AABB and in motion, reduces ghosting
|
||||
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5;
|
||||
float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0);
|
||||
|
||||
float test = 0.05;
|
||||
if(hand) movementRejection *= 5;
|
||||
if(istranslucent) test = 0.1;
|
||||
|
||||
//Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
// vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, min(luma(motionVector) *255,1.0),1.)));
|
||||
|
||||
vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, test,1.)));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NO_CLIP
|
||||
vec3 albedoPrev = texture2D(colortex5, previousPosition.xy).xyz;
|
||||
vec3 supersampled = mix(albedoPrev,albedoCurrent0,clamp(0.05,0.,1.));
|
||||
#endif
|
||||
|
||||
//De-tonemap
|
||||
return supersampled;
|
||||
}
|
||||
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
n.xy = abs(encn);
|
||||
n.z = 1.0 - n.x - n.y;
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
vec2 R2_samples(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x *(1- gl_FragCoord.x) + alpha.y * (1-gl_FragCoord.y) + 1.0/1.6180339887 * frameCounter) ;
|
||||
return fract(alpha * n)*2.-1.0;
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
|
||||
float phaseRayleigh(float cosTheta) {
|
||||
const vec2 mul_add = vec2(0.1, 0.28) /acos(-1.0);
|
||||
return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation
|
||||
}
|
||||
|
||||
float GetCloudShadow(vec3 eyePlayerPos){
|
||||
vec3 worldPos = (eyePlayerPos + cameraPosition) - Cloud_Height;
|
||||
vec3 cloudPos = worldPos*Cloud_Size + WsunVec/abs(WsunVec.y) * ((3250 - 3250*0.35) - worldPos.y*Cloud_Size) ;
|
||||
float shadow = getCloudDensity(cloudPos, 1);
|
||||
|
||||
shadow = clamp(exp(-shadow*5),0.0,1.0);
|
||||
|
||||
return shadow ;
|
||||
}
|
||||
|
||||
float densityAtPosFog(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
f = (f*f) * (3.-2.*f);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
float fog_densities_atmospheric = 24 * Haze_amount; // this is seperate from the cloudy and uniform fog.
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
|
||||
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
|
||||
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
|
||||
float mult = exp( -max((pos.y - SEA_LEVEL) / 35.,0.0));
|
||||
|
||||
float fog_shape = 1-densityAtPosFog(samplePos * 24.0);
|
||||
float fog_eroded = 1-densityAtPosFog( samplePos2 * 200.0);
|
||||
|
||||
float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.2, 0.0) * mult;
|
||||
float UniformFog = exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0));
|
||||
|
||||
float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength;
|
||||
|
||||
TimeOfDayFog(UniformFog, CloudyFog);
|
||||
|
||||
return CloudyFog + UniformFog + RainFog;
|
||||
}
|
||||
|
||||
mat2x3 getVolumetricRays(
|
||||
float dither,
|
||||
vec3 fragpos,
|
||||
float dither2
|
||||
){
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = toShadowSpaceProjected(vec3(0.));
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = fragposition-start;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
|
||||
float maxLength = min(length(dVWorld),far)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
|
||||
vec3 vL = vec3(0.);
|
||||
|
||||
float SdotV = dot(sunVec,normalize(fragpos))*lightCol.a;
|
||||
float dL = length(dVWorld);
|
||||
|
||||
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
|
||||
float mie = phaseg(SdotV,0.7)*5.0 + 1.0;
|
||||
float rayL = phaseRayleigh(SdotV);
|
||||
|
||||
// Makes fog more white idk how to simulate it correctly
|
||||
vec3 sunColor = lightCol.rgb / 127.0;
|
||||
vec3 skyCol0 = (ambientUp / 150. * 5.); // * max(abs(WsunVec.y)/150.0,0.);
|
||||
|
||||
vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5);
|
||||
vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6);
|
||||
|
||||
float mu = 1.0;
|
||||
float muS = mu;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float expFactor = 11.0;
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
|
||||
|
||||
float cloudShadow = 1.0;
|
||||
|
||||
for (int i=0;i<VL_SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
//project into biased shadowmap space
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
|
||||
float densityVol = cloudVol(progressW);
|
||||
float sh = 1.0;
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
float max_height = clamp(400.0 - progressW.y, 0.0,1.0); // so it doesnt go beyond the height of the clouds
|
||||
vec3 campos = (progressW)-319;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
cloudShadow = exp(-cloudShadow*cloudDensity*200);
|
||||
cloudShadow *= max_height;
|
||||
// cloudShadow *= 1000; //debug
|
||||
#endif
|
||||
#endif
|
||||
vec4 TAA_hq_render(){
|
||||
#ifdef TAA_UPSCALING
|
||||
vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.);
|
||||
#else
|
||||
vec2 adjTC = texcoord;
|
||||
#endif
|
||||
|
||||
//Water droplets(fog)
|
||||
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24;
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density)*mC;
|
||||
|
||||
|
||||
vec3 DirectLight = (sunColor*sh*cloudShadow) * (rayL*rL+m*mie);
|
||||
vec3 AmbientLight = skyCol0 * m;
|
||||
vec3 AtmosphericFog = skyCol0 * (rL+m) ;
|
||||
|
||||
// extra fog effects
|
||||
vec3 rainRays = (sunColor*sh*cloudShadow) * (rayL*phaseg(SdotV,0.6)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength;
|
||||
vec3 CaveRays = (sunColor*sh*cloudShadow) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
|
||||
|
||||
vec3 vL0 = ( DirectLight + AmbientLight + AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
|
||||
|
||||
#ifdef Biome_specific_environment
|
||||
BiomeFogColor(vL0); // ?????
|
||||
//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);
|
||||
#endif
|
||||
|
||||
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
|
||||
absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0);
|
||||
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
}
|
||||
|
||||
float waterCaustics(vec3 wPos, vec3 lightSource) { // water waves
|
||||
|
||||
vec2 pos = wPos.xz + (lightSource.xz/lightSource.y*wPos.y);
|
||||
if(isEyeInWater==1) pos = wPos.xz - (lightSource.xz/lightSource.y*wPos.y); // fix the fucky
|
||||
vec2 movement = vec2(-0.035*frameTimeCounter);
|
||||
float caustic = 0.0;
|
||||
float weightSum = 0.0;
|
||||
float radiance = 2.39996;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
const vec2 wave_size[4] = vec2[](
|
||||
vec2(64.),
|
||||
vec2(32.,16.),
|
||||
vec2(16.,32.),
|
||||
vec2(48.)
|
||||
);
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
pos = rotationMatrix * pos;
|
||||
|
||||
vec2 speed = movement;
|
||||
float waveStrength = 1.0;
|
||||
|
||||
if( i == 0) {
|
||||
speed *= 0.15;
|
||||
waveStrength = 2.0;
|
||||
}
|
||||
|
||||
float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength;
|
||||
|
||||
caustic += max( 1.0-sin( 1.0-pow( 0.5+sin( small_wave*3.0 )*0.5, 25.0) ), 0);
|
||||
|
||||
weightSum -= exp2(caustic*0.1);
|
||||
}
|
||||
return caustic / weightSum;
|
||||
}
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEyeDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){
|
||||
int spCount = 8;
|
||||
|
||||
vec3 start = toShadowSpaceProjected(rayStart);
|
||||
vec3 end = toShadowSpaceProjected(rayEnd);
|
||||
vec3 dV = (end-start);
|
||||
|
||||
//limit ray length at 32 blocks for performance and reducing integration error
|
||||
//you can't see above this anyway
|
||||
float maxZ = min(rayLength,32.0)/(1e-8+rayLength);
|
||||
dV *= maxZ;
|
||||
vec3 dVWorld = mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ;
|
||||
rayLength *= maxZ;
|
||||
float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
vec3 vL = vec3(0.0);
|
||||
float phase = 2*mix(phaseg(VdotL, 0.4),phaseg(VdotL, 0.8),0.5);
|
||||
float expFactor = 11.0;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
|
||||
float cloudShadow = 1;
|
||||
for (int i=0;i<spCount;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); // exponential step position (0-1)
|
||||
float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0); //step length (derivative)
|
||||
vec3 spPos = start.xyz + dV*d;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
//project into biased shadowmap space
|
||||
float distortFactor = calcDistort(spPos.xy);
|
||||
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){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
vec3 campos = (progressW)-319;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
float cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
// cloudShadow = exp(-cloudShadow*sqrt(cloudDensity)*50);
|
||||
cloudShadow = clamp(exp(-cloudShadow*6),0.0,1.0);
|
||||
sh *= cloudShadow;
|
||||
#endif
|
||||
#ifndef CLOSEST_VELOCITY
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex0,adjTC).x);
|
||||
#endif
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * rayEnd;
|
||||
vec3 np3 = normVec(p3);
|
||||
float ambfogfade = clamp(exp(np3.y*1.5 - 1.5),0.0,1.0) ;
|
||||
//reproject previous frame
|
||||
vec3 fragposition = toScreenSpace(closestToCamera);
|
||||
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3Prev(previousPosition);
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
vec3 ambientMul = exp(-max(estEyeDepth - dY * d,0.0) * waterCoefs) + ambfogfade*0.5 ;
|
||||
vec3 sunMul = exp(-max((estEyeDepth - dY * d) ,0.0)/abs(refractedSunVec.y) * waterCoefs)*cloudShadow;
|
||||
// //reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
|
||||
return vec4(smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz, 1.0);
|
||||
|
||||
float sunCaustics = waterCaustics(progressW, WsunVec);
|
||||
sunCaustics = max(pow(sunCaustics*3,2),0.5);
|
||||
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz;
|
||||
|
||||
vec3 light = (sh * lightSource * phase * sunCaustics * sunMul + (ambient*ambientMul))*scatterCoef;
|
||||
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs *absorbance;
|
||||
absorbance *= exp(-dd * rayLength * waterCoefs);
|
||||
}
|
||||
inColor += vL;
|
||||
float rej = 0.0;
|
||||
vec4 albedoPrev = texture2D(colortex5, previousPosition.xy);
|
||||
vec3 supersampled = albedoPrev.rgb * albedoPrev.a + albedoCurrent0;
|
||||
|
||||
if (length(velocity) > 1e-6) return vec4(albedoCurrent0,1.0);
|
||||
return vec4(supersampled/(albedoPrev.a+1.0), albedoPrev.a+1.0);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
float lightleakfix = max(eyeBrightnessSmooth.y,0)/240.;
|
||||
|
||||
if (isEyeInWater == 0){
|
||||
/* DRAWBUFFERS:5 */
|
||||
|
||||
vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize;
|
||||
float z = texture2D(depthtex0,tc).x;
|
||||
vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
|
||||
float noise = blueNoise();
|
||||
mat2x3 vl = getVolumetricRays(noise,fragpos,blueNoise());
|
||||
float absorbance = dot(vl[1],vec3(0.22,0.71,0.07));
|
||||
gl_FragData[0] = clamp(vec4(vl[0],absorbance),0.000001,65000.);
|
||||
|
||||
} else {
|
||||
|
||||
float dirtAmount = Dirt_Amount;
|
||||
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
|
||||
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
|
||||
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
|
||||
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B);
|
||||
|
||||
#ifdef AEROCHROME_MODE
|
||||
totEpsilon *= 2.0;
|
||||
scatterCoef *= 10.0;
|
||||
gl_FragData[0].a = 1.0;
|
||||
#ifndef SPLIT_RENDER
|
||||
#ifdef SCREENSHOT_MODE
|
||||
|
||||
|
||||
vec4 color = TAA_hq_render();
|
||||
gl_FragData[0] = color;
|
||||
|
||||
|
||||
#else
|
||||
#ifdef TAA
|
||||
vec4 data = texture2D(colortex1,texcoord* RENDER_SCALE); // terraom
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
|
||||
bool translucentCol = texture2D(colortex13,texcoord * RENDER_SCALE).a > 0.0; // translucents
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
// vec3 motionVector = texture2D(colortex10,texcoord).xyz ;
|
||||
// vec3 motionVector = texelFetch(colortex10, ivec2(gl_FragCoord.xy), 0).xyz * 2 - 1;
|
||||
|
||||
// if((motionVector.x+motionVector.y+motionVector.z) / 3 < 0.00001) motionVector = vec3(0.0);
|
||||
// vec3 viewpos = motionVector;
|
||||
// // vec3 eyepos = mat3(gbufferModelViewInverse) * viewpos;
|
||||
// // vec3 worldPos = eyepos + (cameraPosition + gbufferModelViewInverse[3].xyz);
|
||||
// // vec3 feetPos = worldPos - cameraPosition;
|
||||
|
||||
// vec4 clippos = gbufferProjection * vec4(motionVector,1.0);
|
||||
|
||||
// vec3 ndcPos = projectAndDivide(gbufferProjectionInverse, viewpos);
|
||||
// vec3 screenPos = ndcPos * 0.5 + 0.5;
|
||||
|
||||
|
||||
vec3 DEBUG = vec3(0.0);
|
||||
color += TAA_hq(hand, translucentCol, vec3(0.0),DEBUG);
|
||||
|
||||
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color ,triangularize(R2_dither())),6.11*1e-5,65000.0);
|
||||
// gl_FragData[0].rgb = motionVector;
|
||||
#endif
|
||||
|
||||
vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize;
|
||||
float z = texture2D(depthtex0,tc).x;
|
||||
vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
|
||||
float noise = R2_dither();
|
||||
vec3 vl = vec3(0.0);
|
||||
float estEyeDepth = clamp((14.0-eyeBrightnessSmooth.y/255.0*16.0)/14.0,0.,1.0);
|
||||
estEyeDepth *= estEyeDepth*estEyeDepth*34.0;
|
||||
|
||||
#ifndef lightMapDepthEstimation
|
||||
estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0);
|
||||
#ifndef TAA
|
||||
vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.);
|
||||
gl_FragData[0].rgb = color;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SPLIT_RENDER
|
||||
if(texcoord.x > 0.5){
|
||||
|
||||
vec4 color = TAA_hq_render();
|
||||
gl_FragData[0] = color;
|
||||
|
||||
}else{
|
||||
vec4 data = texture2D(colortex1,texcoord* RENDER_SCALE); // terraom
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
|
||||
bool translucentCol = texture2D(colortex13,texcoord * RENDER_SCALE).a > 0.0; // translucents
|
||||
|
||||
|
||||
|
||||
vec3 color = TAA_hq(hand, translucentCol);
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color ,triangularize(R2_dither())),6.11*1e-5,65000.0);
|
||||
|
||||
waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, (ambientUp*8./150./3.*0.5) , lightCol.rgb*8./150./3.0*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)), dot(normalize(fragpos), normalize(sunVec) ));
|
||||
gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -3,110 +3,16 @@
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
|
||||
|
||||
flat varying vec3 sunColor;
|
||||
flat varying vec3 moonColor;
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying float exposureA;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
flat varying float FogSchedule;
|
||||
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
uniform float rainStrength;
|
||||
uniform int isEyeInWater;
|
||||
uniform int frameCounter;
|
||||
// uniform int worldTime;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
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//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
gl_Position = ftransform();
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0;
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
|
||||
sunColor = texelFetch2D(colortex4,ivec2(12,37),0).rgb;
|
||||
moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb;
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb;
|
||||
|
||||
|
||||
ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
ambientRight = texelFetch2D(colortex4,ivec2(3,37),0).rgb;
|
||||
ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb;
|
||||
ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb;
|
||||
|
||||
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
#ifndef VL_Clouds_Shadows
|
||||
lightCol.rgb *= (1.0-rainStrength*0.9);
|
||||
#endif
|
||||
// float Time = worldTime%24000;
|
||||
|
||||
// FogSchedule = clamp( (Time - 9000)/9000 ,0,1);
|
||||
// // float fogAmount0 = 1/3000.+FOG_TOD_MULTIPLIER*(1/100.*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.))*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.)) + 1/120.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.));
|
||||
|
||||
// float fogAmount0 = TimeOfDayFog;
|
||||
|
||||
// // VFAmount = CLOUDY_FOG_AMOUNT*(fogAmount0*fogAmount0+FOG_RAIN_MULTIPLIER*1.0/20000.*rainStrength);
|
||||
// VFAmount = fogAmount0;
|
||||
// fogAmount = BASE_FOG_AMOUNT*(fogAmount0+max(FOG_RAIN_MULTIPLIER*1/10.*rainStrength , FOG_TOD_MULTIPLIER*1/50.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.)));
|
||||
|
||||
|
||||
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333);
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
exposureA = texelFetch2D(colortex4,ivec2(10,37),0).r;
|
||||
}
|
||||
|
@ -1,313 +1,50 @@
|
||||
#version 120
|
||||
//Horizontal bilateral blur for volumetric fog + Forward rendered objects + Draw volumetric fog
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
//downsample 1st pass (half res) for bloom
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
flat varying vec3 zMults;
|
||||
flat varying vec2 TAA_Offset;
|
||||
|
||||
|
||||
/*
|
||||
const int colortex11Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
*/
|
||||
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
uniform sampler2D colortex11;
|
||||
uniform sampler2D colortex13;
|
||||
uniform sampler2D colortex15;
|
||||
// uniform sampler2D colortex8;
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
||||
flat varying vec3 noooormal;
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 WsunVec;
|
||||
#include "lib/res_params.glsl"
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int frameCounter;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferProjection;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform int isEyeInWater;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float rainStrength;
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
uniform float darknessLightFactor;
|
||||
uniform float nightVision;
|
||||
|
||||
#include "lib/waterBump.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
// #include "lib/biome_specifics.glsl"
|
||||
|
||||
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
float ld(float depth) {
|
||||
return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
|
||||
}
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
vec3 toScreenSpace(vec3 p) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
|
||||
|
||||
// #include "lib/specular.glsl"
|
||||
|
||||
|
||||
|
||||
|
||||
vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth){
|
||||
coord = coord;
|
||||
vec4 vl = vec4(0.0);
|
||||
float sum = 0.0;
|
||||
mat3x3 weights;
|
||||
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION)*scaling;
|
||||
ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION);
|
||||
float dz = zMults.x;
|
||||
ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2;
|
||||
|
||||
ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling;
|
||||
float dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(0) + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling;
|
||||
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
|
||||
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
|
||||
vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w;
|
||||
sum += w;
|
||||
|
||||
return vl/sum;
|
||||
}
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
n.xy = abs(encn);
|
||||
n.z = 1.0 - n.x - n.y;
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
|
||||
vec3 worldToView(vec3 worldPos) {
|
||||
vec4 pos = vec4(worldPos, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord )%512 , 0);
|
||||
}
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
vec3 viewToWorld(vec3 viewPosition) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPosition;
|
||||
pos.w = 0.0;
|
||||
pos = gbufferModelViewInverse * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
/* DRAWBUFFERS:73 */
|
||||
|
||||
vec4 transparencies = texture2D(colortex2,texcoord);
|
||||
vec4 trpData = texture2D(colortex7,texcoord);
|
||||
|
||||
vec4 speculartex = texture2D(colortex8,texcoord); // translucents
|
||||
float sunlight = speculartex.b;
|
||||
|
||||
bool iswater = trpData.a > 0.99;
|
||||
float translucentAlpha = trpData.a;
|
||||
|
||||
//3x3 bilateral upscale from half resolution
|
||||
float z = texture2D(depthtex0,texcoord).x;
|
||||
float z2 = texture2D(depthtex1,texcoord).x;
|
||||
float frDepth = ld(z2);
|
||||
vec4 vl = BilateralUpscale(colortex0,depthtex1,gl_FragCoord.xy,frDepth);
|
||||
// vec4 vl = texture2D(colortex0,texcoord * 0.5);
|
||||
/* DRAWBUFFERS:3 */
|
||||
|
||||
|
||||
vec4 data = texture2D(colortex11,texcoord); // translucents
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
|
||||
vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.*resScale/BLOOM_QUALITY;
|
||||
|
||||
vec3 normals = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw) );
|
||||
// float emissives1 = texture2D(colortex8,quarterResTC).a;
|
||||
// float emissives2 = emissives1 < 1.0 ? emissives1 : 0.0;
|
||||
|
||||
vec4 data_terrain = texture2D(colortex1,texcoord); // terraom
|
||||
vec4 dataUnpacked1_terrain = vec4(decodeVec2(data_terrain.z),decodeVec2(data_terrain.w));
|
||||
// 0.5
|
||||
gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
|
||||
|
||||
bool hand = (abs(dataUnpacked1_terrain.w-0.75) < 0.01);
|
||||
//0.25
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125;
|
||||
|
||||
|
||||
vec2 refractedCoord = texcoord;
|
||||
|
||||
float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); // bloomy rain effect
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0);
|
||||
|
||||
|
||||
|
||||
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));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
#ifdef Refraction
|
||||
vec3 worldPos = p3 + cameraPosition;
|
||||
|
||||
// thank you sixthsurge, though i may be doing stuff weirdly with the tangent, it works... as far as i can tell.
|
||||
vec3 geometryNormal = normalize(cross(dFdx(worldPos), dFdy(worldPos)));
|
||||
|
||||
vec3 geometryNormal2 = geometryNormal;
|
||||
vec3 tangent = geometryNormal2.y > 0.50 || geometryNormal2.y < -0.50 ? normalize(cross(vec3(0,0,1),geometryNormal)) : normalize(cross(vec3(0.0, 1.0, 0.0), geometryNormal));
|
||||
|
||||
// vec3 tangent = normalize(cross(vec3(1.0, 1.0, 1.0), geometryNormal)) ;
|
||||
vec3 bitangent = normalize(cross(tangent, geometryNormal)) ;
|
||||
mat3 tbn = mat3(tangent, bitangent, geometryNormal);
|
||||
vec3 tangentSpaceNormal = normals * tbn;
|
||||
|
||||
float dist = clamp(ld(fragpos.z)*100,0,0.15); // shrink as distance increases
|
||||
|
||||
if( translucentAlpha > 0.0) refractedCoord += (tangentSpaceNormal.xy * dist ) * RENDER_SCALE;
|
||||
|
||||
bool glass = texture2D(colortex7,refractedCoord).a > 0.0 && texture2D(colortex13,texcoord).a > 0.0;
|
||||
if(!glass) refractedCoord = texcoord;
|
||||
#endif
|
||||
|
||||
// underwater squiggles
|
||||
// if(isEyeInWater == 1 && !iswater) refractedCoord = texcoord + pow(texture2D(noisetex,texcoord - vec2(0,frameTimeCounter/25)).b - 0.5, 2.0)*0.05;
|
||||
|
||||
|
||||
vec3 color = texture2D(colortex3,refractedCoord).rgb;
|
||||
|
||||
if (frDepth > 2.5/far || transparencies.a < 0.99 || !hand) color = color * (1.0-transparencies.a) + transparencies.rgb*10.; // Discount fix for transparencies through hand
|
||||
|
||||
|
||||
|
||||
float dirtAmount = Dirt_Amount;
|
||||
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
|
||||
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
|
||||
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
|
||||
|
||||
color *= vl.a ;
|
||||
|
||||
if(rainDrops > 0.0) {
|
||||
// refractedCoord = mix(refractedCoord, vec2(texcoord.x,texcoord.y * 0.9 + 0.05), rainStrength) ;
|
||||
vl.a *= clamp(exp2(-rainDrops*5),0.,1.); // bloomy rain effect
|
||||
}
|
||||
|
||||
|
||||
float lightleakfix = clamp((eyeBrightnessSmooth.y )/240.0,0.0,1.0);
|
||||
|
||||
//cave fog
|
||||
#ifdef Cave_fog
|
||||
if (isEyeInWater == 0){
|
||||
float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
|
||||
float fogfade = clamp( exp(clamp( np3.y*0.5 +0.5,0,1) * -6.0) ,0.0,1.0);
|
||||
|
||||
color.rgb = mix(color.rgb, vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor)* clamp( 1.5 - np3.y,0.,1)) ;
|
||||
// color.rgb = mix(color.rgb, vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade, fogdistfade) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// underwater fog
|
||||
if (isEyeInWater == 1){
|
||||
float fogfade = clamp(exp(-length(fragpos) /9. ) ,0.0,1.0);
|
||||
color.rgb *= fogfade;
|
||||
vl.a *= fogfade*0.70+0.3 ;
|
||||
}
|
||||
|
||||
color += vl.rgb;
|
||||
gl_FragData[0].r = vl.a;
|
||||
|
||||
/// lava.
|
||||
if (isEyeInWater == 2){
|
||||
color.rgb = vec3(4.0,0.5,0.1);
|
||||
}
|
||||
|
||||
/// powdered snow
|
||||
if (isEyeInWater == 3){
|
||||
color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.));
|
||||
vl.a = 0.0;
|
||||
}
|
||||
|
||||
// blidnesss
|
||||
// color.rgb *= mix(1.0, clamp(1.5-pow(length(fragpos2)*(blindness*0.2),2.0),0.0,1.0), blindness);
|
||||
color.rgb *= mix(1.0, clamp( exp(pow(length(fragpos)*(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);
|
||||
|
||||
|
||||
gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0);
|
||||
|
||||
#ifdef display_LUT
|
||||
gl_FragData[1].rgb = texture2D(colortex4,texcoord/2.5).rgb *0.035;
|
||||
#endif
|
||||
|
||||
// gl_FragData[1].rgb =mix(vec3(0.2,0.5,1), vec3(0,0,0), clamp( exp2(pow(clamp(0.5-np3.y,0,1) ,2)* -0.5) ,0,1));
|
||||
}
|
@ -1,32 +1,8 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform int frameCounter;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
uniform sampler2D colortex4;
|
||||
flat varying vec3 zMults;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
#include "/lib/res_params.glsl"
|
||||
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.);
|
||||
|
||||
|
||||
flat varying vec3 noooormal;
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -34,21 +10,9 @@ flat varying vec3 noooormal;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
zMults = vec3(1.0/(far * near),far+near,far-near);
|
||||
//Improves performances and makes sure bloom radius stays the same at high resolution (>1080p)
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
gl_Position = ftransform();
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
|
||||
vec3 noooormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
//*0.51 to avoid errors when sampling outside since clearing is disabled
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
//downsample 1st pass (half res) for bloom
|
||||
#include "lib/res_params.glsl"
|
||||
uniform sampler2D colortex3;
|
||||
// Compute 3x3 min max for TAA
|
||||
|
||||
// uniform sampler2D colortex8;
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -12,35 +14,31 @@ uniform sampler2D colortex3;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:06 */
|
||||
ivec2 center = ivec2(gl_FragCoord.xy);
|
||||
vec3 current = texelFetch2D(colortex3, center, 0).rgb;
|
||||
vec3 cMin = current;
|
||||
vec3 cMax = current;
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, 0), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(-1, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(0, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(0, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, -1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, 0), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
current = texelFetch2D(colortex3, center + ivec2(1, 1), 0).rgb;
|
||||
cMin = min(cMin, current);
|
||||
cMax = max(cMax, current);
|
||||
gl_FragData[0].rgb = cMax;
|
||||
gl_FragData[1].rgb = cMin;
|
||||
|
||||
/* DRAWBUFFERS:6 */
|
||||
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
|
||||
vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.;
|
||||
|
||||
//0.5
|
||||
gl_FragData[0] = texture2D(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
|
||||
|
||||
//0.25
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex3,quarterResTC)*0.125;
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -11,8 +10,9 @@
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
//Improves performances and makes sure bloom radius stays the same at high resolution (>1080p)
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
gl_Position = ftransform();
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
|
||||
#endif
|
||||
//*0.51 to avoid errors when sampling outside since clearing is disabled
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2-1.0;
|
||||
}
|
||||
|
@ -1,452 +1,62 @@
|
||||
#version 120
|
||||
//Temporal Anti-Aliasing + Dynamic exposure calculations (vertex shader)
|
||||
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
//6 Horizontal gaussian blurs and horizontal downsampling
|
||||
#include "lib/res_params.glsl"
|
||||
|
||||
|
||||
//TAA OPTIONS
|
||||
|
||||
const int noiseTextureResolution = 32;
|
||||
|
||||
const int RGBA32F = 1;
|
||||
const int R11F_G11F_B10F = 1;
|
||||
#ifdef SCREENSHOT_MODE
|
||||
const int colortex5Format = RGBA32F; //TAA buffer (everything)
|
||||
#else
|
||||
const int colortex5Format = R11F_G11F_B10F; //TAA buffer (everything)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
const int colortex0Format = RGBA16F; // low res clouds (deferred->composite2) + low res VL (composite5->composite15)
|
||||
const int colortex1Format = RGBA16; //terrain gbuffer (gbuffer->composite2)
|
||||
const int colortex2Format = RGBA16F; //forward + transparencies (gbuffer->composite4)
|
||||
const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6->final)
|
||||
const int colortex4Format = RGBA16F; //light values and skyboxes (everything)
|
||||
|
||||
const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final)
|
||||
const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex8Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex9Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex10Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex13Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
// const int colortex15Format = RGBA16F; // flat normals and vanilla
|
||||
*/
|
||||
//no need to clear the buffers, saves a few fps
|
||||
/*
|
||||
const bool colortex0Clear = false;
|
||||
const bool colortex1Clear = false;
|
||||
const bool colortex2Clear = true;
|
||||
const bool colortex3Clear = false;
|
||||
const bool colortex4Clear = false;
|
||||
const bool colortex5Clear = false;
|
||||
const bool colortex6Clear = false;
|
||||
const bool colortex7Clear = false;
|
||||
*/
|
||||
varying vec2 texcoord;
|
||||
flat varying float exposureA;
|
||||
flat varying float tempOffsets;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex10;
|
||||
uniform sampler2D colortex13;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewHeight;
|
||||
varying vec2 texcoord;
|
||||
uniform float viewWidth;
|
||||
uniform int frameCounter;
|
||||
uniform int framemod8;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
#include "lib/projections.glsl"
|
||||
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets);
|
||||
}
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
dither = center*inversesqrt(abs(center));
|
||||
return clamp(dither-fsign(center),0.0,1.0);
|
||||
}
|
||||
vec3 fp10Dither(vec3 color,float dither){
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
|
||||
|
||||
//returns the projected coordinates of the closest point to the camera in the 3x3 neighborhood
|
||||
vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
|
||||
{
|
||||
vec2 du = vec2(texelSize.x*2., 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y*2.);
|
||||
|
||||
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x);
|
||||
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x);
|
||||
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x);
|
||||
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x);
|
||||
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x);
|
||||
|
||||
vec3 dmin = dmc;
|
||||
dmin = dmin.z > dtr.z? dtr : dmin;
|
||||
dmin = dmin.z > dtl.z? dtl : dmin;
|
||||
dmin = dmin.z > dbl.z? dbl : dmin;
|
||||
dmin = dmin.z > dbr.z? dbr : dmin;
|
||||
#ifdef TAA_UPSCALING
|
||||
dmin.xy = dmin.xy/RENDER_SCALE;
|
||||
#endif
|
||||
return dmin;
|
||||
}
|
||||
|
||||
//Modified texture interpolation from inigo quilez
|
||||
vec4 smoothfilter(in sampler2D tex, in vec2 uv)
|
||||
{
|
||||
vec2 textureResolution = vec2(viewWidth,viewHeight);
|
||||
uv = uv*textureResolution + 0.5;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
|
||||
uv = (uv - 0.5)/textureResolution;
|
||||
return texture2D( tex, uv);
|
||||
}
|
||||
//Due to low sample count we "tonemap" the inputs to preserve colors and smoother edges
|
||||
vec3 weightedSample(sampler2D colorTex, vec2 texcoord){
|
||||
vec3 wsample = texture2D(colorTex,texcoord).rgb*exposureA;
|
||||
return wsample/(1.0+luma(wsample));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//from : https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
||||
vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
||||
// location [1, 1] in the grid, where [0, 0] is the top left corner.
|
||||
vec2 samplePos = uv * texSize;
|
||||
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
|
||||
|
||||
// Compute the fractional offset from our starting texel to our original sample location, which we'll
|
||||
// feed into the Catmull-Rom spline function to get our filter weights.
|
||||
vec2 f = samplePos - texPos1;
|
||||
|
||||
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
|
||||
// These equations are pre-expanded based on our knowledge of where the texels will be located,
|
||||
// which lets us avoid having to evaluate a piece-wise function.
|
||||
vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f));
|
||||
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f);
|
||||
vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) );
|
||||
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
||||
|
||||
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
|
||||
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 offset12 = w2 / (w1 + w2);
|
||||
|
||||
// Compute the final UV coordinates we'll use for sampling the texture
|
||||
vec2 texPos0 = texPos1 - vec2(1.0);
|
||||
vec2 texPos3 = texPos1 + vec2(2.0);
|
||||
vec2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 *= texelSize;
|
||||
texPos3 *= texelSize;
|
||||
texPos12 *= texelSize;
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
//approximation from SMAA presentation from siggraph 2016
|
||||
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount)
|
||||
{
|
||||
vec2 position = rtMetrics.zw * texcoord;
|
||||
vec2 centerPosition = floor(position - 0.5) + 0.5;
|
||||
vec2 f = position - centerPosition;
|
||||
vec2 f2 = f * f;
|
||||
vec2 f3 = f * f2;
|
||||
|
||||
float c = sharpenAmount;
|
||||
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
|
||||
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
|
||||
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
|
||||
vec2 w3 = c * f3 - c * f2;
|
||||
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
|
||||
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
|
||||
|
||||
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
|
||||
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
|
||||
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
|
||||
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
|
||||
vec4(centerColor, 1.0) * (w12.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
|
||||
return color.rgb/color.a;
|
||||
|
||||
}
|
||||
|
||||
vec3 clip_aabb(vec3 q,vec3 aabb_min, vec3 aabb_max)
|
||||
{
|
||||
vec3 p_clip = 0.5 * (aabb_max + aabb_min);
|
||||
vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001;
|
||||
|
||||
vec3 v_clip = q - vec3(p_clip);
|
||||
vec3 v_unit = v_clip.xyz / e_clip;
|
||||
vec3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return vec3(p_clip) + v_clip / ma_unit;
|
||||
else
|
||||
return q;
|
||||
uniform float viewHeight;
|
||||
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY;
|
||||
vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
|
||||
vec4 tot = vec4(0.);
|
||||
float maxTC = 0.25*resScale.x;
|
||||
float minTC = 0.;
|
||||
for (int i = -maxIT;i<maxIT+1;i++){
|
||||
float weight = exp2(-i*i*alpha*4.0);
|
||||
//here we take advantage of bilinear filtering for 2x less sample, as a side effect the gaussian won't be totally centered for small blurs
|
||||
vec2 spCoord = coord+dir*texelSize*(2.0*i+0.5);
|
||||
tot += vec4(texture2D(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.x > minTC && spCoord.x < maxTC);
|
||||
}
|
||||
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
return tot.rgb/max(1.0,tot.a);
|
||||
}
|
||||
|
||||
vec3 tonemap(vec3 col){
|
||||
return col/(1+luma(col));
|
||||
}
|
||||
vec3 invTonemap(vec3 col){
|
||||
return col/(1-luma(col));
|
||||
}
|
||||
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 TAA_hq(bool hand, bool istranslucent){
|
||||
#ifdef TAA_UPSCALING
|
||||
vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.);
|
||||
#else
|
||||
vec2 adjTC = texcoord;
|
||||
#endif
|
||||
|
||||
//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);
|
||||
#endif
|
||||
|
||||
#ifndef CLOSEST_VELOCITY
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x);
|
||||
#endif
|
||||
|
||||
//reproject previous frame
|
||||
vec3 fragposition = toScreenSpace(closestToCamera);
|
||||
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3Prev(previousPosition);
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
//reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
|
||||
return smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
// Interpolating neighboorhood clampling boundaries between pixels
|
||||
vec3 cMax = texture2D(colortex0, adjTC).rgb;
|
||||
vec3 cMin = texture2D(colortex6, adjTC).rgb;
|
||||
#else
|
||||
vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb;
|
||||
vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb;
|
||||
vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb;
|
||||
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
|
||||
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
|
||||
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
|
||||
albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb;
|
||||
#endif
|
||||
|
||||
#ifndef NO_CLIP
|
||||
vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0);
|
||||
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
|
||||
|
||||
//Increases blending factor when far from AABB and in motion, reduces ghosting
|
||||
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5;
|
||||
float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0);
|
||||
|
||||
float test = 0.05;
|
||||
if(hand) movementRejection *= 5;
|
||||
if(istranslucent) test = 0.1;
|
||||
|
||||
//Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
// vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, min(luma(motionVector) *255,1.0),1.)));
|
||||
|
||||
vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, test,1.)));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NO_CLIP
|
||||
vec3 albedoPrev = texture2D(colortex5, previousPosition.xy).xyz;
|
||||
vec3 supersampled = mix(albedoPrev,albedoCurrent0,clamp(0.05,0.,1.));
|
||||
#endif
|
||||
|
||||
//De-tonemap
|
||||
return supersampled;
|
||||
}
|
||||
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
n.xy = abs(encn);
|
||||
n.z = 1.0 - n.x - n.y;
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
vec2 R2_samples(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha * n)*2.-1.0;
|
||||
}
|
||||
vec4 TAA_hq_render(){
|
||||
#ifdef TAA_UPSCALING
|
||||
vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.);
|
||||
#else
|
||||
vec2 adjTC = texcoord;
|
||||
#endif
|
||||
|
||||
//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);
|
||||
#endif
|
||||
|
||||
#ifndef CLOSEST_VELOCITY
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex0,adjTC).x);
|
||||
#endif
|
||||
|
||||
//reproject previous frame
|
||||
vec3 fragposition = toScreenSpace(closestToCamera);
|
||||
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3Prev(previousPosition);
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
// //reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
|
||||
return vec4(smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz, 1.0);
|
||||
|
||||
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz;
|
||||
|
||||
float rej = 0.0;
|
||||
vec4 albedoPrev = texture2D(colortex5, previousPosition.xy);
|
||||
vec3 supersampled = albedoPrev.rgb * albedoPrev.a + albedoCurrent0;
|
||||
|
||||
if (length(velocity) > 1e-6) return vec4(albedoCurrent0,1.0);
|
||||
return vec4(supersampled/(albedoPrev.a+1.0), albedoPrev.a+1.0);
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:6 */
|
||||
|
||||
/* DRAWBUFFERS:5 */
|
||||
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
|
||||
vec2 gaussDir = vec2(1.0,0.0);
|
||||
gl_FragData[0].rgb = vec3(0.0);
|
||||
vec2 tc2 = texcoord*vec2(2.0,1.)/2.;
|
||||
if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0);
|
||||
|
||||
// vec3 motionVector = texture2D(colortex10,texcoord).xyz ;
|
||||
vec2 tc4 = texcoord*vec2(4.0,1.)/2.-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*2.0;
|
||||
if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3);
|
||||
|
||||
// vec3 viewpos = motionVector;
|
||||
// vec3 eyepos = mat3(gbufferModelViewInverse) * viewpos;
|
||||
// vec3 worldPos = eyepos + (cameraPosition + gbufferModelViewInverse[3].xyz);
|
||||
// vec3 feetPos = worldPos - cameraPosition;
|
||||
vec2 tc8 = texcoord*vec2(8.0,1.)/2.-vec2(0.75*resScale.x+8.*texelSize.x,0.)*4.0;
|
||||
if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6);
|
||||
|
||||
// vec4 clippos = gbufferProjection * vec4(viewpos,1.0);
|
||||
vec2 tc16 = texcoord*vec2(8.0,1./2.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*8.0;
|
||||
if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12);
|
||||
|
||||
// vec3 ndcPos = projectAndDivide(gbufferProjectionInverse, viewpos);
|
||||
// vec3 screenPos = ndcPos * 0.5 + 0.5;
|
||||
vec2 tc32 = texcoord*vec2(16.0,1./2.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*16.0;
|
||||
if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28);
|
||||
|
||||
// vec3 movement = ( cameraPosition - previousCameraPosition);
|
||||
vec2 tc64 = texcoord*vec2(32.0,1./2.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*32.0;
|
||||
if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60);
|
||||
|
||||
|
||||
gl_FragData[0].a = 1.0;
|
||||
#ifndef SPLIT_RENDER
|
||||
#ifdef SCREENSHOT_MODE
|
||||
|
||||
|
||||
vec4 color = TAA_hq_render();
|
||||
gl_FragData[0] = color;
|
||||
|
||||
|
||||
#else
|
||||
#ifdef TAA
|
||||
vec4 data = texture2D(colortex1,texcoord* RENDER_SCALE); // terraom
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
|
||||
bool translucentCol = texture2D(colortex13,texcoord * RENDER_SCALE).a > 0.0; // translucents
|
||||
|
||||
|
||||
|
||||
vec3 color = TAA_hq(hand, translucentCol);
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color ,triangularize(R2_dither())),6.11*1e-5,65000.0);
|
||||
#endif
|
||||
|
||||
#ifndef TAA
|
||||
vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.);
|
||||
gl_FragData[0].rgb = color;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SPLIT_RENDER
|
||||
if(texcoord.x > 0.5){
|
||||
|
||||
vec4 color = TAA_hq_render();
|
||||
gl_FragData[0] = color;
|
||||
|
||||
}else{
|
||||
vec4 data = texture2D(colortex1,texcoord* RENDER_SCALE); // terraom
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
|
||||
bool translucentCol = texture2D(colortex13,texcoord * RENDER_SCALE).a > 0.0; // translucents
|
||||
|
||||
|
||||
|
||||
vec3 color = TAA_hq(hand, translucentCol);
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color ,triangularize(R2_dither())),6.11*1e-5,65000.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
||||
|
@ -1,18 +1,21 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
varying vec2 texcoord;
|
||||
flat varying float exposureA;
|
||||
flat varying float tempOffsets;
|
||||
uniform sampler2D colortex4;
|
||||
uniform int frameCounter;
|
||||
#include "/lib/util.glsl"
|
||||
void main() {
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
void main() {
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY;
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
exposureA = texelFetch2D(colortex4,ivec2(10,37),0).r;
|
||||
//0-0.25
|
||||
gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0;
|
||||
//0-0.5
|
||||
gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0;
|
||||
texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.);
|
||||
}
|
||||
|
@ -1,50 +1,62 @@
|
||||
#version 120
|
||||
//downsample 1st pass (half res) for bloom
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
uniform sampler2D colortex5;
|
||||
// uniform sampler2D colortex8;
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
||||
//6 Vertical gaussian blurs and vertical downsampling
|
||||
#include "lib/res_params.glsl"
|
||||
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:3 */
|
||||
|
||||
|
||||
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
|
||||
vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.*resScale/BLOOM_QUALITY;
|
||||
|
||||
// float emissives1 = texture2D(colortex8,quarterResTC).a;
|
||||
// float emissives2 = emissives1 < 1.0 ? emissives1 : 0.0;
|
||||
|
||||
// 0.5
|
||||
gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
|
||||
|
||||
//0.25
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
|
||||
|
||||
//0.125
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125;
|
||||
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0);
|
||||
|
||||
|
||||
uniform sampler2D colortex6;
|
||||
uniform vec2 texelSize;
|
||||
varying vec2 texcoord;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY;
|
||||
vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
|
||||
vec4 tot = vec4(0.);
|
||||
float maxTC = 0.25*resScale.y;
|
||||
float minTC = 0.;
|
||||
for (int i = -maxIT;i<maxIT+1;i++){
|
||||
float weight = exp2(-i*i*alpha*4.0);
|
||||
vec2 spCoord = coord+dir*texelSize*(2.0*i+0.5);
|
||||
tot += vec4(texture2D(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.y > minTC && spCoord.y < maxTC);
|
||||
}
|
||||
return tot.rgb/max(1.0,tot.a);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:6 */
|
||||
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
|
||||
|
||||
vec2 gaussDir = vec2(0.0,1.0);
|
||||
gl_FragData[0].rgb = vec3(0.0);
|
||||
vec2 tc2 = texcoord*vec2(2.0,1.);
|
||||
if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,4.0),gaussDir,0.16,0);
|
||||
|
||||
vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0;
|
||||
if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,2.0),gaussDir,0.16,3);
|
||||
|
||||
vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0;
|
||||
if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6);
|
||||
|
||||
vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.0;
|
||||
if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12);
|
||||
|
||||
vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0;
|
||||
if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30);
|
||||
|
||||
vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.0;
|
||||
if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y)
|
||||
gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60);
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
#version 120
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/res_params.glsl"
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
varying vec2 texcoord;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -10,9 +12,12 @@ uniform float viewHeight;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
//Improves performances and makes sure bloom radius stays the same at high resolution (>1080p)
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY;
|
||||
gl_Position = ftransform();
|
||||
//*0.51 to avoid errors when sampling outside since clearing is disabled
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
|
||||
//0-0.25
|
||||
gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0;
|
||||
//0-0.5
|
||||
gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0;
|
||||
texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.);
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ uniform float rainStrength;
|
||||
uniform float eyeAltitude;
|
||||
uniform float nightVision;
|
||||
uniform vec3 sunVec;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform mat4 gbufferProjection;
|
||||
@ -74,10 +75,39 @@ float R2_dither(){
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y + 1.0/1.6180339887 * frameCounter));
|
||||
return noise;
|
||||
}
|
||||
vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.);
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
#include "lib/volumetricFog.glsl"
|
||||
|
||||
const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0);
|
||||
|
||||
uniform sampler2D depthtex1;//depth
|
||||
// #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)
|
||||
// #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 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
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() {
|
||||
/* DRAWBUFFERS:4 */
|
||||
gl_FragData[0] = vec4(0.0);
|
||||
@ -154,7 +184,7 @@ if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){
|
||||
sky *= vec3(0.0, 0.18, 0.35);
|
||||
#endif
|
||||
|
||||
sky = mix(sky, vec3(0.5,0.5,0.5)*avgSky * 4000., clamp(1 - viewVector.y,0.0,1.0) * rainStrength );
|
||||
// sky = mix(sky, vec3(0.5,0.5,0.5)*avgSky * 4000., clamp(1 - viewVector.y,0.0,1.0) * rainStrength );
|
||||
// sky *= max(abs(viewVector.y+0.05),0.25);
|
||||
gl_FragData[0] = vec4(sky/4000.*Sky_Brightness,1.0);
|
||||
}
|
||||
@ -163,23 +193,24 @@ if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){
|
||||
if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+257.){
|
||||
vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0);
|
||||
vec3 viewVector = cartToSphere(p);
|
||||
vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec3(0.), blueNoise(),sunColorCloud,moonColor,ambientUp,blueNoise());
|
||||
mat2x3 vL = getVolumetricRays(fract(frameCounter/1.6180339887),mat3(gbufferModelView)*viewVector*1024.);
|
||||
float absorbance = dot(vL[1],vec3(0.22,0.71,0.07));
|
||||
|
||||
vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(blueNoise(),R2_dither()), sunColorCloud, moonColor, ambientUp*5.0);
|
||||
vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), ambientUp);
|
||||
|
||||
|
||||
vec3 skytex = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150.;
|
||||
if(viewVector.y < -0.025) skytex = skytex * clamp( exp(viewVector.y) - 1.0,0.25,1.0) ;
|
||||
|
||||
if(viewVector.y < -0.025) skytex = skytex * clamp( exp(viewVector.y - 1.0),0.,1.) ;
|
||||
skytex = skytex*clouds.a + clouds.rgb/5.0;
|
||||
skytex = skytex*VL_Fog.a + VL_Fog.rgb*20;
|
||||
|
||||
skytex = skytex*clouds.a + clouds.rgb;
|
||||
|
||||
// gl_FragData[0] = vec4(skytex,1.0);
|
||||
gl_FragData[0] = vec4(skytex*absorbance+vL[0].rgb,1.0);
|
||||
gl_FragData[0] = vec4(skytex,1.0);
|
||||
}
|
||||
|
||||
//Temporally accumulate sky and light values
|
||||
vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb;
|
||||
vec3 curr = gl_FragData[0].rgb*150.;
|
||||
gl_FragData[0].rgb = clamp(mix(temp,curr,0.06),0.0,65000.);
|
||||
gl_FragData[0].rgb = clamp(mix(temp,curr,0.07),0.0,65000.);
|
||||
|
||||
//Exposure values
|
||||
if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
|
@ -32,6 +32,7 @@ uniform sampler2D colortex6;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform vec3 sunPosition;
|
||||
uniform vec2 texelSize;
|
||||
@ -246,9 +247,4 @@ void main() {
|
||||
exposure = Manual_exposure_value;
|
||||
rodExposure = clamp(log(Manual_exposure_value*2.0+1.0)-0.1,0.0,2.0);
|
||||
#endif
|
||||
float modWT = (worldTime%24000)*1.0;
|
||||
|
||||
float fogAmount0 = 1/3000.+FOG_TOD_MULTIPLIER*(1/100.*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.))*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.)) + 1/120.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.));
|
||||
VFAmount = CLOUDY_FOG_AMOUNT*(fogAmount0*fogAmount0+FOG_RAIN_MULTIPLIER*1.0/20000.*rainStrength);
|
||||
fogAmount = BASE_FOG_AMOUNT*(fogAmount0+max(FOG_RAIN_MULTIPLIER*1/10.*rainStrength , FOG_TOD_MULTIPLIER*1/50.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.)));
|
||||
}
|
@ -4,6 +4,9 @@
|
||||
//Computes volumetric clouds at variable resolution (default 1/4 res)
|
||||
|
||||
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 sunColor;
|
||||
flat varying vec3 moonColor;
|
||||
flat varying vec3 avgAmbient;
|
||||
@ -13,6 +16,7 @@ uniform sampler2D depthtex0;
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
uniform vec3 sunVec;
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
@ -74,26 +78,26 @@ vec3 normVec (vec3 vec){
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
float phi = 2 * 3.14159265359;
|
||||
float noise = fract(fract(frameCounter * (1.0 / phi)) + interleaved_gradientNoise() ) ;
|
||||
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
// vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+(vec2(tempOffsets)*(texelSize/4))*CLOUDS_QUALITY*RENDER_SCALE*0.5);
|
||||
|
||||
vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5);
|
||||
|
||||
float z = texture2D(depthtex0,halfResTC*texelSize).x;
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(halfResTC*texelSize,1));
|
||||
|
||||
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+(vec2(tempOffsets)*(texelSize/4))*CLOUDS_QUALITY*RENDER_SCALE*0.5);
|
||||
vec4 currentClouds = renderClouds(fragpos,vec2(R2_dither(),blueNoise2()), lightCol.rgb/80., moonColor/150., (avgAmbient*2.0)* 8./150./3.);
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(halfResTC*texelSize,1.0));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
gl_FragData[0] = currentClouds;
|
||||
|
||||
|
||||
vec4 currentClouds = renderClouds(fragpos,vec3(0.), R2_dither(),sunColor/150.,moonColor/150.,avgAmbient/150.,blueNoise2());
|
||||
gl_FragData[0] = currentClouds ;
|
||||
|
||||
|
||||
#else
|
||||
#else
|
||||
gl_FragData[0] = vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -5,15 +5,20 @@
|
||||
|
||||
flat varying vec3 sunColor;
|
||||
flat varying vec3 moonColor;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 avgAmbient;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
uniform int frameCounter;
|
||||
@ -36,6 +41,12 @@ void main() {
|
||||
moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb;
|
||||
// avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb;
|
||||
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
|
||||
// ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
// ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
// ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
|
@ -6,8 +6,8 @@
|
||||
entity.1100 = slime giant ender_dragon ghast
|
||||
|
||||
#weak sss (same as weak sss for blocks)
|
||||
entity.1200 = frog sheep chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned elder_gaurdian endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager wither player trader_llama
|
||||
entity.1200 = player frog sheep chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned elder_gaurdian endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager wither trader_llama
|
||||
|
||||
# entity.5000 = minecraft:lightning_bolt
|
||||
entity.9001 = minecraft:boat
|
||||
layer.translucent=slime
|
||||
# entity.9001 = minecraft:boat
|
||||
# layer.translucent=slime
|
||||
|
@ -7,7 +7,7 @@
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D noisetex;
|
||||
// uniform sampler2D noisetex;
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
|
@ -2,15 +2,21 @@
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2DShadow shadow;
|
||||
uniform sampler2D gaux1;
|
||||
uniform sampler2D noisetex;
|
||||
uniform vec3 sunVec;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform float frameTimeCounter;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform vec2 texelSize;
|
||||
uniform float rainStrength;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
@ -19,12 +25,16 @@ uniform mat4 gbufferModelView;
|
||||
uniform mat4 shadowModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
#include "lib/Shadow_Params.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
|
||||
#include "lib/diffuse_lighting.glsl"
|
||||
|
||||
//faster and actually more precise than pow 2.2
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
@ -72,23 +82,11 @@ float shadow2D_bicubic(sampler2DShadow tex, vec3 sc)
|
||||
g1(fuv.y) * (g0x * shadow2D(tex, vec3(p2,sc.z)).x +
|
||||
g1x * shadow2D(tex, vec3(p3,sc.z)).x);
|
||||
}
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
|
||||
float GetCloudShadow(vec3 eyePlayerPos){
|
||||
vec3 worldPos = (eyePlayerPos + cameraPosition) - Cloud_Height;
|
||||
vec3 cloudPos = worldPos*Cloud_Size + WsunVec/abs(WsunVec.y) * ((3250 - 3250*0.35) - worldPos.y*Cloud_Size) ;
|
||||
float shadow = getCloudDensity(cloudPos, 1);
|
||||
// float shadow = (getCloudDensity(cloudPos, 1) + HighAltitudeClouds(cloudPos)) / 2.0;
|
||||
|
||||
shadow = clamp(exp(-shadow*15),0.0,1.0);
|
||||
|
||||
return shadow ;
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -104,28 +102,19 @@ void main() {
|
||||
#endif
|
||||
|
||||
#ifndef WEATHER
|
||||
|
||||
gl_FragData[1].a = 0.0; // for bloomy rain
|
||||
gl_FragData[0] = TEXTURE;
|
||||
vec2 tempOffset = offsets[framemod8];
|
||||
float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
|
||||
gl_FragData[0].rgb = clamp((gl_FragData[0].rgb)*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
|
||||
vec3 albedo = toLinear(gl_FragData[0].rgb);
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
|
||||
vec2 tempOffset = offsets[framemod8];
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
vec3 DirectLightCol = texelFetch2D(gaux1,ivec2(6,37),0).rgb / 127.0;
|
||||
DirectLightCol *= GetCloudShadow(p3);
|
||||
|
||||
vec3 AmbientLight = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * 8.0/150.0/3.0;
|
||||
|
||||
//compute shadows only if not backface
|
||||
float diffuseSun = 0.712;
|
||||
if (diffuseSun > 0.001) {
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
float Shadows = 0.0;
|
||||
vec3 p3_shadow = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3_shadow + shadowModelView[3].xyz;
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
//apply distortion
|
||||
@ -135,19 +124,21 @@ void main() {
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
|
||||
float diffthresh = 0.0002;
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
|
||||
|
||||
float shading = shadow2D_bicubic(shadow,vec3(projectedShadowPosition + vec3(0.0,0.0,-diffthresh*1.2)));
|
||||
DirectLightCol *= shading;
|
||||
}
|
||||
}
|
||||
Shadows += shadow2D_bicubic(shadow,vec3(projectedShadowPosition + vec3(0.0,0.0,-diffthresh*1.2)));
|
||||
|
||||
}
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
Shadows *= GetCloudShadow(p3);
|
||||
#endif
|
||||
|
||||
float phase = phaseg(clamp(dot(np3, WsunVec),0.0,1.0), 0.7) + 0.05 ;
|
||||
float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0);
|
||||
vec3 DirectLight = DirectLightCol * phase * lightleakfix;
|
||||
float phase = phaseg(clamp(dot(np3, WsunVec),0.0,1.0), 0.7) + 1.0 ;
|
||||
vec3 Direct_lighting = DoDirectLighting(lightCol.rgb/80., Shadows, 1.0, 0.0) * phase * lightleakfix;
|
||||
|
||||
gl_FragData[0].rgb = (AmbientLight + DirectLight) * albedo;
|
||||
vec3 Indirect_lighting = DoAmbientLighting(avgAmbient, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.zw, 5.0);
|
||||
|
||||
gl_FragData[0].rgb = (Direct_lighting + Indirect_lighting) * Albedo;
|
||||
#endif
|
||||
}
|
@ -21,7 +21,9 @@ varying vec4 normalMat;
|
||||
#endif
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
@ -53,6 +55,7 @@ void main() {
|
||||
gl_Position = ftransform();
|
||||
color = gl_Color;
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
@ -61,11 +64,13 @@ void main() {
|
||||
|
||||
|
||||
FlatNormals = normalize(gl_NormalMatrix *gl_Normal);
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
|
||||
#endif
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
|
||||
|
||||
flat varying int NameTags;
|
||||
|
||||
#ifndef USE_LUMINANCE_AS_HEIGHTMAP
|
||||
#ifndef MC_NORMAL_MAP
|
||||
@ -41,14 +42,18 @@ varying vec4 NoSeasonCol;
|
||||
varying vec4 seasonColor;
|
||||
uniform float far;
|
||||
varying vec4 normalMat;
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
uniform float wetness;
|
||||
uniform sampler2D normals;
|
||||
uniform sampler2D specular;
|
||||
varying vec3 FlatNormals;
|
||||
#endif
|
||||
|
||||
// #ifdef SPECULARTEX
|
||||
uniform sampler2D specular;
|
||||
// #endif
|
||||
#ifdef POM
|
||||
vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
|
||||
vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
|
||||
@ -67,22 +72,26 @@ uniform vec3 cameraPosition;
|
||||
uniform float rainStrength;
|
||||
uniform sampler2D noisetex;//depth
|
||||
uniform sampler2D depthtex0;
|
||||
in vec3 test_motionVectors;
|
||||
|
||||
in vec3 velocity;
|
||||
|
||||
flat varying float blockID;
|
||||
|
||||
flat varying vec4 TESTMASK;
|
||||
flat varying int EMISSIVE;
|
||||
|
||||
// float interleaved_gradientNoise(){
|
||||
// return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521);
|
||||
// }
|
||||
// float interleaved_gradientNoise(){
|
||||
// vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
// vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
// float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
// return noise;
|
||||
// }
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
@ -133,11 +142,6 @@ vec4 encode (vec3 n, vec2 lightmaps){
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
// vec3 applyBump(mat3 tbnMatrix, vec3 bump){
|
||||
// float bumpmult = 1.0;
|
||||
// bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
// return normalize(bump*tbnMatrix);
|
||||
// }
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){
|
||||
float bumpmult = clamp(puddle_values,0.0,1.0);
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
@ -235,7 +239,7 @@ float densityAtPosSNOW(in vec3 pos){
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
/* RENDERTARGETS: 1,7,8,13,15 */
|
||||
/* RENDERTARGETS: 1,7,8,15 */
|
||||
void main() {
|
||||
|
||||
|
||||
@ -243,6 +247,7 @@ void main() {
|
||||
float noise = fract(fract(frameCounter * (1.0 / phi)) + interleaved_gradientNoise() ) ;
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec3 normal2 = normalMat.xyz;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
@ -250,6 +255,7 @@ void main() {
|
||||
tangent.y, tangent2.y, normal.y,
|
||||
tangent.z, tangent2.z, normal.z);
|
||||
#endif
|
||||
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
@ -293,19 +299,24 @@ void main() {
|
||||
if (dist < MAX_OCCLUSION_DISTANCE) {
|
||||
|
||||
float depthmap = readNormal(vtexcoord.st).a;
|
||||
float used_POM_DEPTH = 1.0;
|
||||
|
||||
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
|
||||
|
||||
// vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH;
|
||||
#ifdef Adaptive_Step_length
|
||||
vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0) ;
|
||||
|
||||
used_POM_DEPTH = 1.0;
|
||||
#else
|
||||
vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH;
|
||||
#endif
|
||||
vec3 coord = vec3(vtexcoord.st, 1.0);
|
||||
coord += interval;
|
||||
|
||||
coord += interval * used_POM_DEPTH;
|
||||
|
||||
float sumVec = 0.5;
|
||||
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) {
|
||||
coord = coord+interval;
|
||||
sumVec += 1;
|
||||
coord = coord+interval * used_POM_DEPTH;
|
||||
sumVec += 1.0 * used_POM_DEPTH;
|
||||
}
|
||||
|
||||
if (coord.t < mincoord) {
|
||||
@ -330,6 +341,10 @@ void main() {
|
||||
|
||||
vec4 Albedo = texture2DGradARB(texture, adjustedTexCoord.xy,dcdx,dcdy) * color;
|
||||
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
#endif
|
||||
|
||||
#ifdef AEROCHROME_MODE
|
||||
vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
|
||||
float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07));
|
||||
@ -355,6 +370,10 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WhiteWorld
|
||||
Albedo.rgb = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_ALPHA_MIPMAPS
|
||||
Albedo.a = texture2DGradARB(texture, adjustedTexCoord.xy,vec2(0.),vec2(0.0)).a;
|
||||
#endif
|
||||
@ -379,6 +398,10 @@ void main() {
|
||||
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0);
|
||||
|
||||
normal = applyBump(tbnMatrix,NormalTex, mix(1.0,Puddle_shape,rainfall));
|
||||
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) normal = vec3(1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
@ -393,20 +416,28 @@ void main() {
|
||||
|
||||
vec4 data1 = clamp(encode(viewToWorld(normal), lmtexcoord.zw),0.,1.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x),encodeVec2(Albedo.y,data1.y),encodeVec2(Albedo.z,data1.z),encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
gl_FragData[1].a = 0.0;
|
||||
#else
|
||||
|
||||
#else
|
||||
float bias = Texture_MipMap_Bias - blueNoise()*0.5;
|
||||
////////////////////////////////
|
||||
//////////////////////////////// NORMAL
|
||||
////////////////////////////////
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
vec4 NormalTex = texture2D(normals, lmtexcoord.xy, bias).rgba;
|
||||
NormalTex.xy = NormalTex.xy*2.0-1.0;
|
||||
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ;
|
||||
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1.0-Puddle_shape,rainfall) );
|
||||
|
||||
// #ifdef ENTITIES
|
||||
// if(NameTags == 1 || NameTags == 2) normal = normal2;
|
||||
// #endif
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) normal = vec3(1);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -414,18 +445,27 @@ void main() {
|
||||
//////////////////////////////// SPECULAR
|
||||
////////////////////////////////
|
||||
|
||||
vec4 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
vec4 SpecularTex = texture2D(specular, lmtexcoord.xy, bias);
|
||||
|
||||
SpecularTex.r = max(SpecularTex.r, Puddle_shape);
|
||||
SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.04);
|
||||
|
||||
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) SpecularTex = vec4(0.0);
|
||||
#endif
|
||||
|
||||
gl_FragData[2] = SpecularTex;
|
||||
|
||||
if(EMISSIVE > 0) gl_FragData[2].a = 0.9;
|
||||
|
||||
////////////////////////////////
|
||||
//////////////////////////////// ALBEDO
|
||||
////////////////////////////////
|
||||
|
||||
vec4 Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
vec4 Albedo = texture2D(texture, lmtexcoord.xy, bias) * color;
|
||||
|
||||
// pain in my ass
|
||||
|
||||
#ifdef AEROCHROME_MODE
|
||||
vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
|
||||
@ -473,6 +513,7 @@ void main() {
|
||||
else Albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAND
|
||||
if (Albedo.a > 0.1) Albedo.a = 0.75;
|
||||
else Albedo.a = 0.0;
|
||||
@ -482,18 +523,18 @@ void main() {
|
||||
//////////////////////////////// FINALIZE
|
||||
////////////////////////////////
|
||||
|
||||
// #ifndef ENTITIES
|
||||
// if(TESTMASK.r==255) Albedo.rgb = vec3(0);
|
||||
// #endif
|
||||
|
||||
vec4 data1 = clamp(blueNoise()/255.0 + encode(viewToWorld(normal), lmtexcoord.zw),0.0,1.0);
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + lmtexcoord.zw), 0.0, 1.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
#ifdef WORLD
|
||||
gl_FragData[1].a = 0.0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
gl_FragData[4] = vec4(FlatNormals* 0.5 + 0.5,VanillaAO);
|
||||
gl_FragData[5].x = 0;
|
||||
|
||||
#ifdef ENTITIES
|
||||
gl_FragData[5].xyz = velocity *0.5+0.5;
|
||||
#endif
|
||||
|
||||
gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5,VanillaAO);
|
||||
}
|
@ -2,6 +2,13 @@
|
||||
#include "lib/settings.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef USE_LUMINANCE_AS_HEIGHTMAP
|
||||
#ifndef MC_NORMAL_MAP
|
||||
@ -13,23 +20,18 @@
|
||||
#define MC_NORMAL_MAP
|
||||
#endif
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
uniform int worldDay;
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying float VanillaAO;
|
||||
varying vec4 NoSeasonCol;
|
||||
varying vec4 normalMat;
|
||||
#ifdef POM
|
||||
varying vec4 vtexcoordam; // .st for add, .pq for mul
|
||||
varying vec4 vtexcoord;
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
varying vec4 NoSeasonCol;
|
||||
varying float VanillaAO;
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 normalMat;
|
||||
|
||||
#ifdef POM
|
||||
varying vec4 vtexcoordam; // .st for add, .pq for mul
|
||||
varying vec4 vtexcoord;
|
||||
#endif
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
@ -37,9 +39,6 @@ varying vec4 vtexcoord;
|
||||
varying vec3 FlatNormals;
|
||||
#endif
|
||||
|
||||
out vec3 test_motionVectors;
|
||||
in vec3 at_velocity;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
const float PI48 = 150.796447372*WAVY_SPEED;
|
||||
float pi2wt = PI48*frameTimeCounter;
|
||||
@ -47,12 +46,15 @@ float pi2wt = PI48*frameTimeCounter;
|
||||
attribute vec4 mc_Entity;
|
||||
uniform int blockEntityId;
|
||||
uniform int entityId;
|
||||
flat varying int EMISSIVE;
|
||||
|
||||
flat varying float blockID;
|
||||
flat varying vec4 TESTMASK;
|
||||
flat varying int lightningBolt;
|
||||
|
||||
flat varying int NameTags;
|
||||
|
||||
in vec3 at_velocity;
|
||||
out vec3 velocity;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
@ -126,8 +128,8 @@ vec3 blackbody2(float Temp)
|
||||
// return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
// }
|
||||
|
||||
#define SEASONS_VSH
|
||||
#include "/lib/climate_settings.glsl"
|
||||
#define SEASONS_VSH
|
||||
#include "/lib/climate_settings.glsl"
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -136,17 +138,31 @@ vec3 blackbody2(float Temp)
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
NameTags = 0;
|
||||
|
||||
velocity = at_velocity;
|
||||
|
||||
// emission and shit...
|
||||
EMISSIVE = 0;
|
||||
#ifndef LabPBR_Emissives
|
||||
if(mc_Entity.x == 10005) EMISSIVE = 1;
|
||||
#endif
|
||||
|
||||
#ifdef SPIDEREYES
|
||||
// gl_Position.xy = gl_Position.xy * 0.9 + 0.9 * gl_Position.w - gl_Position.w;
|
||||
if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1);
|
||||
EMISSIVE = 1;
|
||||
#endif
|
||||
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
FlatNormals = normalize(gl_NormalMatrix * gl_Normal);
|
||||
TESTMASK = vec4(normalize(gl_NormalMatrix * gl_Normal), 1.0);
|
||||
|
||||
TESTMASK.r = blockEntityId == 222 ? 255 : TESTMASK.r;
|
||||
|
||||
blockID = mc_Entity.x;
|
||||
|
||||
#ifdef ENTITIES
|
||||
test_motionVectors = at_velocity;
|
||||
#endif
|
||||
|
||||
#ifdef POM
|
||||
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
@ -156,15 +172,17 @@ void main() {
|
||||
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
|
||||
#endif
|
||||
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
|
||||
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
VanillaAO = 1.0 - clamp(color.a,0,1);
|
||||
if (color.a < 0.3) color.a = 1.0; // fix vanilla ao on some custom block models.
|
||||
|
||||
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
@ -180,15 +198,20 @@ void main() {
|
||||
normalMat.a = entityId == 1200 ? 0.65 : normalMat.a;
|
||||
#endif
|
||||
#endif
|
||||
// normalMat.a = 0.45;
|
||||
|
||||
normalMat.a = 0.45;
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
|
||||
|
||||
// try and single out nametag text and then discard nametag background
|
||||
if( dot(gl_Color.rgb, vec3(0.35)) < 1.0) NameTags = 1;
|
||||
|
||||
if(gl_Color.a >= 0.24 && gl_Color.a <= 0.25 ) gl_Position = vec4(10,10,10,1);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef WORLD
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),mc_Entity.x == 10004 || mc_Entity.x == 10003 ? 0.5 : mc_Entity.x == 10001 ? 0.6 : 1.0);
|
||||
@ -200,10 +223,12 @@ void main() {
|
||||
normalMat.a = (mc_Entity.x == 10007 || mc_Entity.x == 10008) ? 0.55 : normalMat.a; // 0.55 abnormal block strong sss
|
||||
#endif
|
||||
|
||||
normalMat.a = mc_Entity.x == 10005 ? 0.8 : normalMat.a;
|
||||
// normalMat.a = mc_Entity.x == 10005 ? 0.8 : normalMat.a;
|
||||
|
||||
|
||||
#ifdef WAVY_PLANTS
|
||||
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
|
||||
|
||||
if ((mc_Entity.x == 10001 && istopv) && abs(position.z) < 64.0) {
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
worldpos.xyz += calcMovePlants(worldpos.xyz)*lmtexcoord.w - cameraPosition;
|
||||
@ -223,26 +248,10 @@ void main() {
|
||||
}
|
||||
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SEPARATE_AO
|
||||
|
||||
// #if indirect_effect == 1 || indirect_effect == 0
|
||||
// lmtexcoord.zw *= sqrt(color.a);
|
||||
// #endif
|
||||
|
||||
#else
|
||||
color.rgb *= color.a;
|
||||
#endif
|
||||
|
||||
// if (mc_Entity.x == 10099 ) seasonColor.rgb = (gl_Color.rgb * blackbody2(sin(frameTimeCounter)*12000 + 14000)) * (1.0 - floor(luma(gl_Color.rgb)+(1.0/255.)));
|
||||
|
||||
#endif
|
||||
|
||||
// seasonColor = color;
|
||||
NoSeasonCol.rgb = gl_Color.rgb;
|
||||
|
||||
#ifdef Seasons
|
||||
#ifndef BLOCKENTITIES
|
||||
#ifndef ENTITIES
|
||||
|
@ -9,7 +9,6 @@ uniform sampler2D normals;
|
||||
varying vec3 tangent;
|
||||
varying vec4 tangent_other;
|
||||
varying vec3 viewVector;
|
||||
varying float dist;
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
@ -18,11 +17,13 @@ varying float dist;
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2DShadow shadow;
|
||||
uniform sampler2D gaux2;
|
||||
uniform sampler2D gaux1;
|
||||
// uniform sampler2D gaux2;
|
||||
// uniform sampler2D gaux1;
|
||||
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
uniform vec4 lightCol;
|
||||
uniform float nightVision;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
@ -50,6 +51,8 @@ uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
|
||||
|
||||
@ -62,6 +65,9 @@ uniform int isEyeInWater;
|
||||
#include "lib/stars.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
|
||||
#include "lib/diffuse_lighting.glsl"
|
||||
|
||||
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
@ -141,7 +147,7 @@ vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){
|
||||
for (int i = 0; i <= int(quality); i++) {
|
||||
#ifdef USE_QUARTER_RES_DEPTH
|
||||
// decode depth buffer
|
||||
float sp = sqrt(texelFetch2D(gaux1,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
sp = invLinZ(sp);
|
||||
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
@ -181,14 +187,15 @@ float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
|
||||
#define PW_DEPTH 0.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 1 //[2 4 6 8 16 32]
|
||||
#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 2 //[2 4 6 8 16 32]
|
||||
#define bayer4(a) (bayer2( .5*(a))*.25+bayer2(a))
|
||||
#define bayer8(a) (bayer4( .5*(a))*.25+bayer2(a))
|
||||
#define bayer16(a) (bayer8( .5*(a))*.25+bayer2(a))
|
||||
#define bayer32(a) (bayer16(.5*(a))*.25+bayer2(a))
|
||||
#define bayer64(a) (bayer32(.5*(a))*.25+bayer2(a))
|
||||
#define bayer128(a) fract(bayer64(.5*(a))*.25+bayer2(a))
|
||||
|
||||
vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) {
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
@ -316,19 +323,45 @@ vec4 encode (vec3 n, vec2 lightmaps){
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
float g(float NdotL, float roughness){
|
||||
float alpha = square(max(roughness, 0.02));
|
||||
return 2.0 * NdotL / (NdotL + sqrt(square(alpha) + (1.0 - square(alpha)) * square(NdotL)));
|
||||
}
|
||||
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
vec3 GGX2_2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
vec3 GGX2(vec3 n, vec3 v, vec3 l, float r, vec3 F0,float fresnel) {
|
||||
float alpha = square(r) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
vec3 h = normalize(l + v) ;
|
||||
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
float D = alpha / (2.2 * square( (dotNH * alpha - 1.0) * square(dotNH) + 1.0) );
|
||||
|
||||
vec3 F = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
|
||||
return F * D;
|
||||
}
|
||||
// float SunGGX(vec3 n, vec3 v, vec3 l, float Roughness, float F0){
|
||||
|
||||
// vec3 h = normalize(l + v) ;
|
||||
|
||||
// float dotNH = clamp(dot(h,n),0.,1.);
|
||||
// float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
// float alpha =max(square(Roughness),1e-4) ;
|
||||
|
||||
// float WallFresnel = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
// float Sun = square( dotNH - pow(alpha,1.5) - 1.0);
|
||||
|
||||
// float Final = ((alpha / (10.0 * Sun + 1e-4)) * WallFresnel);
|
||||
|
||||
// return Final ;
|
||||
// }
|
||||
float SunGGX(vec3 n, vec3 v, vec3 l, float roughness,float F0, float fresnel){
|
||||
|
||||
float roughness = r;
|
||||
|
||||
float alpha = square(roughness) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
@ -343,11 +376,39 @@ vec3 GGX2(vec3 n, vec3 v, vec3 l, float r, vec3 F0,float fresnel) {
|
||||
|
||||
float D = alpha / (0.0541592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
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 = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
|
||||
float k2 = .25 * r;
|
||||
|
||||
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
|
||||
}
|
||||
|
||||
|
||||
vec3 pixelCoord (vec3 Coordinates, int Resolution){
|
||||
return floor(Coordinates / Resolution) * Resolution;
|
||||
}
|
||||
#define PHYSICSMOD_FRAGMENT
|
||||
#include "/lib/oceans.glsl"
|
||||
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -360,32 +421,30 @@ void main() {
|
||||
float iswater = normalMat.w;
|
||||
vec3 fragC = gl_FragCoord.xyz*vec3(texelSize,1.0);
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy,-5)*color;
|
||||
// float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
|
||||
// gl_FragData[0].rgb = clamp((gl_FragData[0].rgb)*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
|
||||
|
||||
vec3 albedo = toLinear(gl_FragData[0].rgb);
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy,Texture_MipMap_Bias)*color;
|
||||
float alphalabede = gl_FragData[0].a;
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
//pain
|
||||
|
||||
#ifdef HAND
|
||||
iswater = 0.1;
|
||||
#endif
|
||||
|
||||
#ifndef Vanilla_like_water
|
||||
if (iswater > 0.4) {
|
||||
albedo = vec3(1.0);
|
||||
gl_FragData[0] = vec4(0.42,0.6,0.7,0.7);
|
||||
}
|
||||
if (iswater > 0.9) {
|
||||
gl_FragData[0] = vec4(vec3(0.0),1./255.);
|
||||
Albedo = vec3(0.0);
|
||||
gl_FragData[0] = vec4(vec3(0.0),1.0/255.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Vanilla_like_water
|
||||
if (iswater > 0.5) {
|
||||
gl_FragData[0].a = luma(albedo.rgb);
|
||||
albedo = color.rgb;
|
||||
gl_FragData[0].a = luma(Albedo.rgb);
|
||||
Albedo = color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
gl_FragData[4] = vec4(albedo, gl_FragData[0].a);
|
||||
|
||||
gl_FragData[4] = vec4(Albedo, gl_FragData[0].a);
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
|
||||
@ -393,47 +452,73 @@ void main() {
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
vec3 WaterNormals;
|
||||
vec3 TranslucentNormals;
|
||||
|
||||
if (iswater > 0.4){
|
||||
|
||||
if(physics_iterationsNormal < 1.0){
|
||||
float bumpmult = 1.;
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
posxz.xz-=posxz.y;
|
||||
|
||||
vec3 bump;
|
||||
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
|
||||
posxz.xz -= posxz.y;
|
||||
|
||||
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos)) ;
|
||||
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos));
|
||||
|
||||
bump = normalize(getWaveHeight(posxz.xz,iswater));
|
||||
WaterNormals = bump; // tangent space normals for refraction
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
normal = normalize(bump * tbnMatrix);
|
||||
}else {
|
||||
|
||||
|
||||
}else{
|
||||
vec3 PhysicsMod_normal = physics_waveNormal(physics_localPosition.xz, physics_localWaviness, physics_gameTime);
|
||||
|
||||
normal = normalize(worldToView(PhysicsMod_normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0)));
|
||||
|
||||
vec3 worldSpaceNormal = normal;
|
||||
|
||||
vec3 bitangent = normalize(cross(tangent, worldSpaceNormal));
|
||||
mat3 tbn_new = mat3(tangent, binormal, worldSpaceNormal);
|
||||
vec3 tangentSpaceNormal = (worldSpaceNormal * tbn_new);
|
||||
|
||||
WaterNormals = tangentSpaceNormal ;
|
||||
}
|
||||
|
||||
}else{
|
||||
vec3 normalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgb;
|
||||
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0);
|
||||
|
||||
TranslucentNormals = normalTex;
|
||||
|
||||
normal = applyBump(tbnMatrix,normalTex);
|
||||
|
||||
}
|
||||
|
||||
TranslucentNormals += WaterNormals;
|
||||
vec4 data0 = vec4(1);
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), lmtexcoord.zw),0.0,1.0);
|
||||
vec4 data1 = clamp( encode(TranslucentNormals, lmtexcoord.zw),0.0,1.0);
|
||||
gl_FragData[3] = vec4(encodeVec2(data0.x,data1.x), encodeVec2(data0.y,data1.y), encodeVec2(data0.z,data1.z), encodeVec2(data1.w,data0.w));
|
||||
gl_FragData[5] = vec4(encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a));
|
||||
|
||||
float NdotL = lightSign*dot(normal,sunVec);
|
||||
float NdotU = dot(upVec,normal);
|
||||
float diffuseSun = clamp(NdotL,0.0f,1.0f);
|
||||
diffuseSun = clamp((-15 + diffuseSun*255.0) / 240.0 ,0.0,1.0);
|
||||
|
||||
vec3 direct = texelFetch2D(gaux1,ivec2(6,37),0).rgb/127.0;
|
||||
|
||||
#ifdef ambientLight_only
|
||||
direct = vec3(0);
|
||||
#endif
|
||||
float NdotL = clamp(lightSign*dot(normal,sunVec) ,0.0,1.0);
|
||||
NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0);
|
||||
|
||||
|
||||
float shading = 1.0;
|
||||
|
||||
float Shadows = 1.0;
|
||||
float cloudShadow = 1.0;
|
||||
//compute shadows only if not backface
|
||||
if (diffuseSun > 0.001) {
|
||||
if (NdotL > 0.001) {
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
@ -444,134 +529,127 @@ void main() {
|
||||
//do shadows only if on shadow map
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
|
||||
float distortThresh = (sqrt(1.0-diffuseSun*diffuseSun)/diffuseSun+0.7)/distortFactor;
|
||||
float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor;
|
||||
float diffthresh = distortThresh/6000.0*threshMul;
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
|
||||
|
||||
shading = 0.0;
|
||||
Shadows = 0.0;
|
||||
float noise = blueNoise();
|
||||
float rdMul = 4.0/shadowMapResolution;
|
||||
|
||||
for(int i = 0; i < 9; i++){
|
||||
vec2 offsetS = tapLocation(i,9, 1.618,noise,0.0);
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
shading += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0;
|
||||
Shadows += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0;
|
||||
}
|
||||
direct *= shading;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
vec3 campos = (p3 + cameraPosition)-319 ;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
// cloudShadow = exp(-cloudShadow*sqrt(cloudDensity)*25);
|
||||
|
||||
cloudShadow = clamp(exp(-cloudShadow*10),0,1);
|
||||
|
||||
// make these turn to zero when occluded by the cloud shadow
|
||||
direct *= cloudShadow;
|
||||
#endif
|
||||
Shadows *= GetCloudShadow(p3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
vec3 ambientLight = (texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * 2.0) * 8./150./3.;
|
||||
// vec3 ambientLight = (texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * 2.0) * 8./150./3.;
|
||||
|
||||
direct *= (iswater > 0.9 ? 0.2: 1.0)*diffuseSun*lmtexcoord.w;
|
||||
// direct *= (iswater > 0.9 ? 0.2: 1.0)*NdotL*lmtexcoord.w;
|
||||
|
||||
vec3 directLight = direct;
|
||||
// vec3 directLight = direct;
|
||||
vec3 WS_normal = viewToWorld(normal);
|
||||
vec3 ambientCoefs = WS_normal/dot(abs(WS_normal),vec3(1.));
|
||||
float skylight = clamp(abs(ambientCoefs.y+1),0.35,2.0) ;
|
||||
|
||||
vec3 color = vec3(0);
|
||||
vec3 Indirect_lighting = DoAmbientLighting(avgAmbient, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.zw, skylight);
|
||||
vec3 Direct_lighting = DoDirectLighting(lightCol.rgb/80.0, Shadows, NdotL, 0.0);
|
||||
|
||||
vec3 FinalColor = (Direct_lighting + Indirect_lighting) * Albedo;
|
||||
|
||||
color += ambientLight ;
|
||||
color += directLight;
|
||||
// if (iswater > 0.9) FinalColor = Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
float alphashit = min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
color *= alphashit;
|
||||
FinalColor *= alphashit;
|
||||
#endif
|
||||
|
||||
color *= albedo;
|
||||
|
||||
vec2 specularstuff = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
specularstuff = iswater > 0.0 && specularstuff.r > 0.0 && specularstuff.g < 0.9 ? specularstuff : vec2(1.0,0.02);
|
||||
vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
SpecularTex = iswater > 0.0 && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02);
|
||||
|
||||
if (iswater > 0.0){
|
||||
|
||||
float roughness = pow(1.0-specularstuff.r,2.0);
|
||||
float f0 = 0;
|
||||
if (iswater > 0.0 && (SpecularTex.g > 0.0 || SpecularTex.r > 0.0)){
|
||||
vec3 Reflections_Final = vec3(0.0);
|
||||
float roughness = max(pow(1.0-SpecularTex.r,2.0),0.1);
|
||||
float f0 = SpecularTex.g;
|
||||
|
||||
float F0 = f0;
|
||||
|
||||
vec3 reflectedVector = reflect(normalize(fragpos), normal);
|
||||
float normalDotEye = dot(normal, normalize(fragpos));
|
||||
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0);
|
||||
// float unchangedfresnel = fresnel;
|
||||
|
||||
// snells window looking thing
|
||||
if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0);
|
||||
|
||||
fresnel = mix(F0, 1.0, fresnel);
|
||||
if(isEyeInWater == 1 && physics_iterationsNormal > 0.0) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0);
|
||||
|
||||
// fresnel = mix(F0, 1.0, fresnel);
|
||||
fresnel = F0 + (1.0 - F0) * fresnel;
|
||||
float indoors = clamp((lmtexcoord.w-0.6)*5.0, 0.0,1.0);
|
||||
vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector;
|
||||
|
||||
vec3 sky_c = skyCloudsFromTex(wrefl,gaux1).rgb / 150. * 5. ;
|
||||
sky_c.rgb *= indoors;
|
||||
// SSR, Sky, and Sun reflections
|
||||
vec4 Reflections = vec4(0.0);
|
||||
vec3 SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 150. * 5.;
|
||||
vec3 SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, f0);
|
||||
// vec3 SunReflection = Direct_lighting * SunGGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, f0, fresnel);
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / F0) * -4),0,1);
|
||||
|
||||
sky_c = mix(sky_c,color,(1.0-indoors)) ;
|
||||
|
||||
vec4 reflection = vec4(0.);
|
||||
if(iswater > 0.0){
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1);
|
||||
if (rtPos.z <1.){
|
||||
if (rtPos.z < 1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
reflection.a = 1.0;
|
||||
reflection.rgb = texture2D(gaux2,previousPosition.xy).rgb;
|
||||
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1);
|
||||
|
||||
if(isEyeInWater == 1 ) sky_c.rgb = color.rgb*lmtexcoord.w;
|
||||
Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a);
|
||||
Reflections_Final = mix(FinalColor, Reflections_Final, fresnel * visibilityFactor);
|
||||
Reflections_Final += SunReflection;
|
||||
|
||||
reflection.rgb = mix(sky_c.rgb, reflection.rgb, reflection.a);
|
||||
|
||||
vec3 sunSpec = shading*directLight * GGX2(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0), fresnel) ;
|
||||
|
||||
sunSpec *= max(cloudShadow-0.5,0.0);
|
||||
|
||||
vec3 reflected = reflection.rgb*fresnel + sunSpec ;
|
||||
|
||||
// reflected = vec3(0);
|
||||
gl_FragData[0].rgb = Reflections_Final;
|
||||
|
||||
//correct alpha channel with fresnel
|
||||
float alpha0 = gl_FragData[0].a;
|
||||
// //correct alpha channel with fresnel
|
||||
gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel;
|
||||
gl_FragData[0].rgb = clamp(color/gl_FragData[0].a*alpha0*(1.0-fresnel)*0.1+reflected/gl_FragData[0].a*0.1,0.0,65100.0);
|
||||
|
||||
|
||||
|
||||
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
|
||||
|
||||
#ifdef BorderFog
|
||||
float fog = 1.0 - clamp( exp2(-pow(length(fragpos / far),10.)*3.0) ,0.0,1.0);
|
||||
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, fog);
|
||||
#endif
|
||||
// //suffering
|
||||
// #ifdef SPIDEREYES
|
||||
// gl_FragData[0].rgb = Albedo.rgb * 10;
|
||||
// #endif
|
||||
|
||||
} else {
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
}
|
||||
else
|
||||
gl_FragData[0].rgb = color*.1;
|
||||
|
||||
gl_FragData[1] = vec4(albedo,iswater);
|
||||
#ifndef HAND
|
||||
gl_FragData[1] = vec4(Albedo,iswater);
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
varying vec3 tangent;
|
||||
varying float dist;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
varying vec3 viewVector;
|
||||
|
||||
@ -26,6 +25,7 @@ attribute vec4 at_tangent;
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
uniform vec3 sunPosition;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform float sunElevation;
|
||||
@ -33,7 +33,7 @@ uniform float sunElevation;
|
||||
varying vec4 tangent_other;
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
|
||||
uniform vec2 texelSize;
|
||||
@ -51,6 +51,17 @@ uniform int framemod8;
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PHYSICSMOD_VERTEX
|
||||
#include "/lib/oceans.glsl"
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -58,25 +69,42 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 Swtich_gl_vertex = gl_Vertex;
|
||||
|
||||
if(physics_iterationsNormal > 0.0){
|
||||
// basic texture to determine how shallow/far away from the shore the water is
|
||||
physics_localWaviness = texelFetch(physics_waviness, ivec2(gl_Vertex.xz) - physics_textureOffset, 0).r;
|
||||
// transform gl_Vertex (since it is the raw mesh, i.e. not transformed yet)
|
||||
vec4 finalPosition = vec4(gl_Vertex.x, gl_Vertex.y + physics_waveHeight(gl_Vertex.xz, PHYSICS_ITERATIONS_OFFSET, physics_localWaviness, physics_gameTime), gl_Vertex.z, gl_Vertex.w);
|
||||
// pass this to the fragment shader to fetch the texture there for per fragment normals
|
||||
physics_localPosition = finalPosition.xyz;
|
||||
|
||||
Swtich_gl_vertex.xyz = finalPosition.xyz ;
|
||||
}
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
gl_Position = toClipSpace3(position);
|
||||
color = gl_Color;
|
||||
float mat = 0.0;
|
||||
|
||||
if(mc_Entity.x == 8.0 || mc_Entity.x == 9.0) {
|
||||
mat = 1.0;
|
||||
|
||||
gl_Position.z -= 1e-4;
|
||||
}
|
||||
|
||||
|
||||
if (mc_Entity.x == 10002) mat = 0.01;
|
||||
if (mc_Entity.x == 10002) mat = 0.2;
|
||||
if (mc_Entity.x == 72) mat = 0.5;
|
||||
|
||||
// if (mc_Entity.x == 8) mat = 0.1;
|
||||
#ifdef ENTITIES
|
||||
mat = 0.2;
|
||||
#endif
|
||||
|
||||
|
||||
normalMat = vec4(normalize( gl_NormalMatrix*gl_Normal),mat);
|
||||
|
||||
@ -91,9 +119,7 @@ void main() {
|
||||
tangent.y, binormal.y, normalMat.y,
|
||||
tangent.z, binormal.z, normalMat.z);
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
viewVector = ( gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
viewVector = ( gl_ModelViewMatrix * Swtich_gl_vertex).xyz;
|
||||
viewVector = normalize(tbnMatrix * viewVector);
|
||||
|
||||
|
||||
@ -112,4 +138,6 @@ void main() {
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
}
|
||||
|
@ -1,35 +1,8 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
// #define ENTITIES
|
||||
// #define BLOCKENTITIES
|
||||
// #define WORLD
|
||||
#define SPIDEREYES
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D gaux1;
|
||||
|
||||
//faster and actually more precise than pow 2.2
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
/* DRAWBUFFERS:2 */
|
||||
void main() {
|
||||
|
||||
vec4 Albedo = texture2D(texture, lmtexcoord.xy)*color;
|
||||
Albedo.a = 1.0;
|
||||
|
||||
float exposure = texelFetch2D(gaux1,ivec2(10,37),0).r;
|
||||
Albedo.rgb *= 25.0 ;
|
||||
Albedo.rgb *= clamp(0.5-exposure,0.05,1.0);
|
||||
|
||||
|
||||
gl_FragData[0] = Albedo;
|
||||
|
||||
}
|
||||
#include "gbuffers_all_solid.fsh"
|
@ -1,57 +1,8 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
// #define ENTITIES
|
||||
// #define BLOCKENTITIES
|
||||
// #define WORLD
|
||||
#define SPIDEREYES
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
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//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
gl_Position = ftransform();
|
||||
color = gl_Color;
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
|
||||
#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
|
||||
}
|
||||
#include "gbuffers_all_solid.vsh"
|
@ -1,6 +1,6 @@
|
||||
#version 120
|
||||
|
||||
|
||||
// #define WORLD
|
||||
#define WORLD
|
||||
#define ENTITIES
|
||||
#include "gbuffers_all_solid.vsh"
|
@ -1,4 +1,5 @@
|
||||
#version 120
|
||||
|
||||
#define WORLD
|
||||
#define HAND
|
||||
#include "gbuffers_all_solid.fsh"
|
@ -1,4 +1,5 @@
|
||||
#version 120
|
||||
|
||||
#define HAND
|
||||
// #define WORLD
|
||||
#include "gbuffers_all_translucent.fsh"
|
@ -1,4 +1,5 @@
|
||||
#version 120
|
||||
|
||||
#define HAND
|
||||
// #define WORLD
|
||||
#include "gbuffers_all_translucent.vsh"
|
@ -1,24 +1,7 @@
|
||||
#version 120
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
/* RENDERTARGETS:0 */
|
||||
|
||||
/* RENDERTARGETS:12 */
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
//faster and actually more precise than pow 2.2
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
|
||||
uniform sampler2D texture;
|
||||
void main() {
|
||||
|
||||
gl_FragData[0] = texture2D(texture,texcoord.xy)*color;
|
||||
gl_FragData[0].rgb = gl_FragData[0].rgb*gl_FragData[0].a;
|
||||
discard;
|
||||
}
|
||||
|
@ -1,38 +1,5 @@
|
||||
#version 120
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
|
||||
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() {
|
||||
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
|
||||
|
||||
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -1,32 +1,8 @@
|
||||
#version 120
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
// #define ENTITIES
|
||||
// #define BLOCKENTITIES
|
||||
// #define WORLD
|
||||
#define SPIDEREYES
|
||||
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform sampler2D texture;
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texcoord);
|
||||
|
||||
albedo *= color;
|
||||
albedo.rgb = toLinear(albedo.rgb)*0.33;
|
||||
/* DRAWBUFFERS:2 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
}
|
||||
#include "gbuffers_all_solid.fsh"
|
@ -1,37 +1,8 @@
|
||||
#version 120
|
||||
#include "/lib/res_params.glsl"
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
// #define ENTITIES
|
||||
// #define BLOCKENTITIES
|
||||
// #define WORLD
|
||||
#define SPIDEREYES
|
||||
|
||||
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() {
|
||||
|
||||
|
||||
texcoord = (gl_MultiTexCoord0).xy;
|
||||
color = gl_Color;
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
#include "gbuffers_all_solid.vsh"
|
@ -1,9 +1,9 @@
|
||||
option.indirect_effect = Indirect Lighting
|
||||
value.indirect_effect.0 = Vanilla AO
|
||||
value.indirect_effect.1 = SSAO
|
||||
value.indirect_effect.2 = RTAO
|
||||
value.indirect_effect.3 = SSGI
|
||||
value.indirect_effect.4 = SSDO
|
||||
value.indirect_effect.2 = GTAO
|
||||
value.indirect_effect.3 = RTAO
|
||||
value.indirect_effect.4 = SSGI
|
||||
|
||||
option.ambient_colortype = Coloring Type
|
||||
value.ambient_colortype.0 = Temperature
|
||||
|
186
shaders/lib/PhotonGTAO.glsl
Normal file
186
shaders/lib/PhotonGTAO.glsl
Normal file
@ -0,0 +1,186 @@
|
||||
|
||||
// Common constants
|
||||
|
||||
const float eps = 1e-6;
|
||||
const float e = exp(1.0);
|
||||
const float tau = 2.0 * pi;
|
||||
const float half_pi = 0.5 * pi;
|
||||
const float rcp_pi = 1.0 / pi;
|
||||
const float degree = tau / 360.0; // Size of one degree in radians, useful because radians() is not a constant expression on all platforms
|
||||
const float golden_ratio = 0.5 + 0.5 * sqrt(5.0);
|
||||
const float golden_angle = tau / golden_ratio / golden_ratio;
|
||||
const float hand_depth = 0.56;
|
||||
|
||||
#if defined TAA && defined TAAU
|
||||
const float taau_render_scale = TAAU_RENDER_SCALE;
|
||||
#else
|
||||
const float taau_render_scale = 1.0;
|
||||
#endif
|
||||
|
||||
// Helper functions
|
||||
|
||||
#define rcp(x) (1.0 / (x))
|
||||
#define clamp01(x) clamp(x, 0.0, 1.0) // free on operation output
|
||||
#define max0(x) max(x, 0.0)
|
||||
#define min1(x) min(x, 1.0)
|
||||
|
||||
float sqr(float x) { return x * x; }
|
||||
vec2 sqr(vec2 v) { return v * v; }
|
||||
vec3 sqr(vec3 v) { return v * v; }
|
||||
vec4 sqr(vec4 v) { return v * v; }
|
||||
|
||||
float cube(float x) { return x * x * x; }
|
||||
|
||||
float max_of(vec2 v) { return max(v.x, v.y); }
|
||||
float max_of(vec3 v) { return max(v.x, max(v.y, v.z)); }
|
||||
float max_of(vec4 v) { return max(v.x, max(v.y, max(v.z, v.w))); }
|
||||
float min_of(vec2 v) { return min(v.x, v.y); }
|
||||
float min_of(vec3 v) { return min(v.x, min(v.y, v.z)); }
|
||||
float min_of(vec4 v) { return min(v.x, min(v.y, min(v.z, v.w))); }
|
||||
|
||||
float length_squared(vec2 v) { return dot(v, v); }
|
||||
float length_squared(vec3 v) { return dot(v, v); }
|
||||
|
||||
vec2 normalize_safe(vec2 v) { return v == vec2(0.0) ? v : normalize(v); }
|
||||
vec3 normalize_safe(vec3 v) { return v == vec3(0.0) ? v : normalize(v); }
|
||||
|
||||
float rcp_length(vec2 v) { return inversesqrt(dot(v, v)); }
|
||||
float rcp_length(vec3 v) { return inversesqrt(dot(v, v)); }
|
||||
|
||||
float fast_acos(float x) {
|
||||
const float C0 = 1.57018;
|
||||
const float C1 = -0.201877;
|
||||
const float C2 = 0.0464619;
|
||||
|
||||
float res = (C2 * abs(x) + C1) * abs(x) + C0; // p(x)
|
||||
res *= sqrt(1.0 - abs(x));
|
||||
|
||||
return x >= 0 ? res : pi - res; // Undo range reduction
|
||||
}
|
||||
vec2 fast_acos(vec2 v) { return vec2(fast_acos(v.x), fast_acos(v.y)); }
|
||||
|
||||
uniform vec2 view_res;
|
||||
uniform vec2 view_pixel_size;
|
||||
|
||||
float linear_step(float edge0, float edge1, float x) {
|
||||
return clamp01((x - edge0) / (edge1 - edge0));
|
||||
}
|
||||
|
||||
vec2 linear_step(vec2 edge0, vec2 edge1, vec2 x) {
|
||||
return clamp01((x - edge0) / (edge1 - edge0));
|
||||
}
|
||||
|
||||
vec4 project(mat4 m, vec3 pos) {
|
||||
return vec4(m[0].x, m[1].y, m[2].zw) * pos.xyzz + m[3];
|
||||
}
|
||||
vec3 project_and_divide(mat4 m, vec3 pos) {
|
||||
vec4 homogenous = project(m, pos);
|
||||
return homogenous.xyz / homogenous.w;
|
||||
}
|
||||
|
||||
vec3 screen_to_view_space(vec3 screen_pos, bool handle_jitter) {
|
||||
vec3 ndc_pos = 2.0 * screen_pos - 1.0;
|
||||
|
||||
return project_and_divide(gbufferProjectionInverse, ndc_pos);
|
||||
}
|
||||
|
||||
vec3 view_to_screen_space(vec3 view_pos, bool handle_jitter) {
|
||||
vec3 ndc_pos = project_and_divide(gbufferProjection, view_pos);
|
||||
|
||||
|
||||
return ndc_pos * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------
|
||||
// ambient occlusion
|
||||
// ---------------------
|
||||
|
||||
#define GTAO_SLICES 2
|
||||
#define GTAO_HORIZON_STEPS 3
|
||||
#define GTAO_RADIUS 2.0
|
||||
#define GTAO_FALLOFF_START 0.75
|
||||
|
||||
float integrate_arc(vec2 h, float n, float cos_n) {
|
||||
vec2 tmp = cos_n + 2.0 * h * sin(n) - cos(2.0 * h - n);
|
||||
return 0.25 * (tmp.x + tmp.y);
|
||||
}
|
||||
|
||||
float calculate_maximum_horizon_angle(
|
||||
vec3 view_slice_dir,
|
||||
vec3 viewer_dir,
|
||||
vec3 screen_pos,
|
||||
vec3 view_pos,
|
||||
float dither
|
||||
) {
|
||||
const float step_size = GTAO_RADIUS * rcp(float(GTAO_HORIZON_STEPS));
|
||||
|
||||
float max_cos_theta = -1.0;
|
||||
|
||||
vec2 ray_step = (view_to_screen_space(view_pos + view_slice_dir * step_size, true) - screen_pos).xy;
|
||||
vec2 ray_pos = screen_pos.xy + ray_step * (dither + max_of(view_pixel_size) * rcp_length(ray_step));
|
||||
|
||||
|
||||
for (int i = 0; i < GTAO_HORIZON_STEPS; ++i, ray_pos += ray_step) {
|
||||
float depth = texelFetch(depthtex1, ivec2(clamp(ray_pos,0.0,1.0) * view_res * taau_render_scale - 0.5), 0).x;
|
||||
|
||||
if (depth == 1.0 || depth < hand_depth || depth == screen_pos.z) continue;
|
||||
|
||||
vec3 offset = screen_to_view_space(vec3(ray_pos, depth), true) - view_pos;
|
||||
|
||||
float len_sq = length_squared(offset);
|
||||
float norm = inversesqrt(len_sq);
|
||||
|
||||
float distance_falloff = linear_step(GTAO_FALLOFF_START * GTAO_RADIUS, GTAO_RADIUS, len_sq * norm);
|
||||
|
||||
float cos_theta = dot(viewer_dir, offset) * norm;
|
||||
cos_theta = mix(cos_theta, -1.0, distance_falloff);
|
||||
|
||||
max_cos_theta = max(cos_theta, max_cos_theta);
|
||||
}
|
||||
|
||||
return fast_acos(clamp(max_cos_theta, -1.0, 1.0));
|
||||
}
|
||||
|
||||
float ambient_occlusion(vec3 screen_pos, vec3 view_pos, vec3 view_normal, vec2 dither , inout vec3 debug) {
|
||||
float ao = 0.0;
|
||||
vec3 bent_normal = vec3(0.0);
|
||||
|
||||
// Construct local working space
|
||||
vec3 viewer_dir = normalize(-view_pos);
|
||||
vec3 viewer_right = normalize(cross(vec3(0.0, 1.0, 0.0), viewer_dir));
|
||||
vec3 viewer_up = cross(viewer_dir, viewer_right);
|
||||
mat3 local_to_view = mat3(viewer_right, viewer_up, viewer_dir);
|
||||
|
||||
for (int i = 0; i < GTAO_SLICES; ++i) {
|
||||
float slice_angle = (i + dither.x) * (pi / float(GTAO_SLICES));
|
||||
|
||||
vec3 slice_dir = vec3(cos(slice_angle), sin(slice_angle), 0.0);
|
||||
vec3 view_slice_dir = local_to_view * slice_dir;
|
||||
|
||||
vec3 ortho_dir = slice_dir - dot(slice_dir, viewer_dir) * viewer_dir;
|
||||
vec3 axis = cross(slice_dir, viewer_dir);
|
||||
|
||||
vec3 projected_normal = view_normal - axis * dot(view_normal, axis);
|
||||
|
||||
float len_sq = dot(projected_normal, projected_normal);
|
||||
float norm = inversesqrt(len_sq);
|
||||
|
||||
float sgn_gamma = sign(dot(ortho_dir, projected_normal));
|
||||
float cos_gamma = clamp01(dot(projected_normal, viewer_dir) * norm);
|
||||
float gamma = sgn_gamma * fast_acos(cos_gamma);
|
||||
|
||||
vec2 max_horizon_angles;
|
||||
max_horizon_angles.x = calculate_maximum_horizon_angle(-view_slice_dir, viewer_dir, screen_pos, view_pos, dither.y);
|
||||
max_horizon_angles.y = calculate_maximum_horizon_angle( view_slice_dir, viewer_dir, screen_pos, view_pos, dither.y);
|
||||
|
||||
max_horizon_angles = gamma + clamp(vec2(-1.0, 1.0) * max_horizon_angles - gamma, -half_pi, half_pi);
|
||||
|
||||
vec3 max_horizon_angles2 = mat3(gbufferModelViewInverse) * projected_normal;
|
||||
|
||||
ao += integrate_arc(max_horizon_angles, gamma, cos_gamma) * len_sq * norm * max_horizon_angles.y;
|
||||
}
|
||||
|
||||
ao *= rcp(float(GTAO_SLICES));
|
||||
return ao;
|
||||
}
|
@ -3,8 +3,10 @@
|
||||
|
||||
|
||||
uniform float Day;
|
||||
uniform float worldDay;
|
||||
|
||||
// it's so symmetrical~
|
||||
|
||||
float day0 = clamp(clamp(Day, 0.0,1.0)*clamp(2-Day, 0.0,1.0),0.0,1.0);
|
||||
float day1 = clamp(clamp(Day-1, 0.0,1.0)*clamp(3-Day, 0.0,1.0),0.0,1.0);
|
||||
float day2 = clamp(clamp(Day-2, 0.0,1.0)*clamp(4-Day, 0.0,1.0),0.0,1.0);
|
||||
@ -23,23 +25,36 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
/////////////////////////////////////////////////////////////////////////////// VERTEX SHADER
|
||||
#ifdef Seasons
|
||||
#ifdef SEASONS_VSH
|
||||
|
||||
varying vec4 seasonColor;
|
||||
|
||||
void YearCycleColor (
|
||||
inout vec3 FinalColor,
|
||||
vec3 glcolor
|
||||
){
|
||||
// colors for things that arent leaves and using the tint index.
|
||||
vec3 SummerCol = vec3(Summer_R, Summer_G, Summer_B) * glcolor;
|
||||
vec3 AutumnCol = vec3(Fall_R, Fall_G, Fall_B) * glcolor;
|
||||
vec3 SummerCol = vec3(Summer_R, Summer_G, Summer_B);
|
||||
vec3 AutumnCol = vec3(Fall_R, Fall_G, Fall_B);
|
||||
vec3 WinterCol = vec3(Winter_R, Winter_G, Winter_B) ;
|
||||
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B) * glcolor;
|
||||
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B);
|
||||
|
||||
// decide if you want to replace biome colors or tint them.
|
||||
SummerCol *= glcolor;
|
||||
AutumnCol *= glcolor;
|
||||
WinterCol *= glcolor;
|
||||
SpringCol *= glcolor;
|
||||
|
||||
// do leaf colors different because thats cool and i like it
|
||||
if(mc_Entity.x == 10003){
|
||||
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B) * glcolor;
|
||||
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B) * glcolor;
|
||||
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B) ;
|
||||
SpringCol = vec3(Spring_Leaf_R, Spring_Leaf_G, Spring_Leaf_B)* glcolor;
|
||||
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B);
|
||||
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B);
|
||||
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B);
|
||||
SpringCol = vec3(Spring_Leaf_R, Spring_Leaf_G, Spring_Leaf_B);
|
||||
|
||||
SummerCol *= glcolor;
|
||||
AutumnCol *= glcolor;
|
||||
WinterCol *= glcolor;
|
||||
SpringCol *= glcolor;
|
||||
}
|
||||
|
||||
// length of each season in minecraft days
|
||||
@ -64,7 +79,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
bool IsTintIndex = floor(dot(glcolor,vec3(0.5))) < 1.0;
|
||||
|
||||
// multiply final color by the final lerped color, because it contains all the other colors.
|
||||
if (IsTintIndex && mc_Entity.x != 200) FinalColor = SpringToSummer;
|
||||
FinalColor = SpringToSummer;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -107,7 +122,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
#ifdef Daily_Weather
|
||||
Coverage += day0 * 0.3 + day1 * 0.8 + day2 * 0.2 + day3 * 0.0 + day4 * 0.8 + day5 * 0.5 + day6 * -0.5 + day7 * 0.6;
|
||||
#else
|
||||
Coverage += cloudCoverage;
|
||||
Coverage += mix(Cumulus_coverage, Rain_coverage, rainStrength);
|
||||
// Coverage = mix(Coverage, Rain_coverage, rainStrength);
|
||||
#endif
|
||||
|
||||
@ -138,7 +153,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
Thickness = CirrusThickness;
|
||||
}
|
||||
#else
|
||||
Coverage = 0.5;
|
||||
Coverage = 0.7;
|
||||
Thickness = 0.05;
|
||||
#endif
|
||||
|
||||
@ -187,7 +202,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
BiomeColors.b = isSwamps*0.35 + isJungles*0.8;
|
||||
|
||||
// insure the biome colors are locked to the fog shape and lighting, but not its orignal color.
|
||||
BiomeColors *= dot(FinalFogColor,vec3(0.5));
|
||||
BiomeColors *= dot(FinalFogColor,vec3(0.33));
|
||||
|
||||
// these range 0.0-1.0. they will never overlap.
|
||||
float Inbiome = isJungles+isSwamps;
|
||||
@ -204,8 +219,8 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
float Inbiome = isJungles+isSwamps;
|
||||
|
||||
vec2 BiomeFogDensity; // x = uniform || y = cloudy
|
||||
BiomeFogDensity.x = isSwamps*5 + isJungles*5;
|
||||
BiomeFogDensity.y = isSwamps*50 + isJungles*2;
|
||||
BiomeFogDensity.x = isSwamps*1 + isJungles*5;
|
||||
BiomeFogDensity.y = isSwamps*5 + isJungles*2;
|
||||
|
||||
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome);
|
||||
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome);
|
||||
@ -229,8 +244,9 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
float Night = clamp((Time-13000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
|
||||
|
||||
// set densities. morn, noon, even, night
|
||||
vec4 UniformDensity = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 CloudyDensity = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 UniformDensity = TOD_Fog_mult * vec4(Morning_Uniform_Fog, Noon_Uniform_Fog, Evening_Uniform_Fog, Night_Uniform_Fog);
|
||||
vec4 CloudyDensity = TOD_Fog_mult * vec4(Morning_Cloudy_Fog, Noon_Cloudy_Fog, Evening_Cloudy_Fog, Night_Cloudy_Fog);
|
||||
|
||||
|
||||
#ifdef Daily_Weather
|
||||
DailyWeather_FogDensity(UniformDensity, CloudyDensity); // let daily weather influence fog densities.
|
||||
|
61
shaders/lib/diffuse_lighting.glsl
Normal file
61
shaders/lib/diffuse_lighting.glsl
Normal file
@ -0,0 +1,61 @@
|
||||
// in this here file im doing all the lighting for sunlight, ambient light, torches, for solids and translucents.
|
||||
|
||||
//// OVERWORLD ////
|
||||
|
||||
vec3 DoAmbientLighting (vec3 SkyColor, vec3 TorchColor, vec2 Lightmap, float skyLightDir){
|
||||
// Lightmap.x = 0.0;
|
||||
// Lightmap.y = 1.0;
|
||||
|
||||
SkyColor = SkyColor * 2.0 * ambient_brightness;
|
||||
|
||||
|
||||
vec3 TorchLight = TorchColor * pow(1.0-pow(1.0-clamp(Lightmap.x,0.0,1.0) ,0.1),2);
|
||||
TorchLight = exp(TorchLight * 30) - 1.0;
|
||||
|
||||
|
||||
// vec3 SkyLight = max((SkyColor * 8./150./3.) * pow(Lightmap.y,3.0) , vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)) ;
|
||||
vec3 SkyLight = max((SkyColor * 8./150./3.) * pow(Lightmap.y,3.0),0.0) ;
|
||||
|
||||
|
||||
return SkyLight * skyLightDir + TorchLight;
|
||||
}
|
||||
|
||||
vec3 DoDirectLighting(vec3 SunColor, float Shadow, float NdotL, float SubsurfaceScattering){
|
||||
|
||||
// vec3 SunLight = max(NdotL * Shadow, SubsurfaceScattering) * SunColor;
|
||||
vec3 SunLight = NdotL * Shadow * SunColor;
|
||||
|
||||
return SunLight;
|
||||
}
|
||||
|
||||
|
||||
//// NETHER ////
|
||||
vec3 DoAmbientLighting_Nether(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3, vec3 WorldPos){
|
||||
|
||||
vec3 TorchLight = TorchColor * clamp(pow(Lightmap,3.0),0.0,1.0);
|
||||
|
||||
|
||||
|
||||
vec3 LavaGlow = vec3(TORCH_R,TORCH_G,TORCH_B);
|
||||
LavaGlow *= pow(clamp(1.0-max(Normal.y,0.0) + dot(Normal,np3),0.0,1.0),3.0);
|
||||
LavaGlow *= clamp(exp2(-max((WorldPos.y - 50.0) / 5,0.0)),0.0,1.0);
|
||||
LavaGlow *= pow(Lightmap,0.2);
|
||||
|
||||
vec3 AmbientLight = vec3(0.1) + FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0);
|
||||
|
||||
return AmbientLight + TorchLight + LavaGlow;
|
||||
}
|
||||
//// END ////
|
||||
vec3 DoAmbientLighting_End(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3){
|
||||
|
||||
// vec3 TorchLight = TorchColor * clamp(pow(Lightmap,3.0),0.0,1.0);
|
||||
vec3 TorchLight = TorchColor * pow(1.0-pow(1.0-clamp(Lightmap,0.0,1.0) ,0.1),2);
|
||||
TorchLight = exp(TorchLight * 30) - 1.0;
|
||||
|
||||
|
||||
FogColor = (FogColor / pow(0.00001 + dot(FogColor,vec3(0.3333)),1.0) ) * 0.1;
|
||||
// vec3 AmbientLight = sqrt( clamp(1.25 + dot(Normal,np3),0.0,1.0)) * (vec3(0.5,0.75,1.0) * 0.05);
|
||||
vec3 AmbientLight = sqrt( clamp(1.25 + dot(Normal,np3),0.0,1.0)*0.5) * FogColor;
|
||||
|
||||
return TorchLight + AmbientLight;
|
||||
}
|
346
shaders/lib/end_fog.glsl
Normal file
346
shaders/lib/end_fog.glsl
Normal file
@ -0,0 +1,346 @@
|
||||
vec3 srgbToLinear2(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
}
|
||||
vec3 blackbody2(float Temp)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp(col,0.0,1.0);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
|
||||
return srgbToLinear2(col);
|
||||
}
|
||||
|
||||
|
||||
// Integer Hash - II
|
||||
// - Inigo Quilez, Integer Hash - II, 2017
|
||||
// https://www.shadertoy.com/view/XlXcW4
|
||||
uvec3 iqint2(uvec3 x)
|
||||
{
|
||||
const uint k = 1103515245u;
|
||||
|
||||
x = ((x>>8U)^x.yzx)*k;
|
||||
x = ((x>>8U)^x.yzx)*k;
|
||||
x = ((x>>8U)^x.yzx)*k;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
uvec3 hash(vec2 s)
|
||||
{
|
||||
|
||||
uvec4 u = uvec4(s, uint(s.x) ^ uint(s.y), uint(s.x) + uint(s.y)); // Play with different values for 3rd and 4th params. Some hashes are okay with constants, most aren't.
|
||||
|
||||
return iqint2(u.xyz);
|
||||
}
|
||||
vec3 hash31(float p)
|
||||
{
|
||||
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yzx+33.33);
|
||||
return fract((p3.xxy+p3.yzz)*p3.zyx);
|
||||
}
|
||||
|
||||
// uniform float ifEndBoss;
|
||||
// uniform float isSneaking;
|
||||
|
||||
// uniform float EndSequence1;
|
||||
// uniform float EndSequence2;
|
||||
|
||||
|
||||
// position related stuff
|
||||
// vec2 SEED = vec2(sin(frameTimeCounter*5) + 1);
|
||||
// uvec3 HASH = hash(SEED);
|
||||
// vec3 RandomPosition = clamp(vec3(HASH) * (1.0/float(0xffffffffu)), 0.0, 1.0);
|
||||
vec3 RandomPosition = hash31(1);
|
||||
|
||||
|
||||
// vec3 ManualLightPos = vec3(109.25, 128.73, 1189.4) ;
|
||||
// vec3 ManualLightPos = vec3(307.96, 141.00, 1107.05) - vec3(sin(frameTimeCounter), 0, -cos(frameTimeCounter))*25;
|
||||
// ManualLightPos -= vec3(sin(frameTimeCounter), 0, -cos(frameTimeCounter))*100;
|
||||
|
||||
vec3 ManualLightPos = vec3(ORB_X, ORB_Y, ORB_Z);
|
||||
|
||||
///////////////// POSITION
|
||||
///////////////// POSITION
|
||||
///////////////// POSITION
|
||||
vec3 LightSourcePosition(vec3 WorldPos, vec3 CameraPos){
|
||||
|
||||
vec3 Origin = WorldPos ;
|
||||
vec3 RandomPosition2 = hash31(Origin.y);
|
||||
// make the swirl only happen within a radius
|
||||
float SwirlBounds = clamp(sqrt(length(vec3(Origin.x,Origin.y-100,Origin.z)) / 150.0 - 1.0) ,0.0,1.0);
|
||||
|
||||
if( SwirlBounds < 1.0) {
|
||||
Origin.y -= 200;
|
||||
} else {
|
||||
Origin = WorldPos - cameraPosition - ManualLightPos ;
|
||||
// Origin -= RandomPosition * 100;
|
||||
}
|
||||
|
||||
#ifdef THE_ORB
|
||||
Origin = WorldPos - ManualLightPos;
|
||||
#endif
|
||||
|
||||
return Origin;
|
||||
}
|
||||
|
||||
///////////////// COLOR
|
||||
///////////////// COLOR
|
||||
///////////////// COLOR
|
||||
vec3 LightSourceColor(float SwirlBounds){
|
||||
|
||||
vec3 Color = vec3(0.0);
|
||||
|
||||
if( SwirlBounds < 1.0) {
|
||||
|
||||
//////// STAGE 1
|
||||
Color = vec3(0.5, 0.5, 1.0);
|
||||
|
||||
//////// STAGE 2
|
||||
|
||||
// Color = mix(Color, vec3(1.0,0.3,0.3), pow(EndSequence1,3.0));
|
||||
|
||||
// //////// STAGE 3
|
||||
// // yes rico, kaboom
|
||||
// Color = mix(Color, vec3(1.0,0.0,1.0) * (1.0-EndSequence2), EndSequence2);
|
||||
|
||||
} else {
|
||||
|
||||
// Color = vec3(0.6, 0.8 ,1.0);
|
||||
Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult;
|
||||
|
||||
// float Timing = dot(RandomPosition, vec3(1.0/3.0));
|
||||
|
||||
// float Flash = max(sin(frameTimeCounter*10) * Timing,0.0);
|
||||
// Color *= blackbody2(RandomPosition.y*4000 + 1000);
|
||||
// Color *= Flash;
|
||||
|
||||
}
|
||||
|
||||
#ifdef THE_ORB
|
||||
Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult;
|
||||
#endif
|
||||
|
||||
return Color;
|
||||
}
|
||||
|
||||
///////////////// SHAPE
|
||||
///////////////// SHAPE
|
||||
///////////////// SHAPE
|
||||
vec3 LightSourceShape(vec3 WorldPos){
|
||||
|
||||
vec3 Shapes = vec3(0.0);
|
||||
vec3 Origin = WorldPos ;
|
||||
|
||||
// make the swirl only happen within a radius
|
||||
float SwirlBounds = clamp(sqrt(length(Origin) / 200.0 - 1.0) ,0.0,1.0);
|
||||
|
||||
if( SwirlBounds < 1.0) {
|
||||
|
||||
// vec3 Origin = WorldPos;
|
||||
Origin.y -= 200;
|
||||
|
||||
vec3 Origin2 = Origin;
|
||||
Origin2.y += 100 ;
|
||||
Origin2.y *= 0.8;
|
||||
|
||||
float Center = length(Origin);
|
||||
float AltCenter = length(Origin2);
|
||||
|
||||
//////// STAGE 1
|
||||
// when the ender dragon is alive, restrict the fog in this shape
|
||||
// the max of a sphere is another smaller sphere. this creates a hollow sphere.
|
||||
Shapes.r = max(1.0 - AltCenter / 75.0, max(AltCenter / 150.0 - 1.0, 0.0));
|
||||
|
||||
float radius = 200.0;
|
||||
float thickness = 50.0 * radius;
|
||||
Shapes.r = (thickness - clamp(pow(sqrt(pow(Origin2.x,2) + pow(Origin2.z,2)) - radius,2) + pow(Origin2.y*0.75,2.0) - radius,0,thickness)) / thickness ;
|
||||
|
||||
Shapes.r = max(Shapes.r, max(1.0 - AltCenter / 75.0, 0.0));
|
||||
|
||||
radius = 50.0;
|
||||
thickness = 5.0 * radius;
|
||||
Shapes.b = (thickness - clamp(pow(sqrt(pow(Origin2.x,2) + pow(Origin2.y,2)) - radius,2) + pow(Origin2.z*0.75,2.0) - radius,0,thickness)) / thickness ;
|
||||
}
|
||||
|
||||
return Shapes;
|
||||
}
|
||||
|
||||
|
||||
float densityAtPosFog(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
|
||||
f = (f*f) * (3.-2.*f);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
float cloudVol(in vec3 pos, int LOD){
|
||||
|
||||
|
||||
// THE OOOOOOOOOOOOOOOOOOOOOORB
|
||||
vec3 Shapes = LightSourceShape(pos);
|
||||
|
||||
vec3 samplePos = pos*vec3(1.0,1./32.,1.0);
|
||||
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
// #ifndef THE_ORB
|
||||
// ender dragon battle area swirling effect.
|
||||
// if(EndSequence2 < 1.0){
|
||||
float radiance = 2.39996 + samplePos.y + frameTimeCounter/10;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
// make the swirl only happen within a radius
|
||||
float SwirlBounds = clamp(sqrt(length(vec3(pos.x,pos.y-100,pos.z)) / 200.0 - 1.0) ,0.0,1.0);
|
||||
|
||||
samplePos.xz = mix(samplePos.xz * rotationMatrix, samplePos.xz, SwirlBounds);
|
||||
samplePos2.xz = mix(samplePos2.xz * rotationMatrix, samplePos2.xz, SwirlBounds);
|
||||
// }
|
||||
// #endif
|
||||
|
||||
samplePos2.y -= frameTimeCounter/15;
|
||||
|
||||
float finalfog = 0;
|
||||
|
||||
finalfog += max(0.6-densityAtPosFog(samplePos * 16.0) * 2,0.0);
|
||||
// finalfog = exp(finalfog*5)-1;
|
||||
|
||||
float smallnoise = max(densityAtPosFog(samplePos2 * (160. - finalfog*3))-0.1,0.0);
|
||||
finalfog -= ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.3;
|
||||
|
||||
// make the eye of the swirl have no fog, so you can actually see.
|
||||
finalfog = max(finalfog - Shapes.r, 0.0);
|
||||
|
||||
// dragon death sequence
|
||||
// finalfog = Shapes.b;
|
||||
|
||||
|
||||
return finalfog;
|
||||
}
|
||||
|
||||
|
||||
mat2x3 getVolumetricRays(float dither,vec3 fragpos,float dither2) {
|
||||
int SAMPLES = 16;
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = vec3(0.0);
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = (fragposition-start);
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
|
||||
float maxLength = min(length(dVWorld),32.0 * 12.0)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
vec3 vL = vec3(0.);
|
||||
float dL = length(dVWorld);
|
||||
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float expFactor = 11.0;
|
||||
|
||||
vec3 fogColor = (gl_Fog.color.rgb / pow(dot(gl_Fog.color.rgb,vec3(0.3333)),1.1) ) ;
|
||||
|
||||
|
||||
for (int i=0;i<SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
float densityVol = cloudVol(progressW,1);
|
||||
float density = min(densityVol,0.1);
|
||||
float air = 0.005;
|
||||
|
||||
/// THE OOOOOOOOOOOOOOOOOOOOOORB
|
||||
vec3 LightColor = LightSourceColor(clamp(sqrt(length(vec3(progressW.x,progressW.y-100,progressW.z)) / 150.0 - 1.0) ,0.0,1.0));
|
||||
|
||||
vec3 LightPos = LightSourcePosition(progressW, cameraPosition);
|
||||
// float OrbMie = exp(length(LightPos) * -0.03) * 64.0;
|
||||
|
||||
// float OrbMie = max(exp2(4.0 + length(LightPos) / -20),0.0);
|
||||
|
||||
|
||||
float OrbMie = max(1.0-length(LightPos)/200,0.0);
|
||||
float N = 2.50;
|
||||
OrbMie = pow(1.0-pow(1.0-OrbMie,1.0/N),N);
|
||||
OrbMie *= 10.0;
|
||||
// LightColor *= OrbMie;
|
||||
|
||||
float CastLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = progressW - LightPos * (pow(j+dither2/3,0.75)*0.3);
|
||||
// vec3 shadowSamplePos = progressW - LightPos * (pow(j+dither2,0.75)*0.25);
|
||||
|
||||
float densityVol2 = cloudVol(shadowSamplePos,1);
|
||||
CastLight += densityVol2;
|
||||
}
|
||||
|
||||
|
||||
vec3 CastedLight = LightColor * OrbMie * exp(CastLight * 15 * (LightColor*(1.0-CastLight/3)-1.50)) ;
|
||||
CastedLight += (LightColor * vec3(1.0,1.3,1.0)) * exp(abs(densityVol*2.0 - 0.3) * 15 * (LightColor*CastLight)) * (max(OrbMie - density*10,0.0)/10);
|
||||
|
||||
#ifdef THE_ORB
|
||||
density += clamp((1.0 - length(LightPos) / 10.0) * 10 ,0.0,1.0) ;
|
||||
InnerLight = vec3(0.0);
|
||||
#endif
|
||||
|
||||
vec3 AmbientLight = fogColor * 0.05 * pow(exp(density * -2),20);
|
||||
|
||||
vec3 vL0 = AmbientLight + CastedLight;
|
||||
|
||||
vec3 vL1 = vec3(0.5,0.75,1.0) * 0.05 ;
|
||||
// vL1 += (LightColor* vec3(1.0,1.3,1.0)) * max(LightColor - (exp(CastLight * 5)-OrbMie),0.0) * OrbMie;
|
||||
|
||||
vL += (vL0 - vL0*exp(-density*dd*dL)) * absorbance;
|
||||
vL += (vL1 - vL1*exp(-air*dd*dL)) * absorbance;
|
||||
|
||||
absorbance *= exp(-(density+air)*dd*dL);
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
}
|
||||
|
||||
float GetCloudShadow(vec3 WorldPos, vec3 LightPos, float noise){
|
||||
float Shadow = 0.0;
|
||||
|
||||
for (int i=0; i < 3; i++){
|
||||
|
||||
vec3 shadowSamplePos = WorldPos - LightPos * (0.25 + pow(i,0.75)*0.25);
|
||||
float Cast = cloudVol(shadowSamplePos,1);
|
||||
Shadow += Cast;
|
||||
}
|
||||
|
||||
return clamp(exp(-Shadow*5),0.0,1.0);
|
||||
// return (Shadow);
|
||||
}
|
||||
float GetCloudShadow2(vec3 WorldPos){
|
||||
|
||||
float Shadow = cloudVol(WorldPos,1);
|
||||
|
||||
return clamp( exp2(Shadow * -3),0.0,1.0);
|
||||
}
|
168
shaders/lib/nether_fog.glsl
Normal file
168
shaders/lib/nether_fog.glsl
Normal file
@ -0,0 +1,168 @@
|
||||
///////////////// POSITION
|
||||
///////////////// POSITION
|
||||
///////////////// POSITION
|
||||
|
||||
vec3 ManualLightPos = vec3(ORB_X, ORB_Y, ORB_Z);
|
||||
|
||||
vec3 lighting_pos = vec3(0, -1, 0);
|
||||
|
||||
vec3 lightSource = normalize(lighting_pos);
|
||||
vec3 viewspace_sunvec = mat3(gbufferModelView) * lightSource;
|
||||
vec3 WsunVec = normalize(mat3(gbufferModelViewInverse) * viewspace_sunvec);
|
||||
|
||||
|
||||
|
||||
///////////////// COLOR
|
||||
///////////////// COLOR
|
||||
///////////////// COLOR
|
||||
vec3 LightSourceColor(){
|
||||
|
||||
vec3 Color = vec3(1.0,0.75,0.5);
|
||||
|
||||
return Color;
|
||||
}
|
||||
|
||||
///////////////// SHAPE
|
||||
///////////////// SHAPE
|
||||
///////////////// SHAPE
|
||||
vec3 LightSourceShape(vec3 WorldPos){
|
||||
|
||||
vec3 Shapes = vec3(0.0);
|
||||
vec3 Origin = WorldPos ;
|
||||
|
||||
return Shapes;
|
||||
}
|
||||
|
||||
|
||||
float densityAtPosFog(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
|
||||
f = (f*f) * (3.-2.*f);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
|
||||
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
|
||||
// vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
// float fog_shape = 1-densityAtPosFog(samplePos * 16.0);
|
||||
// float fog_eroded = 1-densityAtPosFog(samplePos2 * (200 + fog_shape*25));
|
||||
|
||||
// float finalfog = clamp( (fog_shape*2.0 - fog_eroded*0.3) - 1.5, 0.0, 1.0);
|
||||
|
||||
float finalfog = 1-exp(max(samplePos.y - 60,0.0) / -1);
|
||||
|
||||
|
||||
return finalfog;
|
||||
}
|
||||
|
||||
// float GetCloudShadow(vec3 WorldPos, vec3 LightPos, float noise){
|
||||
// float Shadow = 0.0;
|
||||
|
||||
// for (int i=0; i < 3; i++){
|
||||
|
||||
// // vec3 shadowSamplePos = WorldPos - LightPos.y/abs(LightPos.y) * (0.25 + pow(i,0.75)*0.25);
|
||||
// vec3 shadowSamplePos = WorldPos + LightPos * (i * 20);
|
||||
|
||||
// float Cast = cloudVol(shadowSamplePos);
|
||||
// Shadow += Cast;
|
||||
// }
|
||||
|
||||
// return clamp(exp(-Shadow*30),0.0,1.0);
|
||||
// }
|
||||
//Mie phase function
|
||||
// float phaseg(float x, float g){
|
||||
// float gg = g * g;
|
||||
// return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) /3.14;
|
||||
// }
|
||||
|
||||
mat2x3 getVolumetricRays(float dither,vec3 fragpos,float dither2) {
|
||||
int SAMPLES = 16;
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = vec3(0.0);
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = (fragposition-start);
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
|
||||
float maxLength = min(length(dVWorld),32.0 * 12.0)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
vec3 vL = vec3(0.);
|
||||
float dL = length(dVWorld);
|
||||
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float expFactor = 11.0;
|
||||
|
||||
vec3 fogColor = gl_Fog.color.rgb;
|
||||
|
||||
// float SdotV = dot(normalize(viewspace_sunvec), normalize(fragpos));
|
||||
// float OrbMie = phaseg(SdotV, 0.8);
|
||||
|
||||
for (int i=0;i<SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
float densityVol = cloudVol(progressW) ;
|
||||
float density = min(densityVol,0.1);
|
||||
float air = 0.005;
|
||||
|
||||
/// THE OOOOOOOOOOOOOOOOOOOOOORB
|
||||
vec3 LightColor = LightSourceColor();
|
||||
|
||||
// vec3 LightPos = LightSourcePosition(progressW, cameraPosition);
|
||||
// float OrbMie = exp(length(LightPos) * -0.03) * 64.0;
|
||||
|
||||
float OrbMie = clamp(exp((progressW.y - 30) / -10.) * 5,0,1);
|
||||
|
||||
LightColor *= OrbMie;
|
||||
|
||||
float CastLight = 0.0;
|
||||
for (int j=0; j < 5; j++){
|
||||
vec3 shadowSamplePos = progressW + WsunVec * (0.5 + j * 5);
|
||||
// vec3 shadowSamplePos = progressW - LightPos.y * (j*30);
|
||||
|
||||
float densityVol2 = cloudVol(shadowSamplePos);
|
||||
CastLight += densityVol2;
|
||||
}
|
||||
|
||||
vec3 CastedLight = LightColor * exp(CastLight * -15);
|
||||
|
||||
// #ifdef THE_ORB
|
||||
// density += clamp((1.0 - length(LightPos) / 10.0) * 10 ,0.0,1.0) ;
|
||||
// #endif
|
||||
|
||||
vec3 AmbientLight = fogColor* exp(density * -25);
|
||||
|
||||
vec3 vL0 = AmbientLight;
|
||||
|
||||
vec3 vL1 = vec3(1.0,0.75,0.5) * 0.1;
|
||||
|
||||
vL += (vL0 - vL0*exp(-density*dd*dL)) * absorbance;
|
||||
vL += (vL1 - vL1*exp(-air*dd*dL)) * absorbance;
|
||||
|
||||
absorbance *= exp(-(density+air)*dd*dL);
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
}
|
120
shaders/lib/oceans.glsl
Normal file
120
shaders/lib/oceans.glsl
Normal file
@ -0,0 +1,120 @@
|
||||
// THIS FILE IS PUBLIC DOMAIN SO USE IT HOWEVER YOU WANT!
|
||||
// to make it compatible with your shaderpack use:
|
||||
#define PHYSICS_OCEAN_SUPPORT
|
||||
// at the top of your file. When used my mod no longer injects code into
|
||||
// your shaderpack. It replaces this define statement (before compilation) with
|
||||
#define PHYSICS_OCEAN
|
||||
// so you can use
|
||||
// #ifdef PHYSICS_OCEAN
|
||||
// #endif
|
||||
// to customize the water for the physics ocean
|
||||
|
||||
// just some basic consts for the wave function based on afl_ext's shader https://www.shadertoy.com/view/Xdlczl
|
||||
// the overall shape must stay consistent because it is also computed on the CPU side
|
||||
// to offset entities (though a custom CPU integration of your shader is possible by
|
||||
// contacting me on my discord server https://discord.gg/VsNs9xP)
|
||||
const int PHYSICS_ITERATIONS_OFFSET = 13;
|
||||
const float PHYSICS_DRAG_MULT = 0.048;
|
||||
const float PHYSICS_XZ_SCALE = 0.035;
|
||||
const float PHYSICS_TIME_MULTIPLICATOR = 0.45;
|
||||
const float PHYSICS_W_DETAIL = 0.75;
|
||||
const float PHYSICS_FREQUENCY = 6.0;
|
||||
const float PHYSICS_SPEED = 2.0;
|
||||
const float PHYSICS_WEIGHT = 0.8;
|
||||
const float PHYSICS_FREQUENCY_MULT = 1.18;
|
||||
const float PHYSICS_SPEED_MULT = 1.07;
|
||||
const float PHYSICS_ITER_INC = 12.0;
|
||||
const float PHYSICS_NORMAL_STRENGTH = 0.6;
|
||||
|
||||
// this is the surface detail from the physics options, ranges from 13 to 48 (yeah I know weird)
|
||||
uniform int physics_iterationsNormal;
|
||||
// used to offset the 0 point of wave meshes to keep the wave function consistent even
|
||||
// though the mesh totally changes
|
||||
uniform vec2 physics_waveOffset;
|
||||
// used for offsetting the local position to fetch the right pixel of the waviness texture
|
||||
uniform ivec2 physics_textureOffset;
|
||||
// time in seconds that can go faster dependent on weather conditions (affected by weather strength
|
||||
// multiplier in ocean settings
|
||||
uniform float physics_gameTime;
|
||||
// base value is 13 and gets multiplied by wave height in ocean settings
|
||||
uniform float physics_oceanHeight;
|
||||
// basic texture to determine how shallow/far away from the shore the water is
|
||||
uniform sampler2D physics_waviness;
|
||||
// basic scale for the horizontal size of the waves
|
||||
uniform float physics_oceanWaveHorizontalScale;
|
||||
|
||||
#ifdef PHYSICSMOD_VERTEX
|
||||
// for the vertex shader stage
|
||||
out vec3 physics_localPosition;
|
||||
out float physics_localWaviness;
|
||||
#endif
|
||||
|
||||
#ifdef PHYSICSMOD_FRAGMENT
|
||||
// for the fragment shader stage
|
||||
in vec3 physics_localPosition;
|
||||
in float physics_localWaviness;
|
||||
#endif
|
||||
float physics_waveHeight(vec2 position, int iterations, float factor, float time) {
|
||||
position = (position - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale;
|
||||
float iter = 0.0;
|
||||
float frequency = PHYSICS_FREQUENCY;
|
||||
float speed = PHYSICS_SPEED;
|
||||
float weight = 1.0;
|
||||
float height = 0.0;
|
||||
float waveSum = 0.0;
|
||||
float modifiedTime = time * PHYSICS_TIME_MULTIPLICATOR;
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
vec2 direction = vec2(sin(iter), cos(iter));
|
||||
float x = dot(direction, position) * frequency + modifiedTime * speed;
|
||||
float wave = exp(sin(x) - 1.0);
|
||||
float result = wave * cos(x);
|
||||
vec2 force = result * weight * direction;
|
||||
|
||||
position -= force * PHYSICS_DRAG_MULT;
|
||||
height += wave * weight;
|
||||
iter += PHYSICS_ITER_INC;
|
||||
waveSum += weight;
|
||||
weight *= PHYSICS_WEIGHT;
|
||||
frequency *= PHYSICS_FREQUENCY_MULT;
|
||||
speed *= PHYSICS_SPEED_MULT;
|
||||
}
|
||||
|
||||
return height / waveSum * physics_oceanHeight * factor - physics_oceanHeight * factor * 0.5;
|
||||
}
|
||||
|
||||
vec2 physics_waveDirection(vec2 position, int iterations, float time) {
|
||||
position = (position - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale;
|
||||
float iter = 0.0;
|
||||
float frequency = PHYSICS_FREQUENCY;
|
||||
float speed = PHYSICS_SPEED;
|
||||
float weight = 1.0;
|
||||
float waveSum = 0.0;
|
||||
float modifiedTime = time * PHYSICS_TIME_MULTIPLICATOR;
|
||||
vec2 dx = vec2(0.0);
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
vec2 direction = vec2(sin(iter), cos(iter));
|
||||
float x = dot(direction, position) * frequency + modifiedTime * speed;
|
||||
float wave = exp(sin(x) - 1.0);
|
||||
float result = wave * cos(x);
|
||||
vec2 force = result * weight * direction;
|
||||
|
||||
dx += force / pow(weight, PHYSICS_W_DETAIL);
|
||||
position -= force * PHYSICS_DRAG_MULT;
|
||||
iter += PHYSICS_ITER_INC;
|
||||
waveSum += weight;
|
||||
weight *= PHYSICS_WEIGHT;
|
||||
frequency *= PHYSICS_FREQUENCY_MULT;
|
||||
speed *= PHYSICS_SPEED_MULT;
|
||||
}
|
||||
|
||||
return vec2(dx / pow(waveSum, 1.0 - PHYSICS_W_DETAIL));
|
||||
}
|
||||
|
||||
vec3 physics_waveNormal(vec2 position, float factor, float time) {
|
||||
vec2 wave = -physics_waveDirection(position.xy, physics_iterationsNormal, time);
|
||||
float oceanHeightFactor = physics_oceanHeight / 13.0;
|
||||
float totalFactor = oceanHeightFactor * factor;
|
||||
return normalize(vec3(wave.x * totalFactor, PHYSICS_NORMAL_STRENGTH, wave.y * totalFactor));
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
#define Water_Top_Layer 62.90 // When under water and when lightMapDepthEstimate is turned off. Assumes the top layer of the water is at this height (minecraft y position) for underwater lighting calculations. If not set correctly, underwater will look incorrect.[0.90 1.90 2.90 3.90 4.90 5.90 6.90 7.90 8.90 9.90 10.90 11.90 12.90 13.90 14.90 15.90 16.90 17.90 18.90 19.90 20.90 21.90 22.90 23.90 24.90 25.90 26.90 27.90 28.90 29.90 30.90 31.90 32.90 33.90 34.90 35.90 36.90 37.90 38.90 39.90 40.90 41.90 42.90 43.90 44.90 45.90 46.90 47.90 48.90 49.90 50.90 51.90 52.90 53.90 54.90 55.90 56.90 57.90 58.90 59.90 60.90 61.90 62.90 63.90 64.90 65.90 66.90 67.90 68.90 69.90 70.90 71.90 72.90 73.90 74.90 75.90 76.90 77.90 78.90 79.90 80.90 81.90 82.90 83.90 84.90 85.90 86.90 87.90 88.90 89.90 90.90 91.90 92.90 93.90 94.90 95.90 96.90 97.90 98.90 99.90 100.90 101.90 102.90 103.90 104.90 105.90 106.90 107.90 108.90 109.90 110.90 111.90 112.90 113.90 114.90 115.90 116.90 117.90 118.90 119.90 120.90 121.90 122.90 123.90 124.90 125.90 126.90 127.90 128.90 129.90 130.90 131.90 132.90 133.90 134.90 135.90 136.90 137.90 138.90 139.90 140.90 141.90 142.90 143.90 144.90 145.90 146.90 147.90 148.90 149.90 150.90 151.90 152.90 153.90 154.90 155.90 156.90 157.90 158.90 159.90 160.90 161.90 162.90 163.90 164.90 165.90 166.90 167.90 168.90 169.90 170.90 171.90 172.90 173.90 174.90 175.90 176.90 177.90 178.90 179.90 180.90 181.90 182.90 183.90 184.90 185.90 186.90 187.90 188.90 189.90 190.90 191.90 192.90 193.90 194.90 195.90 196.90 197.90 198.90 199.90]
|
||||
//#define lightMapDepthEstimation // If turned off, will use the player eye position and the Water_Top_Layer option to determine how deep the player is in water. It can look wrong in a lot of cases, and using minecraft light levels instead improves this but will look worse in oceans, lakes and rivers.
|
||||
//#define Vanilla_like_water // vanilla water texture along with shader water stuff
|
||||
#define Texture_MipMap_Bias -1.00 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
|
||||
#define Texture_MipMap_Bias 0.0 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
|
||||
|
||||
// --- AMBIENT LIGHT ---
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#define TORCH_R 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_G 0.75 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define AO_in_sunlight // control if ambient occlusion appears in sunlit areas.
|
||||
|
||||
// --- DOF ---
|
||||
|
||||
@ -75,8 +76,7 @@
|
||||
#define CaveFogColor_G 0.2 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define CaveFogColor_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define display_LUT // aaaaaaaaaaaaaaaaaaaaaaa
|
||||
#define CLOUDS_SHADOWS
|
||||
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL (slow)
|
||||
|
||||
#define CLOUDS_SHADOWS_STRENGTH 1.0 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define VL_SAMPLES 8 //[4 6 8 10 12 14 16 20 24 30 40 50]
|
||||
#define SEA_LEVEL 70 //[0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190] //The volumetric light uses an altitude-based fog density, this is where fog density is the highest, adjust this value according to your world.
|
||||
@ -89,29 +89,38 @@
|
||||
#define fog_coefficientMieR 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientMieG 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]intervalMult
|
||||
#define fog_coefficientMieB 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define Cloudy_Fog_Density 5.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define Uniform_Fog_Density 1.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define uniformfog_fade 10 // does not change rain or cave fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
#define cloudyfog_fade 10 // does not change rain or cave fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
#define RainFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
|
||||
#define CaveFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
|
||||
|
||||
#define cloudray_amount 0.2 // rain boost this [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
#define UniformFog_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0]
|
||||
#define CloudyFog_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10 20 30 40 50 100 500 10000]
|
||||
#define TimeOfDayFog_multiplier 1.0 // Influence of time of day on fog amount [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
#define Haze_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
// #define fog_selfShadowing // make the fog cast a shadow onto itself
|
||||
|
||||
#define HQ_CLOUDS //Renders detailled clouds for viewport
|
||||
#define CLOUDS_QUALITY 0.5 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define BASE_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0] Base fog amount amount (does not change the "cloudy" fog)
|
||||
#define CLOUDY_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
#define FOG_TOD_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of time of day on fog amount
|
||||
#define FOG_RAIN_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of rain on fog amount
|
||||
|
||||
#define BLOOMY_FOG 2.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0]
|
||||
#define BLOOM_STRENGTH 4.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0]
|
||||
|
||||
// --- LABPBR ---
|
||||
|
||||
#define Haze_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
#define RainFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
|
||||
#define CaveFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
|
||||
|
||||
#define Morning_Uniform_Fog 1.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Noon_Uniform_Fog 0.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Evening_Uniform_Fog 10.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Night_Uniform_Fog 10.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
|
||||
#define Morning_Cloudy_Fog 1.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Noon_Cloudy_Fog 0.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Evening_Cloudy_Fog 50.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
#define Night_Cloudy_Fog 5.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
|
||||
|
||||
#define TOD_Fog_mult 1.0 // [0.0 0.25 0.5 0.75 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
|
||||
|
||||
|
||||
|
||||
|
||||
#define NetherFog_brightness 0.5 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
// --- LABPBR ---
|
||||
//#define SPECULARTEX
|
||||
#define Sub_surface_scattering // (place the flashlight on your hand example here)
|
||||
// #define LabPBR_subsurface_scattering
|
||||
#define LabSSS_Curve 1.0 // i just really like how it looks at 2.0, so i made it an option. [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
@ -123,16 +132,16 @@
|
||||
// #define LabPBR_Emissives
|
||||
#define Emissive_Brightness 10.0 // [1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 100.]
|
||||
#define Emissive_Curve 2.0 // yes i blatantly copied kappa here. [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
//#define Horrible_slope_normals
|
||||
//#define Horrible_slope_normals // really only good on low resoltution packs. alot of aliasing/flickering at high resoltions
|
||||
//#define POM
|
||||
#define mob_SSS
|
||||
#define misc_block_SSS
|
||||
#define POM_DEPTH 0.25 // [0.025 0.05 0.075 0.1 0.125 0.15 0.20 0.25 0.30 0.50 0.75 1.0] //Increase to increase POM strength
|
||||
#define POM_DEPTH 0.25 // [0.025 0.05 0.075 0.1 0.125 0.15 0.20 0.25 0.30 0.50 0.75 1.0] // IN CENTIMETERS. Increase to increase POM strength.
|
||||
#define Adaptive_Step_length // make only used parts of the POM depth get samples, to increase overall quality. DOWNSIDE: at sheer angles, it looks kinda buggy.
|
||||
#define MAX_ITERATIONS 50 // [5 10 15 20 25 30 40 50 60 70 80 90 100 125 150 200 400] //Improves quality at grazing angles (reduces performance)
|
||||
#define MAX_DIST 25.0 // [5.0 10.0 15.0 20.0 25.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 125.0 150.0 200.0 400.0] //Increases distance at which POM is calculated
|
||||
#define DISABLE_ALPHA_MIPMAPS //Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
|
||||
// #define DISABLE_ALPHA_MIPMAPS //Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
|
||||
// #define Porosity
|
||||
#define texture_ao // ambient occlusion on the texture
|
||||
|
||||
// --- WEATHER/SKY ---
|
||||
|
||||
@ -155,6 +164,7 @@
|
||||
#define moonColorR 0.9080 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define moonColorG 0.9121 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define moonColorB 0.8948 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
|
||||
#if colortype == 1
|
||||
#define sunColorBase vec3(sunColorR,sunColorG,sunColorB) * sun_illuminance
|
||||
#define moonColorBase vec3(moonColorR,moonColorG,moonColorB) * moon_illuminance //Fake Purkinje effect
|
||||
@ -162,6 +172,8 @@
|
||||
#define sunColorBase blackbody(Sun_temp) * sun_illuminance
|
||||
#define moonColorBase blackbody(Moon_temp) * moon_illuminance //Fake Purkinje effect
|
||||
#endif
|
||||
|
||||
|
||||
// #define Allow_Vanilla_sky // allow the vanilla sky to appear. may appear broken with some resourcepacks.
|
||||
// #define WhiteWorld // THIS IS A DEBUG VIEW. uses to see AO easier. used to see fake GI better (green light)
|
||||
#define TAA
|
||||
@ -196,9 +208,9 @@
|
||||
#define Daily_Weather // different skies for different days, and fog.
|
||||
#define WeatherDay -1 // [-1 0 1 2 3 4 5 6 7]
|
||||
#define cloudCoverage 0.4 // Cloud coverage [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define Rain_coverage 0.6 // how much the coverage of the clouds change during rain [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0]
|
||||
#define Rain_coverage 0.8 // how much the coverage of the clouds change during rain [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0]
|
||||
#define Biome_specific_environment // makes the fog density and color look unique in certain biomes. (swamps, jungles, lush caves, giant pines, dark forests)
|
||||
const float ambientOcclusionLevel = 0.15; //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
const float ambientOcclusionLevel = 1.0; //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ]
|
||||
#define Puddle_Size 1.0 // [0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5]
|
||||
|
||||
@ -218,11 +230,11 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
|
||||
#define SHADOW_DISABLE_ALPHA_MIPMAPS // Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
|
||||
#define Stochastic_Transparent_Shadows // Highly recommanded to enable SHADOW_DISABLE_ALPHA_MIPMAPS with it. Uses noise to simulate transparent objects' shadows (not colored). It is also recommended to increase Min_Shadow_Filter_Radius with this.
|
||||
|
||||
|
||||
// --- SSGI/RTAO ---
|
||||
|
||||
// #define SSGI
|
||||
//#define RTAO // I recommend turning ambientOcclusionLevel to zero with this on. like ssao, but rt, nicer, noiser, and slower. SSAO will turn OFF when this is ON
|
||||
#define indirect_effect 1 // 0 = none. 1 = SSAO. 2 = RTAO. 3 = SSGI. [0 1 2 3 4]
|
||||
#define indirect_effect 1 // vanilla AO is what minecraft normally uses. SSAO is basic, and fast, this setting includes vanilla AO. GTAO is high quality, low noise, medium speed. RTAO is raytraced ambient occlusion, noisy and slow. SSGI is raytraced global illumination, and ambient occlusion, very slow and noisy. [0 1 2 3 4]
|
||||
|
||||
#define RAY_COUNT 4 // [1 2 3 4 5 6 7 8 9 10 12 14 16 18 21 24 28 32 37 43 49 57 65 75 86 100]
|
||||
#define STEPS 8 // [ 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99]
|
||||
#define STEP_LENGTH 12. // [ 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30.]
|
||||
@ -230,7 +242,7 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
|
||||
#define DRAW_SUN //if not using custom sky
|
||||
#define SKY_BRIGHTNESS_DAY 1.0 //[0.0 0.5 0.75 1. 1.2 1.4 1.6 1.8 2.0]
|
||||
#define SKY_BRIGHTNESS_NIGHT 1.0 //[0.0 0.5 0.75 1. 1.2 1.4 1.6 1.8 2.0]
|
||||
#define SSAO // screen-space ambient occlusion.
|
||||
|
||||
|
||||
// --- REFLECTIONS ---
|
||||
|
||||
@ -248,7 +260,30 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
|
||||
|
||||
// --- CLOUDS ---
|
||||
|
||||
#define VOLUMETRIC_CLOUDS// if you don't like the noise on the default cloud settings, turn up the cloud samples. if that hurts performance too much, turn down the clouds quality.
|
||||
#define VOLUMETRIC_CLOUDS // if you don't like the noise on the default cloud settings, turn up the cloud samples. if that hurts performance too much, turn down the clouds quality.
|
||||
|
||||
#define CLOUDS_SHADOWS // Casts shadows from clouds on the world
|
||||
#ifndef VOLUMETRIC_CLOUDS
|
||||
#undef CLOUDS_SHADOWS
|
||||
#endif
|
||||
|
||||
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL
|
||||
#ifndef CLOUDS_SHADOWS
|
||||
#undef VL_CLOUDS_SHADOWS
|
||||
#endif
|
||||
|
||||
#define Cumulus // a layer of puffy clouds up yonder.
|
||||
#define Cumulus_coverage 0.4 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Cumulus_density 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
|
||||
|
||||
|
||||
|
||||
#define Altostratus // a layer of clouds WAAAY up yonder
|
||||
#define Alto_coverage 0.5 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Alto_density 0.05 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
|
||||
|
||||
|
||||
|
||||
#define cloud_LevelOfDetail 1 // Number of fbm noise iterations for on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_ShadowLevelOfDetail 0 // Number of fbm noise iterations for the shadowing of on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_LevelOfDetailLQ 1 // Number of fbm noise iterations for reflected clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
@ -262,19 +297,17 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
|
||||
#define cloudMie2Multiplier 0.7 // Multiplier for multiple scattering approximation [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define Cloud_top_cutoff 1.0 // the cutoff point on the top part of the cloud. [ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.5 3.0 4 5 6 7 8 9]
|
||||
#define Cloud_base_cutoff 5.0 // the cutoff point on the base of the cloud. [0.1 1 2 4 6 8 10 12 14 16 18 20]
|
||||
#define cloudDensity 0.0514 // Cloud Density, 0.04-0.06 is around irl values [0.0010 0.0011 0.0013 0.0015 0.0017 0.0020 0.0023 0.0026 0.0030 0.0034 0.0039 0.0045 0.0051 0.0058 0.0067 0.0077 0.0088 0.0101 0.0115 0.0132 0.0151 0.0173 0.0199 0.0228 0.0261 0.0299 0.0342 0.0392 0.0449 0.0514 0.0589 0.0675 0.0773 0.0885 0.1014 0.1162 0.1331 0.1524 0.1746 0.2000 0.3 0.35 0.4 0.45 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define cloudDensity 0.5 // Cloud Density, 0.04-0.06 is around irl values [0.0010 0.0011 0.0013 0.0015 0.0017 0.0020 0.0023 0.0026 0.0030 0.0034 0.0039 0.0045 0.0051 0.0058 0.0067 0.0077 0.0088 0.0101 0.0115 0.0132 0.0151 0.0173 0.0199 0.0228 0.0261 0.0299 0.0342 0.0392 0.0449 0.0514 0.0589 0.0675 0.0773 0.0885 0.1014 0.1162 0.1331 0.1524 0.1746 0.2000 0.3 0.35 0.4 0.45 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define fbmAmount 0.50 // Amount of noise added to the cloud shape [0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00]
|
||||
#define fbmPower1 3.00 // Higher values increases high frequency details of the cloud shape [1.0 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.]
|
||||
#define fbmPower2 1.50 // Lower values increases high frequency details of the cloud shape [1.00 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.]
|
||||
#define fbmPower2 2.50 // Lower values increases high frequency details of the cloud shape [1.00 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.]
|
||||
#define Cloud_Size 35 // [1 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
#define Cloud_Height 319 // [-300 -290 -280 -270 -260 -250 -240 -230 -220 -210 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 319 320]
|
||||
#define Cloud_Height 300 // [-300 -290 -280 -270 -260 -250 -240 -230 -220 -210 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 319 320]
|
||||
#define Shadow_brightness 0.5 // how dark / bright you want the shadowed part of the clouds to be. low values can look weird. [ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0]
|
||||
#define self_shadow_samples 3.0 // amount of interations for cloud self shadows. longer/shorter cloud self shadows. [ 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15 20 30 40 50]
|
||||
#define Dynamic_sky_day -1 // -1 MEANS THIS IS OFF. select which day of the 8 to the clouds should take shape in [0 1 2 3 4 5 6 7 ]
|
||||
#define Dynamic_Sky // day 1: partly cloudy. day 2: really cloudy, misty. day 3: mostly clear. day 4: cloudy. day 5: cloudy again. day 6: scattered clouds. day 7: partly cloudy. day 8: clear
|
||||
#define High_Altitude_Clouds // a layer of clouds way up yonder
|
||||
#define Cumulus_Clouds
|
||||
#define flip_the_clouds 1 // what was once above is now below [1 -1]
|
||||
|
||||
#define cloud_speed 1 // how [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 5.0 10.0 25.0 50.0 100.0 200.0]
|
||||
#define VL_SAMPLES2 6 //[4 6 8 10 12 14 16 20 24 30 40 50]
|
||||
|
||||
@ -303,3 +336,18 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
|
||||
// #define AEROCHROME_MODE // Infra-red film colors ^~^
|
||||
#define AEROCHROME_PINKNESS 0.3 // How pink it is from red [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
//#define AEROCHROME_WOOL_ENABLED // Technically wool things should be affected but it affects a lot of builds and stuff
|
||||
|
||||
|
||||
|
||||
// -- END SPECIFIC STUFF ---
|
||||
|
||||
// #define DEBUG_endfog
|
||||
// #define THE_ORB
|
||||
#define ORB_X 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define ORB_Y 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define ORB_Z 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
|
||||
#define ORB_R 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define ORB_G 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define ORB_B 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define ORB_ColMult 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
@ -81,7 +81,7 @@ vec4 skyCloudsFromTex(vec3 pos,sampler2D sampler){
|
||||
vec2 p = sphereToCarte(pos);
|
||||
return texture2D(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize);
|
||||
}
|
||||
vec4 skyCloudsFromTex_Spec(vec3 pos,sampler2D sampler, int LOD){
|
||||
vec4 skyCloudsFromTexLOD(vec3 pos,sampler2D sampler, float LOD){
|
||||
vec2 p = sphereToCarte(pos);
|
||||
return texture2DLod(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize, LOD);
|
||||
return texture2DLod(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize,LOD);
|
||||
}
|
@ -12,39 +12,18 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
// sun specular stuff
|
||||
|
||||
vec3 mix_vec3(vec3 X, vec3 Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
}
|
||||
float mix_float(float X, float Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
}
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
float g(float NdotL, float roughness){
|
||||
float alpha = square(max(roughness, 0.02));
|
||||
return 2.0 * NdotL / (NdotL + sqrt(square(alpha) + (1.0 - square(alpha)) * square(NdotL)));
|
||||
}
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
vec3 GGX2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
float roughness = r; // when roughness is zero it fucks up
|
||||
float alpha = square(roughness) + 1e-5;
|
||||
|
||||
vec3 h = normalize(l + v) ;
|
||||
|
||||
float dotLH = clamp(dot(h,l),0.,1.);
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNV = clamp(dot(n,v),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
|
||||
float D = alpha / (3.141592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
|
||||
// other shit
|
||||
@ -62,71 +41,7 @@ float linZ(float depth) {
|
||||
// d = -((2n/l)-f-n)/(f-n)
|
||||
|
||||
}
|
||||
vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
|
||||
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? (-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(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*dither;
|
||||
|
||||
float minZ = clipPosition.z+stepv.z;
|
||||
float maxZ = spos.z+stepv.z;
|
||||
spos.xy += TAA_Offset*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 = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r;
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
|
||||
spos += stepv;
|
||||
//small bias
|
||||
minZ = maxZ-(0.0001/dist)/ld(spos.z);
|
||||
maxZ += stepv.z;
|
||||
}
|
||||
|
||||
return vec3(1.1);
|
||||
}
|
||||
// vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
|
||||
|
||||
// vec3 clipPosition = toClipSpace3(position);
|
||||
// float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
// (-near -position.z) / dir.z : far*sqrt(3.);
|
||||
// vec3 direction = normalize(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 = maxLengths.y;
|
||||
|
||||
// vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0) * dither;
|
||||
// vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ;
|
||||
|
||||
// spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
|
||||
|
||||
// float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases
|
||||
|
||||
// for(int i = 0; i < int(quality); i++){
|
||||
// spos += stepv;
|
||||
// float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
// float currZ = linZ(spos.z);
|
||||
|
||||
// if( sp < currZ) {
|
||||
// float dist = abs(sp-currZ)/currZ;
|
||||
// if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0);
|
||||
// }
|
||||
// spos += stepv;
|
||||
// }
|
||||
// return vec3(1.1);
|
||||
// }
|
||||
|
||||
void frisvad(in vec3 n, out vec3 f, out vec3 r){
|
||||
if(n.z < -0.9) {
|
||||
@ -153,28 +68,44 @@ vec2 R2_samples_spec(int n){
|
||||
return fract(alpha * n);
|
||||
}
|
||||
|
||||
vec3 sampleGGXVNDF(vec3 V_, float roughness, float U1, float U2){
|
||||
// stretch view
|
||||
vec3 V = normalize(vec3(roughness * V_.x, roughness * V_.y, V_.z));
|
||||
// orthonormal basis
|
||||
vec3 T1 = (V.z < 0.9999) ? normalize(cross(V, vec3(0,0,1))) : vec3(1,0,0);
|
||||
vec3 T2 = cross(T1, V);
|
||||
// sample point with polar coordinates (r, phi)
|
||||
float a = 1.0 / (1.0 + V.z);
|
||||
float r = sqrt(U1*0.25);
|
||||
float phi = (U2<a) ? U2/a * 3.141592653589793 : 3.141592653589793 + (U2-a)/(1.0-a) * 3.141592653589793;
|
||||
float P1 = r*cos(phi);
|
||||
float P2 = r*sin(phi)*((U2<a) ? 1.0 : V.z);
|
||||
// compute normal
|
||||
vec3 N = P1*T1 + P2*T2 + sqrt(max(0.0, 1.0 - P1*P1 - P2*P2))*V;
|
||||
// unstretch
|
||||
N = normalize(vec3(roughness*N.x, roughness*N.y, N.z));
|
||||
return N;
|
||||
vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
|
||||
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? (-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(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*dither;
|
||||
|
||||
float minZ = clipPosition.z+stepv.z;
|
||||
float maxZ = spos.z+stepv.z;
|
||||
spos.xy += TAA_Offset*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 = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r;
|
||||
|
||||
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
|
||||
spos += stepv;
|
||||
//small bias
|
||||
minZ = maxZ-(0.0001/dist)/ld(spos.z);
|
||||
maxZ += stepv.z;
|
||||
}
|
||||
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool hand, inout float reflectLength){
|
||||
|
||||
|
||||
vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool hand){
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
(-near -position.z) / dir.z : far*sqrt(3.);
|
||||
@ -197,9 +128,8 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool
|
||||
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++) {
|
||||
|
||||
// decode depth buffer
|
||||
vec2 testthing = hand ? spos.xy*texelSize : spos.xy/texelSize/4.0; // fix for ssr on hand
|
||||
float sp = sqrt(texelFetch2D(gaux1,ivec2(testthing),0).w/65000.0);
|
||||
float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a+0.1)/65000.0);
|
||||
sp = invLinZ(sp);
|
||||
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
@ -209,58 +139,94 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool
|
||||
float biasamount = 0.0002 / dist;
|
||||
if(hand) biasamount = 0.01;
|
||||
minZ = maxZ-biasamount / ld(spos.z);
|
||||
|
||||
maxZ += stepv.z;
|
||||
|
||||
reflectLength += 1.0 / quality; // for shit
|
||||
}
|
||||
|
||||
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
|
||||
vec3 mix_vec3(vec3 X, vec3 Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
}
|
||||
float mix_float(float X, float Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
vec3 sampleGGXVNDF(vec3 V_, float roughness, float U1, float U2){
|
||||
// stretch view
|
||||
vec3 V = normalize(vec3(roughness * V_.x, roughness * V_.y, V_.z));
|
||||
// orthonormal basis
|
||||
vec3 T1 = (V.z < 0.9999) ? normalize(cross(V, vec3(0,0,1))) : vec3(1,0,0);
|
||||
vec3 T2 = cross(T1, V);
|
||||
// sample point with polar coordinates (r, phi)
|
||||
float a = 1.0 / (1.0 + V.z);
|
||||
float r = sqrt(U1*0.25);
|
||||
float phi = (U2<a) ? U2/a * 3.141592653589793 : 3.141592653589793 + (U2-a)/(1.0-a) * 3.141592653589793;
|
||||
float P1 = r*cos(phi);
|
||||
float P2 = r*sin(phi)*((U2<a) ? 1.0 : V.z);
|
||||
// compute normal
|
||||
vec3 N = P1*T1 + P2*T2 + sqrt(max(0.0, 1.0 - P1*P1 - P2*P2))*V;
|
||||
// unstretch
|
||||
N = normalize(vec3(roughness*N.x, roughness*N.y, N.z));
|
||||
return N;
|
||||
}
|
||||
|
||||
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 = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
|
||||
float k2 = .25 * r;
|
||||
|
||||
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
|
||||
}
|
||||
|
||||
// pain
|
||||
void MaterialReflections(
|
||||
vec2 texcoord,
|
||||
inout vec3 Output,
|
||||
float roughness,
|
||||
vec3 f0,
|
||||
vec3 albedo,
|
||||
vec3 sunPos,
|
||||
vec3 sunCol,
|
||||
float diffuse,
|
||||
vec3 directlighting,
|
||||
float lightmap,
|
||||
vec3 normal,
|
||||
vec3 np3,
|
||||
vec3 fragpos,
|
||||
vec3 noise,
|
||||
bool hand
|
||||
bool hand,
|
||||
bool isEntities
|
||||
){
|
||||
vec3 Reflections_Final = Output;
|
||||
vec3 SkyReflection = Output;
|
||||
vec3 SunReflection;
|
||||
vec4 Reflections;
|
||||
|
||||
float reflectLength;
|
||||
float Outdoors = clamp((lightmap-0.6)*5.0, 0.0,1.0);
|
||||
// float Outdoors = clamp((lightmap-0.5) * , 0.0,1.0);
|
||||
|
||||
roughness = unpackRoughness(roughness);
|
||||
f0 = f0.y == 0.0 ? vec3(0.04) : f0;
|
||||
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
|
||||
|
||||
// roughness = 0.2;
|
||||
// f0 = vec3(0.04);
|
||||
|
||||
// f0 = vec3(0.0);
|
||||
// roughness = 0.0;
|
||||
|
||||
mat3 basis = CoordBase(normal);
|
||||
vec3 normSpaceView = -np3*basis ;
|
||||
|
||||
// roughness stuff
|
||||
#ifdef Rough_reflections
|
||||
int seed = (frameCounter%40000);
|
||||
int seed = frameCounter%40000;
|
||||
vec2 ij = fract(R2_samples_spec(seed) + noise.rg) ;
|
||||
|
||||
vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y);
|
||||
|
||||
if(hand) H = normalize(vec3(0.0,0.0,1.0));
|
||||
#else
|
||||
vec3 H = normalize(vec3(0.0,0.0,1.0));
|
||||
@ -271,59 +237,137 @@ void MaterialReflections(
|
||||
|
||||
// fresnel stuff
|
||||
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
|
||||
vec3 F = mix_vec3(f0, vec3(1.0), fresnel);
|
||||
vec3 rayContrib = F;
|
||||
|
||||
float fresnel2 = dot(-np3, H);
|
||||
float VisibilityFactor = rayContrib.x * pow(1.0-roughness,3.0);
|
||||
|
||||
// vec3 F = f0 + (1.0 - f0) * fresnel;
|
||||
bool hasReflections = Roughness_Threshold == 1.0 ? true : (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
|
||||
float hasReflections2 = max(1.0 - roughness*1.75,0.0);
|
||||
|
||||
|
||||
// // if (!hasReflections) Outdoors = 0.0;
|
||||
|
||||
// SunReflection = directlighting * SunGGX(normal, -np3, sunPos, roughness, f0.y) / 5.0;
|
||||
SunReflection = directlighting * GGX(normal, -np3, sunPos, roughness, f0.yyy);
|
||||
//
|
||||
if (hasReflections) { // Skip sky reflection and SSR if its just not very visible anyway
|
||||
#ifdef Sky_reflection
|
||||
SkyReflection = skyCloudsFromTex(L, colortex4).rgb / 150. * 5.;
|
||||
#endif
|
||||
|
||||
#ifdef Screen_Space_Reflections
|
||||
// #ifdef SCREENSHOT_MODE
|
||||
// float rayQuality = reflection_quality;
|
||||
// #else
|
||||
float rayQuality = mix_float(reflection_quality,4,luma(rayContrib)); // Scale quality with ray contribution
|
||||
// #endif
|
||||
// float rayQuality = reflection_quality;
|
||||
|
||||
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
|
||||
|
||||
float LOD = clamp(reflectLength * 6.0, 0.0,6.0) ;
|
||||
if(hand || isEntities) LOD = 6.0;
|
||||
|
||||
if (rtPos.z < 1.) { // Reproject on previous frame
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2DLod(colortex5,previousPosition.xy,LOD).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// check if the f0 is within the metal ranges, then tint by albedo if it's true.
|
||||
vec3 Metals = f0.y > 229.5/255.0 ? clamp(albedo + fresnel,0.0,1.0) : vec3(1.0);
|
||||
|
||||
SunReflection *= Metals;
|
||||
|
||||
#ifdef Sky_reflection
|
||||
SkyReflection *= Metals;
|
||||
#endif
|
||||
#ifdef Screen_Space_Reflections
|
||||
Reflections.rgb *= Metals;
|
||||
#endif
|
||||
|
||||
// background reflections
|
||||
SkyReflection = mix_vec3(Output, SkyReflection, Outdoors);
|
||||
|
||||
// composite background and SSR.
|
||||
Reflections.rgb = mix_vec3(SkyReflection, Reflections.rgb, Reflections.a);
|
||||
|
||||
// put reflections onto the scene
|
||||
#ifdef Rough_reflections
|
||||
Output = hand ? mix_vec3(Output, Reflections.rgb, VisibilityFactor) : mix_vec3(Output, Reflections.rgb, luma(rayContrib));
|
||||
#else
|
||||
Output = mix_vec3(Output, Reflections.rgb, VisibilityFactor);
|
||||
#endif
|
||||
|
||||
Output += SunReflection;
|
||||
}
|
||||
|
||||
void MaterialReflections_N(
|
||||
inout vec3 Output,
|
||||
float roughness,
|
||||
vec3 f0,
|
||||
vec3 albedo,
|
||||
vec3 normal,
|
||||
vec3 np3,
|
||||
vec3 fragpos,
|
||||
vec3 noise,
|
||||
bool hand
|
||||
){
|
||||
vec3 Reflections_Final = Output;
|
||||
float reflectLength = 0.0;
|
||||
|
||||
roughness = unpackRoughness(roughness);
|
||||
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
|
||||
|
||||
// roughness = 0.0;
|
||||
// f0 = vec3(0.9);
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
|
||||
|
||||
mat3 basis = CoordBase(normal);
|
||||
vec3 normSpaceView = -np3*basis ;
|
||||
|
||||
// roughness stuff
|
||||
#ifdef Rough_reflections
|
||||
int seed = (frameCounter%40000);
|
||||
vec2 ij = fract(R2_samples_spec(seed) + noise.rg) ;
|
||||
vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y);
|
||||
|
||||
if(hand) H = normalize(vec3(0.0,0.0,1.0));
|
||||
#else
|
||||
vec3 H = normalize(vec3(0.0,0.0,1.0));
|
||||
#endif
|
||||
|
||||
vec3 Ln = reflect(-normSpaceView, H);
|
||||
vec3 L = basis * Ln;
|
||||
|
||||
// fresnel stuff
|
||||
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
|
||||
vec3 F = mix(f0, vec3(1.0), fresnel);
|
||||
vec3 rayContrib = F;
|
||||
|
||||
|
||||
// float NdotV = clamp(normalize(dot(np3, L))*10000.,0.,1.);
|
||||
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
|
||||
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) >= 0.0;
|
||||
if (Roughness_Threshold == 1.0){ hasReflections = true; }
|
||||
|
||||
if (Roughness_Threshold == 1.0){ hasReflections = roughness > -1; }
|
||||
|
||||
if (!hasReflections ) Outdoors = 0.0;
|
||||
|
||||
|
||||
|
||||
// if(hand){
|
||||
// LOD_controller = 6;
|
||||
// // noise.b = 0.5;
|
||||
// }
|
||||
|
||||
// SSR, Sky, and Sun reflections
|
||||
vec4 Reflections = vec4(0.0);
|
||||
// vec3 SkyReflection = skyCloudsFromTex_Spec(L, colortex4,int(LOD_controller)).rgb / 150. * 5.;
|
||||
vec3 SkyReflection = skyCloudsFromTex(L, colortex4).rgb / 150. * 5.;
|
||||
|
||||
vec3 SunReflection = diffuse * GGX2(normal, -np3, sunPos, roughness, f0) * 8./150./3. * sunCol * Sun_specular_Strength;
|
||||
|
||||
#ifndef Sky_reflection
|
||||
SkyReflection = Reflections_Final;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 FogReflection = vec3(0.0);
|
||||
#ifdef Screen_Space_Reflections
|
||||
if ( hasReflections ) { // Skip SSR if ray contribution is low
|
||||
|
||||
|
||||
#ifdef SCREENSHOT_MODE
|
||||
float rayQuality = reflection_quality;
|
||||
#else
|
||||
float rayQuality = mix_float(reflection_quality,0.0,dot(rayContrib,vec3(0.33))); // Scale quality with ray contribution
|
||||
#endif
|
||||
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
|
||||
|
||||
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand);
|
||||
|
||||
// float test = dot(vec2(-rtPos.x,-rtPos.y), vec2(rtPos.x,rtPos.y));
|
||||
// float LOD_controller = clamp((1-pow(test*0.5+1.0,25)) * 10,0.0,6.0) ;
|
||||
|
||||
// LOD_controller = 0;
|
||||
float LOD = clamp( reflectLength * 6.0 ,0.0,6.0);
|
||||
|
||||
if (rtPos.z < 1. ){ // Reproject on previous frame
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
@ -331,30 +375,30 @@ void MaterialReflections(
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2DLod(colortex5,previousPosition.xy,0).rgb;
|
||||
Reflections.rgb = texture2DLod(colortex5,previousPosition.xy,LOD).rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// check if the f0 is within the metal ranges, then tint by albedo if it's true.
|
||||
vec3 Metals = f0.y > 229.5/255.0 ? clamp(albedo + fresnel,0.0,1.0) : vec3(1.0);
|
||||
|
||||
Reflections.rgb *= Metals;
|
||||
SunReflection *= Metals;
|
||||
|
||||
#ifdef Sky_reflection
|
||||
SkyReflection *= Metals;
|
||||
// reflect nether fog color instead of a sky.
|
||||
FogReflection = gl_Fog.color.rgb * 0.5 * NetherFog_brightness;
|
||||
FogReflection *= 1.0 + sqrt(roughness) * 15.0; // brighten rough spots for some highlights that look neat
|
||||
FogReflection *= Metals;
|
||||
|
||||
FogReflection = mix(Output, FogReflection, pow(fresnel, 0.2)+0.1); // make sure the background contains the fog reflection.
|
||||
#else
|
||||
FogReflection = Output;
|
||||
#endif
|
||||
float lumaRayContrib = pow(luma(rayContrib),1.0);
|
||||
float oneminus_lumaRayContrib = pow(1.0-luma(rayContrib),1.0);
|
||||
// darken albedos, and stop darkening where the sky gets occluded indoors
|
||||
Reflections_Final *= mix_float(1.0 - (Reflections.a*lumaRayContrib), oneminus_lumaRayContrib, Outdoors);
|
||||
|
||||
// apply all reflections to the lighting
|
||||
Reflections_Final += Reflections.rgb * lumaRayContrib;
|
||||
Reflections_Final += SkyReflection * lumaRayContrib * (1.0-Reflections.a) * Outdoors ;
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
|
||||
Reflections.rgb = mix(FogReflection, Reflections.rgb, Reflections.a); // make background only where ssr is not.
|
||||
Reflections_Final = mix(Output, Reflections.rgb, luma(rayContrib)); // apply reflections to final scene color.
|
||||
|
||||
#ifdef Rough_reflections
|
||||
Output = hand ? mix_vec3(Output, Reflections_Final, visibilityFactor) : Reflections_Final;
|
||||
@ -362,8 +406,106 @@ void MaterialReflections(
|
||||
Output = mix_vec3(Output, Reflections_Final, visibilityFactor);
|
||||
#endif
|
||||
|
||||
Output += SunReflection ;
|
||||
// float aaaa = dot(vec2(-rtPos.x,-rtPos.y), vec2(rtPos.x,rtPos.y));
|
||||
// test = pow(test*0.5+1.0,2);
|
||||
// Output = vec3(0,test,0) ;
|
||||
// Output = vec3(reflectLength);
|
||||
}
|
||||
|
||||
void MaterialReflections_E(
|
||||
inout vec3 Output,
|
||||
float roughness,
|
||||
vec3 f0,
|
||||
vec3 albedo,
|
||||
vec3 normal,
|
||||
vec3 np3,
|
||||
vec3 fragpos,
|
||||
vec3 noise,
|
||||
bool hand,
|
||||
vec3 lightCol,
|
||||
vec3 lightDir,
|
||||
bool isEntities
|
||||
){
|
||||
vec3 Reflections_Final = Output;
|
||||
float reflectLength = 0.0;
|
||||
|
||||
roughness = unpackRoughness(roughness);
|
||||
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
|
||||
|
||||
// roughness = 0.0;
|
||||
// f0 = vec3(0.9);
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
|
||||
|
||||
mat3 basis = CoordBase(normal);
|
||||
vec3 normSpaceView = -np3*basis ;
|
||||
|
||||
// roughness stuff
|
||||
#ifdef Rough_reflections
|
||||
int seed = (frameCounter%40000);
|
||||
vec2 ij = fract(R2_samples_spec(seed) + noise.rg) ;
|
||||
vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y);
|
||||
|
||||
if(hand) H = normalize(vec3(0.0,0.0,1.0));
|
||||
#else
|
||||
vec3 H = normalize(vec3(0.0,0.0,1.0));
|
||||
#endif
|
||||
|
||||
vec3 Ln = reflect(-normSpaceView, H);
|
||||
vec3 L = basis * Ln;
|
||||
|
||||
// fresnel stuff
|
||||
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
|
||||
vec3 F = mix(f0, vec3(1.0), fresnel);
|
||||
vec3 rayContrib = F;
|
||||
|
||||
// float NdotV = clamp(normalize(dot(np3, L))*10000.,0.,1.);
|
||||
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) >= 0.0;
|
||||
if (Roughness_Threshold == 1.0){ hasReflections = true; }
|
||||
|
||||
|
||||
vec3 Ln_2 = reflect(-normSpaceView, normalize(vec3(0.0,0.0,1.0)));
|
||||
vec3 L_2 = basis * Ln_2;
|
||||
|
||||
vec3 FogReflection = skyCloudsFromTexLOD(L_2, colortex4, sqrt(roughness) * 9.0).rgb / 150.0;
|
||||
FogReflection = mix(FogReflection, lightCol * 2 * clamp(dot(L_2, lightDir),0,1), roughness);
|
||||
|
||||
|
||||
FogReflection *= 1.0 + roughness * 2.0;
|
||||
vec4 Reflections = vec4(0.0);
|
||||
|
||||
#ifdef Screen_Space_Reflections
|
||||
if ( hasReflections ) { // Skip SSR if ray contribution is low
|
||||
|
||||
float rayQuality = reflection_quality;
|
||||
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
|
||||
|
||||
float LOD = clamp( reflectLength * 6.0 ,0.0,6.0);
|
||||
|
||||
if(hand) LOD = 6.0;
|
||||
if(isEntities) LOD = 4.0;
|
||||
|
||||
if (rtPos.z < 1. ){ // Reproject on previous frame
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2DLod(colortex5,previousPosition.xy,LOD).rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// check if the f0 is within the metal ranges, then tint by albedo if it's true.
|
||||
vec3 Metals = f0.y > 229.5/255.0 ? clamp(albedo + fresnel,0.0,1.0) : vec3(1.0);
|
||||
Reflections.rgb *= Metals;
|
||||
FogReflection *= Metals;
|
||||
|
||||
Reflections.rgb = mix(FogReflection, Reflections.rgb, Reflections.a); // make background only where ssr is not.
|
||||
Reflections_Final = mix(Output, Reflections.rgb, luma(rayContrib)); // apply reflections to final scene color.
|
||||
|
||||
#ifdef Rough_reflections
|
||||
Output = hand ? mix_vec3(Output, Reflections_Final, visibilityFactor) : Reflections_Final;
|
||||
#else
|
||||
Output = mix_vec3(Output, Reflections_Final, visibilityFactor);
|
||||
#endif
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
#ifdef HQ_CLOUDS
|
||||
int maxIT_clouds = minRayMarchSteps;
|
||||
int maxIT = maxRayMarchSteps;
|
||||
@ -19,21 +17,17 @@
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform sampler2D colortex4;//Skybox
|
||||
// uniform float lightningFlash;
|
||||
|
||||
#define WEATHERCLOUDS
|
||||
#include "/lib/climate_settings.glsl"
|
||||
|
||||
float CumulusHeight = 250;
|
||||
float MaxCumulusHeight = CumulusHeight + 100;
|
||||
|
||||
float maxHeight = 5000.;
|
||||
float cloud_height = 1500.;
|
||||
|
||||
// quick variables
|
||||
float rainCloudwetness = rainStrength ;
|
||||
float rainClouds = rainCloudwetness;
|
||||
|
||||
float cloud_movement1 = frameTimeCounter * cloud_speed * 0.001;
|
||||
float AltostratusHeight = 2000;
|
||||
|
||||
float rainCloudwetness = rainStrength;
|
||||
float cloud_movement = 0;
|
||||
|
||||
//3D noise from 2d texture
|
||||
float densityAtPos(in vec3 pos){
|
||||
@ -45,47 +39,33 @@ float densityAtPos(in vec3 pos){
|
||||
vec2 coord = uv / 512.0;
|
||||
|
||||
//The y channel has an offset to avoid using two textures fetches
|
||||
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
|
||||
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
float cloudshape = 0.0;
|
||||
|
||||
float cloudCov(in vec3 pos,vec3 samplePos){
|
||||
|
||||
// float CloudLarge = texture2D(noisetex, samplePos.xz/150000 + cloud_movement1 ).b;
|
||||
// float CloudSmall = texture2D(noisetex, samplePos.xz/15000 - cloud_movement1 + vec2(1-CloudLarge,-CloudLarge)/5).r;
|
||||
float CloudLarge = texture2D(noisetex, (samplePos.xz + cloud_movement) / 5000 ).b;
|
||||
float CloudSmall = texture2D(noisetex, (samplePos.xz - cloud_movement) / 500 ).r;
|
||||
|
||||
float coverage = abs(pow(CloudLarge,1)*2.0 - 1.2)*0.5 - (1.0-CloudSmall) + 0.3;
|
||||
|
||||
// float coverage = CloudSmall-CloudLarge;
|
||||
float Topshape = max(pos.y - (MaxCumulusHeight + CumulusHeight)*0.46, 0.0) / 200;
|
||||
|
||||
// // float mult = max( abs(pos.y - (maxHeight+cloud_height)*0.4 ) / 5000, 0);
|
||||
Topshape += max(exp((pos.y - MaxCumulusHeight) / 10.0 ), 0.0) ;
|
||||
|
||||
// float mult = max( abs(pos.y-1750) / 5000, 0);
|
||||
float FinalShape = DailyWeather_LowAltitude(coverage) - Topshape;
|
||||
|
||||
// cap the top and bottom for reasons
|
||||
float capbase = sqrt(max(CumulusHeight*1.05 - pos.y, 0.0)/50) ;
|
||||
float captop = max(pos.y - MaxCumulusHeight, 0.0);
|
||||
|
||||
// cloudshape = DailyWeather_LowAltitude(coverage) - mult ;
|
||||
FinalShape = FinalShape - capbase - captop ;
|
||||
|
||||
// return max(cloudshape,0.0);
|
||||
|
||||
|
||||
|
||||
|
||||
float CloudLarge = texture2D(noisetex, samplePos.xz/150000 + cloud_movement1).b;
|
||||
float CloudSmall = texture2D(noisetex, samplePos.xz/15000 - cloud_movement1 + vec2(1-CloudLarge,-CloudLarge)/5).r;
|
||||
|
||||
float coverage = (CloudSmall) - pow(CloudLarge*0.5+0.5,1.5);
|
||||
|
||||
float mult = max( abs(pos.y - (maxHeight+cloud_height)*0.4 ) / 5000, 0);
|
||||
// float mult = max( abs(pos.y-1750) / 5000, 0);
|
||||
|
||||
cloudshape = DailyWeather_LowAltitude(coverage) - mult;
|
||||
|
||||
return max(cloudshape,0.0);
|
||||
return max(FinalShape,0.0);
|
||||
}
|
||||
|
||||
//Erode cloud with 3d Perlin-worley noise, actual cloud value
|
||||
float cloudVol(in vec3 pos,in vec3 samplePos,in float cov, in int LoD){
|
||||
float noise = 0.0 ;
|
||||
@ -93,73 +73,48 @@ float cloudVol(in vec3 pos,in vec3 samplePos,in float cov, in int LoD){
|
||||
float pw = log(fbmPower1);
|
||||
float pw2 = log(fbmPower2);
|
||||
|
||||
// samplePos.xyz -= cloud_movement1.xyz*400;
|
||||
samplePos.xz -= cloud_movement/4;
|
||||
noise += 1.0-densityAtPos(samplePos * 200.) ;
|
||||
|
||||
for (int i = 0; i <= LoD; i++){
|
||||
float weight = exp(-i*pw2);
|
||||
float smallnoise = densityAtPos(samplePos * 600.);
|
||||
if (LoD > 0) noise += ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.5;
|
||||
|
||||
noise += weight - densityAtPos(samplePos * 8 * exp(i*pw) )*weight ;
|
||||
totalWeights += weight ;
|
||||
}
|
||||
noise *= 1.0-cov;
|
||||
|
||||
noise *= clamp(1.0-cloudshape,0.0,1.0);
|
||||
noise /= totalWeights;
|
||||
noise = noise*noise;
|
||||
float cloud = max(cov-noise*noise*fbmAmount,0.0);
|
||||
|
||||
// // noise = (1.0 - densityAtPos(samplePos * 4.));
|
||||
// // samplePos = floor(samplePos*)/16;
|
||||
// noise += ((1.0 - densityAtPos(samplePos * 16.))*0.5+0.5) * (1.0 - densityAtPos(samplePos * 4.));
|
||||
// // noise += (1.0 - densityAtPos(samplePos / 160 * 1000.));
|
||||
// noise *= clamp(pow(1.0-cloudshape,0.5),0.0,1.0);
|
||||
|
||||
// float cloud = max(cov - noise*noise*noise,0.0) ;
|
||||
float cloud = max(cov - noise*noise*fbmAmount,0.0);
|
||||
|
||||
return cloud;
|
||||
}
|
||||
|
||||
float getCloudDensity(in vec3 pos, in int LoD){
|
||||
float GetCumulusDensity(in vec3 pos, in int LoD){
|
||||
|
||||
|
||||
// vec3 samplePos = floor((pos*vec3(1.0,1./48.,1.0)/4 ) /512)*512 ;
|
||||
vec3 samplePos = pos*vec3(1.0,1./48.,1.0)/4;
|
||||
|
||||
float coverageSP = cloudCov(pos,samplePos);
|
||||
|
||||
if (coverageSP > 0.001) {
|
||||
if (LoD < 0) return max(coverageSP - 0.27*fbmAmount,0.0);
|
||||
return cloudVol(pos,samplePos,coverageSP, LoD);
|
||||
return cloudVol(pos,samplePos,coverageSP,LoD);
|
||||
} else return 0.0;
|
||||
}
|
||||
|
||||
float HighAltitudeClouds(vec3 pos){
|
||||
vec2 pos2d = pos.xz/100000.0 ;
|
||||
float GetAltostratusDensity(vec3 pos){
|
||||
|
||||
float cloudLarge = texture2D(noisetex, pos2d/5. ).b;
|
||||
float cloudSmall = texture2D(noisetex, pos2d + vec2(-cloudLarge,cloudLarge)/10).b;
|
||||
float large = texture2D(noisetex, pos.xz/100000. ).b;
|
||||
float small = texture2D(noisetex, pos.xz/10000. - vec2(-large,1-large)/5).b;
|
||||
|
||||
float shape = (small + pow((1.0-large),2.0))/2.0;
|
||||
|
||||
// #ifdef Dynamic_Sky
|
||||
// coverage = max(10.3 - Weather_properties.g*10.,0.0);
|
||||
// // thickness = Weather_properties.g*3 ;
|
||||
// #endif
|
||||
shape = pow(max(shape + Alto_coverage - 0.5,0.0),2.0);
|
||||
|
||||
float coverage = 1;
|
||||
float thickness = 1;
|
||||
DailyWeather_HighAltitude(coverage, thickness);
|
||||
|
||||
float cirrusFinal = exp(pow((cloudSmall + cloudLarge),thickness) * -coverage );
|
||||
return max(cirrusFinal,0.0);
|
||||
return shape;
|
||||
}
|
||||
|
||||
//Mie phase function
|
||||
float phaseg(float x, float g){
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) /3.14;
|
||||
}
|
||||
|
||||
|
||||
// random magic number bullshit go!
|
||||
vec3 Cloud_lighting(
|
||||
vec3 Pos,
|
||||
float CloudShape,
|
||||
float SkyShadowing,
|
||||
float SunShadowing,
|
||||
@ -168,252 +123,229 @@ vec3 Cloud_lighting(
|
||||
vec3 sunContribution,
|
||||
vec3 sunContributionMulti,
|
||||
vec3 moonContribution,
|
||||
vec3 moonContributionMulti,
|
||||
float AmbientShadow,
|
||||
int cloudType
|
||||
){
|
||||
// low altitude
|
||||
float powder = 1.0 - exp(-CloudShape * 400.0);
|
||||
float ambientShading = exp(-SkyShadowing * 50. + powder)*powder ;
|
||||
vec3 ambientLighting = SkyColors * ambientShading;
|
||||
float coeeff = -30;
|
||||
// float powder = 1.0 - exp((CloudShape*CloudShape) * -800);
|
||||
float powder = 1.0 - exp(CloudShape * coeeff/3);
|
||||
float lesspowder = powder*0.4+0.6;
|
||||
|
||||
// if(cloudType == 1) ambientLighting = SkyColors * powder;
|
||||
vec3 skyLighting = SkyColors * exp(SkyShadowing * AmbientShadow * coeeff/2 ) * lesspowder ;
|
||||
|
||||
vec3 sunLighting = exp(-SunShadowing)*sunContribution + exp(-SunShadowing * 0.2)*sunContributionMulti;
|
||||
sunLighting *= powder;
|
||||
if(cloudType == 1){
|
||||
coeeff = -10;
|
||||
skyLighting = SkyColors * exp(SkyShadowing * coeeff/15) * lesspowder;
|
||||
}
|
||||
|
||||
vec3 moonLighting = ( exp2(-MoonShadowing * 2.0 )*moonContribution + exp(-MoonShadowing * 0.2 )*moonContributionMulti ) * powder;
|
||||
vec3 sunLighting = exp(SunShadowing * coeeff + powder) * sunContribution;
|
||||
sunLighting += exp(SunShadowing * coeeff/4 + powder*2) * sunContributionMulti;
|
||||
|
||||
return ambientLighting + sunLighting ;
|
||||
vec3 moonLighting = exp(MoonShadowing * coeeff / 3) * moonContribution * powder;
|
||||
|
||||
|
||||
|
||||
// low altitude
|
||||
// float powder = max(1.0 - exp2(-CloudShape*100.0),0.0);
|
||||
// float ambientShading = (powder*0.8+0.2) * exp2(-SkyShadowing * 50.);
|
||||
// vec3 ambientLighting = SkyColors * 4.0 * ambientShading;
|
||||
|
||||
// if(cloudType == 1) ambientLighting = SkyColors * (1.0-powder/2);
|
||||
|
||||
// vec3 sunLighting = ( exp2(-SunShadowing * 2.0 )*sunContribution + exp(-SunShadowing * 0.2 )*sunContributionMulti ) * powder;
|
||||
// vec3 moonLighting = ( exp2(-MoonShadowing * 2.0 )*moonContribution + exp(-MoonShadowing * 0.2 )*moonContributionMulti ) * powder;
|
||||
|
||||
// // if(cloudType == 0) sunLighting *= clamp((1.05-CirrusCoverage),0,1); // less sunlight hits low clouds if high clouds have alot of coverage
|
||||
|
||||
// return ambientLighting + sunLighting + moonLighting;
|
||||
return skyLighting + moonLighting + sunLighting ;
|
||||
}
|
||||
|
||||
vec3 pixelCoord (vec3 Coordinates, int Resolution){
|
||||
return floor(Coordinates / Resolution) * Resolution;
|
||||
//Mie phase function
|
||||
float phaseg(float x, float g){
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14;
|
||||
}
|
||||
|
||||
float CustomPhase(float LightPos, float S_1, float S_2){
|
||||
float SCALE = S_2; // remember the epislons 0.001 is fine.
|
||||
float N = S_1;
|
||||
float N2 = N / SCALE;
|
||||
|
||||
float R = 1;
|
||||
float A = pow(1.0 - pow(max(R-LightPos,0.0), N2 ),N);
|
||||
|
||||
return A;
|
||||
}
|
||||
|
||||
vec3 startOffset = vec3(0);
|
||||
vec4 renderClouds(
|
||||
vec3 fragpositi,
|
||||
vec3 color,
|
||||
float dither,
|
||||
vec3 sunColor,
|
||||
vec3 moonColor,
|
||||
vec3 avgAmbient,
|
||||
float dither2
|
||||
vec3 FragPosition,
|
||||
vec2 Dither,
|
||||
vec3 SunColor,
|
||||
vec3 MoonColor,
|
||||
vec3 SkyColor
|
||||
){
|
||||
#ifndef VOLUMETRIC_CLOUDS
|
||||
return vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
float vL = 0.0;
|
||||
float total_extinction = 1.0;
|
||||
color = vec3(0.0);
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec4 fragposition = gbufferModelViewInverse*vec4(fragpositi,1.0);
|
||||
vec4 fragpos = normalize(gbufferModelViewInverse*vec4(FragPosition,1.0));
|
||||
|
||||
vec3 worldV = normalize(fragposition.rgb);
|
||||
float VdotU = worldV.y;
|
||||
maxIT_clouds = int(clamp( maxIT_clouds / sqrt(exp2(fragpos.y)),0.0, maxIT));
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec4 start = (gbufferModelViewInverse*vec4(0.0,0.0,0.,1.));
|
||||
vec3 dV_view = normalize(fragpos.xyz);
|
||||
|
||||
// vec3 dV_view = worldV;
|
||||
dV_view.y += 0.05;
|
||||
|
||||
// cloud plane curvature
|
||||
float curvature = 0.05;
|
||||
worldV.y += curvature;
|
||||
vec3 dV_view = worldV;
|
||||
worldV.y -= curvature;
|
||||
vec3 dV_view2 = worldV;
|
||||
|
||||
|
||||
|
||||
maxIT_clouds = int(clamp( maxIT_clouds / sqrt(exp2(VdotU)),0.0, maxIT));
|
||||
|
||||
worldV = normalize(worldV)*100000. + cameraPosition; //makes max cloud distance not dependant of render distance
|
||||
dV_view = normalize(dV_view);
|
||||
|
||||
float height = Cloud_Height;
|
||||
int flipClouds = 1;
|
||||
// if (worldV.y < cloud_height){
|
||||
// flipClouds = -1;
|
||||
// };
|
||||
|
||||
if (worldV.y < cloud_height || cameraPosition.y > 390. ) return vec4(0.,0.,0.,1.); //don't trace if no intersection is possible
|
||||
// if (worldV.y < cloud_height && flipClouds == -1) return vec4(0.,0.,0.,1.); //don't trace if no intersection is possible
|
||||
vec3 dV_view2 = dV_view;
|
||||
float mult2 = length(dV_view2);
|
||||
|
||||
//setup ray to start at the start of the cloud plane and end at the end of the cloud plane
|
||||
dV_view *= max(maxHeight - cloud_height, 0.0)/dV_view.y/(maxIT_clouds);
|
||||
|
||||
// dV_view = floor(dV_view/1000)*1000;
|
||||
startOffset = dV_view*dither;
|
||||
|
||||
vec3 camPos = ((cameraPosition*flipClouds)-height)*Cloud_Size;
|
||||
|
||||
vec3 progress_view = startOffset + camPos + dV_view*(cloud_height-camPos.y)/dV_view.y;
|
||||
// progress_view = floor
|
||||
float shadowStep = 200.;
|
||||
vec3 dV_Sun = flipClouds * normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
|
||||
dV_view *= max(MaxCumulusHeight - CumulusHeight, 0.0)/abs(dV_view.y)/maxIT_clouds;
|
||||
float mult = length(dV_view);
|
||||
|
||||
float SdotV = dot(sunVec,normalize(fragpositi));
|
||||
// i want the samples to stay at one point in the world, but as the height coordinates go negative everything goes insideout, so this is a work around....
|
||||
float startFlip = mix(max(cameraPosition.y - MaxCumulusHeight,0.0), max(CumulusHeight-cameraPosition.y,0), clamp(dV_view.y,0,1));
|
||||
// vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip;
|
||||
vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip;
|
||||
|
||||
float spinX = sin(frameTimeCounter *3.14);
|
||||
float spinZ = sin(1.57 + frameTimeCounter*3.14);
|
||||
float SdotV_custom = dot(mat3(gbufferModelView) * normalize(vec3(0,0.1,0)),normalize(fragpositi));
|
||||
|
||||
float phaseLightning = phaseg(SdotV_custom, 0.7);
|
||||
|
||||
// direct light colors and shit for clouds
|
||||
// multiply everything by ~pi just for good luck :D
|
||||
// float mieDayMulti = phaseg(SdotV, 0.35)*3.14;
|
||||
// float mieDay = mix(phaseg(SdotV,0.75), mieDayMulti,0.8)*3.14;
|
||||
// thank you emin for this world interseciton thing
|
||||
// float lViewPosM = length(FragPosition) < far * 1.5 ? length(FragPosition) - 1.0 : 1000000000.0;
|
||||
// bool IntersecTerrain = false;
|
||||
|
||||
float mieDayMulti = phaseg(SdotV, 0.35);
|
||||
float mieDay = (phaseg(SdotV,0.75) + mieDayMulti)*2.0;
|
||||
////// lighitng stuff
|
||||
float shadowStep = 200.;
|
||||
vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
|
||||
|
||||
float mieNightMulti = phaseg(-SdotV, 0.35)*3.14;
|
||||
float mieNight = mix(phaseg(-SdotV,0.9), mieNightMulti,0.5)*3.14;
|
||||
float SdotV = dot(sunVec,normalize(FragPosition));
|
||||
|
||||
vec3 sunContribution = mieDay*sunColor*3.14;
|
||||
vec3 sunContributionMulti = mieDayMulti*sunColor*3.14;
|
||||
SkyColor *= clamp(abs(dV_Sun.y)/100.,0.75,1.0);
|
||||
SunColor = SunColor * clamp(dV_Sun.y ,0.0,1.0);
|
||||
MoonColor *= clamp(-dV_Sun.y,0.0,1.0);
|
||||
|
||||
vec3 moonContribution = mieNight*moonColor*3.14;
|
||||
vec3 moonContributionMulti = mieNightMulti*moonColor*3.14;
|
||||
if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun;
|
||||
|
||||
float ambientMult = 1.0;
|
||||
vec3 skyCol0 = (avgAmbient * ambientMult) ;
|
||||
float mieDay = phaseg(SdotV, 0.75) * 2;
|
||||
float mieDayMulti = phaseg(SdotV, 0.35) * 2;
|
||||
|
||||
vec3 progress_view_high = progress_view + (20000.0-progress_view.y) * dV_view / dV_view.y;
|
||||
float muEshD_high = 0.0;
|
||||
float muEshN_high = 0.0;
|
||||
vec3 sunContribution = SunColor * mieDay;
|
||||
vec3 sunContributionMulti = SunColor * mieDayMulti ;
|
||||
|
||||
float cirrusShadowStep = 7.;
|
||||
float cirrusDensity = 0.03;
|
||||
// progress_view = floor(progress_view/512)*512;
|
||||
float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4) * 6.0;
|
||||
vec3 moonContribution = MoonColor * mieNight;
|
||||
|
||||
float cloud = 0.0;
|
||||
#ifdef Cumulus
|
||||
for(int i=0;i<maxIT_clouds;i++) {
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
cloud = getCloudDensity(progress_view, cloudLoD);
|
||||
#endif
|
||||
// IntersecTerrain = length(progress_view - cameraPosition) > lViewPosM;
|
||||
// if(IntersecTerrain) break;
|
||||
|
||||
// float basefade = clamp( (progress_view.y - 1750 ) / 1750 ,0.0,1.0) ;
|
||||
float basefade = clamp( (progress_view.y - (maxHeight+cloud_height)*0.25) / ((maxHeight+cloud_height)*0.5) ,0.0,1.0) ;
|
||||
// float basefade = clamp( exp( (progress_view.y - (maxHeight+cloud_height)*0.5 ) / 5/00) ,0.0,1.0) ;
|
||||
float cumulus = GetCumulusDensity(progress_view, cloudLoD);
|
||||
|
||||
float densityofclouds = basefade*cloudDensity ;
|
||||
float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight + CumulusHeight)*0.455) / 9.0 ),0.0,1.0);
|
||||
|
||||
if(cloud >= 0.0){
|
||||
float muS = cloud*densityofclouds;
|
||||
float muE = cloud*densityofclouds;
|
||||
if(cumulus > 1e-5){
|
||||
float muE = cumulus*alteredDensity;
|
||||
|
||||
float Sunlight = 0.0;
|
||||
float MoonLight = 0.0;
|
||||
|
||||
float muEshD = 0.0;
|
||||
if (sunContribution.g > 1e-5){
|
||||
for (int j=0; j < self_shadow_samples; j++){
|
||||
float sample = j+dither2;
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// low altitude clouds shadows
|
||||
vec3 shadowSamplePos = progress_view + dV_Sun * (sample + sample*2.0);
|
||||
vec3 shadowSamplePos = progress_view + dV_Sun * (1+j+Dither.y/2)*0.15;
|
||||
float shadow = GetCumulusDensity(shadowSamplePos, 0) * Cumulus_density;
|
||||
|
||||
Sunlight += shadow;
|
||||
MoonLight += shadow;
|
||||
|
||||
if (shadowSamplePos.y < maxHeight){
|
||||
float cloudS = getCloudDensity(vec3(shadowSamplePos), cloudShadowLoD);
|
||||
muEshD += cloudS*cloudDensity*shadowStep;
|
||||
}
|
||||
|
||||
#ifdef Altostratus
|
||||
// cast a shadow from higher clouds onto lower clouds
|
||||
vec3 HighAlt_shadowPos = progress_view + dV_Sun/abs(dV_Sun.y) * max(AltostratusHeight - progress_view.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * Alto_density ;
|
||||
Sunlight += HighAlt_shadow;
|
||||
#endif
|
||||
|
||||
#ifdef High_Altitude_Clouds
|
||||
// high altitude clouds shadows
|
||||
vec3 shadowSamplePos_high = progress_view_high + dV_Sun * (sample + sample*2.0);
|
||||
float highAlt_cloudS = HighAltitudeClouds(shadowSamplePos_high);
|
||||
muEshD_high += highAlt_cloudS*cirrusDensity*cirrusShadowStep;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
float muEshN = 0.0;
|
||||
if (moonContribution.g > 1e-5){
|
||||
for (int j=0; j<self_shadow_samples; j++){
|
||||
float sample = j+dither2;
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// low altitude clouds shadows
|
||||
vec3 shadowSamplePos = progress_view - dV_Sun * (sample + sample*2.0);
|
||||
if (shadowSamplePos.y < maxHeight){
|
||||
float cloudS = getCloudDensity(vec3(shadowSamplePos), cloudShadowLoD);
|
||||
muEshN += cloudS*cloudDensity*shadowStep;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef High_Altitude_Clouds
|
||||
// high altitude clouds shadows
|
||||
vec3 shadowSamplePos_high = progress_view_high - dV_Sun * (sample + sample*2.0);
|
||||
float highAlt_cloudS = HighAltitudeClouds(shadowSamplePos_high);
|
||||
muEshN_high += highAlt_cloudS*cirrusDensity*cirrusShadowStep;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// clamp(abs(dV_Sun.y)/150.0,0.5,1.0)
|
||||
float muEshA = cloud*cloudDensity ;
|
||||
vec3 S = Cloud_lighting(progress_view, muE, muEshA, muEshD, muEshN, skyCol0 * max(abs(dV_Sun.y)/150.0,0.5), sunContribution, sunContributionMulti, moonContribution, moonContributionMulti, 0);
|
||||
|
||||
// float bottom = clamp( (progress_view.y-3250.*0.6) / 1000. ,0.0,1.0) ;
|
||||
// float location = bottom * (muEshA*5000) * pow(phaseLightning,1.5);
|
||||
// vec3 lightningLighting = lightningFlash * vec3(0.5,0.75,1) * location * max(dV_Sun.y,1.);
|
||||
// S += lightningLighting ;
|
||||
float ambientlightshadow = 1.0-clamp(exp((progress_view.y - (MaxCumulusHeight + CumulusHeight)*0.5) / 100.0),0.0,1.0);
|
||||
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0);
|
||||
|
||||
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
|
||||
color += max(muS*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-muE*mult),0);
|
||||
color += max(muE*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-mult*muE),0.0);
|
||||
|
||||
if (total_extinction < 1e-5) break;
|
||||
#endif
|
||||
}
|
||||
progress_view += dV_view;
|
||||
}
|
||||
#endif
|
||||
|
||||
// do this aftewards because stinky
|
||||
#ifdef High_Altitude_Clouds
|
||||
float cirrus = HighAltitudeClouds(progress_view_high);
|
||||
if (cirrus >= 0.0){
|
||||
float muS = cirrus*cirrusDensity;
|
||||
float muE = cirrus*cirrusDensity;
|
||||
|
||||
float muEshA_high = cirrus*cirrusDensity;
|
||||
#ifdef Altostratus
|
||||
if (max(AltostratusHeight-cameraPosition.y,0.0)/max(normalize(dV_view).y,0.0) / 100000.0 < AltostratusHeight) {
|
||||
|
||||
vec3 S = Cloud_lighting(progress_view, muE, muEshA_high, muEshD_high, muEshN_high, skyCol0 * max(abs(dV_Sun.y)/150.0,0.5) , sunContribution, sunContributionMulti, moonContribution, moonContributionMulti, 1);
|
||||
vec3 progress_view_high = dV_view2 + cameraPosition + dV_view2/dV_view2.y * max(AltostratusHeight-cameraPosition.y,0.0);
|
||||
float altostratus = GetAltostratusDensity(progress_view_high) * Alto_density;
|
||||
|
||||
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
|
||||
color += max(muS*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-muE*mult),0);
|
||||
float Sunlight = 0.0;
|
||||
float MoonLight = 0.0;
|
||||
|
||||
if(altostratus > 1e-5){
|
||||
for (int j = 0; j < 2; j++){
|
||||
vec3 shadowSamplePos_high = progress_view_high + dV_Sun * float(j+Dither.y);
|
||||
float shadow = GetAltostratusDensity(shadowSamplePos_high) * Alto_density;
|
||||
Sunlight += shadow;
|
||||
}
|
||||
vec3 S = Cloud_lighting(altostratus, altostratus, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, 1, 1);
|
||||
|
||||
vec3 Sint = (S - S * exp(-20*altostratus)) / altostratus;
|
||||
color += max(altostratus*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-20*altostratus),0.0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 normView = normalize(dV_view2)*flipClouds;
|
||||
vec3 normView = normalize(dV_view);
|
||||
// Assume fog color = sky gradient at long distance
|
||||
vec3 fogColor = skyFromTex(normView, colortex4)/150.;
|
||||
float dist = (cloud_height - (cameraPosition.y))/normalize(dV_view2).y;
|
||||
float fog = exp(-dist/15000.0*(1.0+rainCloudwetness*8.));
|
||||
vec3 fogColor = skyFromTex(normView, colortex4)/150. * 5.0;
|
||||
float dist = max(cameraPosition.y+CumulusHeight,CumulusHeight)/abs(normView.y);
|
||||
float fog = exp(dist / -5000.0 * (1.0+rainCloudwetness*8.));
|
||||
|
||||
// if(IntersecTerrain) fog = 1.0;
|
||||
|
||||
return mix(vec4(fogColor,0.0), vec4(color,total_extinction), fog);
|
||||
// return vec4(color,total_extinction);
|
||||
}
|
||||
|
||||
float GetCloudShadow(vec3 eyePlayerPos){
|
||||
vec3 playerPos = eyePlayerPos + cameraPosition;
|
||||
playerPos.y += 0.05;
|
||||
float shadow;
|
||||
|
||||
// assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud.
|
||||
#ifdef Cumulus
|
||||
vec3 lowShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight + CumulusHeight)*0.44 - playerPos.y,0.0) ;
|
||||
shadow += GetCumulusDensity(lowShadowStart,1)*cloudDensity;
|
||||
#endif
|
||||
|
||||
#ifdef Altostratus
|
||||
vec3 highShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - playerPos.y,0.0);
|
||||
shadow += GetAltostratusDensity(highShadowStart) * Alto_density;
|
||||
#endif
|
||||
|
||||
shadow = clamp(exp(-shadow*10.0),0.0,1.0);
|
||||
|
||||
return shadow;
|
||||
}
|
||||
float GetCloudShadow_VLFOG(vec3 WorldPos){
|
||||
|
||||
float shadow;
|
||||
|
||||
// assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud.
|
||||
#ifdef Cumulus
|
||||
vec3 lowShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y,0.0) ;
|
||||
shadow += GetCumulusDensity(lowShadowStart,0)*cloudDensity;
|
||||
#endif
|
||||
|
||||
#ifdef Altostratus
|
||||
vec3 highShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - WorldPos.y,0.0);
|
||||
shadow += GetAltostratusDensity(highShadowStart) * Alto_density;
|
||||
#endif
|
||||
|
||||
shadow = clamp(exp(-shadow*15.0),0.0,1.0);
|
||||
|
||||
// do not allow it to exist above the lowest cloud plane
|
||||
shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ;
|
||||
|
||||
return shadow;
|
||||
}
|
@ -1,35 +1,19 @@
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float phaseRayleigh(float cosTheta) {
|
||||
const vec2 mul_add = vec2(0.1, 0.28) /acos(-1.0);
|
||||
return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation
|
||||
}
|
||||
|
||||
|
||||
// #define TIMEOFDAYFOG
|
||||
// #include "/lib/climate_settings.glsl"
|
||||
// uniform int worldTime;
|
||||
|
||||
// void TimeOfDayFog( inout float Uniform, inout float Cloudy) {
|
||||
|
||||
// float Time = (worldTime%24000)*1.0;
|
||||
|
||||
// // set schedules for fog to appear at specific ranges of time in the day.
|
||||
// float Morning = clamp((Time-22000)/2000,0,1) + clamp((2000-Time)/2000,0,1);
|
||||
// float Noon = clamp(Time/2000,0,1) * clamp((12000-Time)/2000,0,1);
|
||||
// float Evening = clamp((Time-10000)/2000,0,1) * clamp((14000-Time)/2000,0,1) ;
|
||||
// float Night = clamp((Time-12000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
|
||||
|
||||
// vec4 UniformDensity = vec4(0, 55, 0, 0);
|
||||
// vec4 CloudyDensity = vec4(0, 0, 0, 0);
|
||||
|
||||
|
||||
// Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a;
|
||||
// Cloudy *= Morning*CloudyDensity.r + Noon*CloudyDensity.g + Evening*CloudyDensity.b + Night*CloudyDensity.a;
|
||||
// }
|
||||
float densityAtPosFog(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
f = (f*f) * (3.-2.*f);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
|
||||
@ -37,24 +21,28 @@ float cloudVol(in vec3 pos){
|
||||
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
|
||||
float mult = exp2( -max((pos.y - SEA_LEVEL) / 35.,0.0));
|
||||
float mult = exp( -max((pos.y - SEA_LEVEL) / 35.,0.0));
|
||||
|
||||
float fog_shape = 1-densityAtPos(samplePos * 24.0);
|
||||
float fog_eroded = densityAtPos( samplePos2 * 150.0);
|
||||
float fog_shape = 1.0 - densityAtPosFog(samplePos * 24.0);
|
||||
float fog_eroded = 1.0 - densityAtPosFog( samplePos2 * 200.0);
|
||||
|
||||
// float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.2, max(fog_shape-0.8,0.0)) * mult;
|
||||
|
||||
float CloudyFog = max((fog_shape*1.2 - fog_eroded*0.2) - 0.75,0.0) ;
|
||||
|
||||
float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.4, 0.0) * mult;
|
||||
float UniformFog = exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0));
|
||||
|
||||
float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength;
|
||||
float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength * RainFog_amount;
|
||||
|
||||
TimeOfDayFog(UniformFog, CloudyFog);
|
||||
|
||||
return RainFog + CloudyFog + UniformFog;
|
||||
return CloudyFog + UniformFog + RainFog;
|
||||
}
|
||||
|
||||
mat2x3 getVolumetricRays(
|
||||
vec4 getVolumetricRays(
|
||||
vec3 fragpos,
|
||||
float dither,
|
||||
vec3 fragpos
|
||||
vec3 AmbientColor
|
||||
){
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
@ -76,7 +64,6 @@ mat2x3 getVolumetricRays(
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
|
||||
vec3 vL = vec3(0.);
|
||||
|
||||
@ -88,23 +75,23 @@ mat2x3 getVolumetricRays(
|
||||
float rayL = phaseRayleigh(SdotV);
|
||||
|
||||
// Makes fog more white idk how to simulate it correctly
|
||||
vec3 sunColor = lightCol.rgb / 5.0;
|
||||
vec3 skyCol0 = (ambientUp / 5.0 * 5.); // * max(abs(WsunVec.y)/150.0,0.);
|
||||
vec3 sunColor = lightCol.rgb / 80.0;
|
||||
vec3 skyCol0 = AmbientColor / 150. * 5.; // * max(abs(WsunVec.y)/150.0,0.);
|
||||
|
||||
vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5);
|
||||
vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6);
|
||||
|
||||
float mu = 1.0;
|
||||
float muS = mu;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float absorbance = 1.0;
|
||||
float expFactor = 11.0;
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
|
||||
|
||||
float cloudShadow = 1.0;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
|
||||
for (int i=0;i<VL_SAMPLES2;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES2))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES2)) * log(expFactor) / float(VL_SAMPLES2)/(expFactor-1.0);
|
||||
for (int i=0;i<VL_SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
//project into biased shadowmap space
|
||||
@ -112,51 +99,44 @@ mat2x3 getVolumetricRays(
|
||||
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
|
||||
float densityVol = cloudVol(progressW);
|
||||
float sh = 1.0;
|
||||
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
float max_height = clamp(400.0 - progressW.y, 0.0,1.0); // so it doesnt go beyond the height of the clouds
|
||||
vec3 campos = (progressW)-319;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
cloudShadow = exp(-cloudShadow*cloudDensity*200);
|
||||
cloudShadow *= max_height;
|
||||
// cloudShadow *= 1000; //debug
|
||||
#endif
|
||||
#endif
|
||||
sh *= GetCloudShadow_VLFOG(progressW);
|
||||
#endif
|
||||
|
||||
//Water droplets(fog)
|
||||
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 16;
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24 * Haze_amount;
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density)*mC;
|
||||
|
||||
vec3 rainRays = (sunColor*sh*cloudShadow) * (rayL*phaseg(SdotV,0.6)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength;
|
||||
|
||||
vec3 DirectLight = (sunColor*sh*cloudShadow) * (rayL*rL+m*mie);
|
||||
vec3 DirectLight = (sunColor*sh) * (rayL*rL+m*mie);
|
||||
vec3 AmbientLight = skyCol0 * m;
|
||||
|
||||
vec3 AtmosphericFog = skyCol0 * (rL+m) ;
|
||||
|
||||
vec3 vL0 = (DirectLight +AmbientLight+AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240.;
|
||||
// extra fog effects
|
||||
vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount;
|
||||
vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
|
||||
|
||||
// vec3 RAAAAY = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) ;
|
||||
|
||||
vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
|
||||
|
||||
#ifdef Biome_specific_environment
|
||||
BiomeFogColor(vL0);
|
||||
BiomeFogColor(vL0); // ?????
|
||||
#endif
|
||||
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
|
||||
absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0);
|
||||
|
||||
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
|
||||
absorbance *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
return vec4(vL,absorbance);
|
||||
}
|
@ -1,41 +1,60 @@
|
||||
|
||||
//#define Vanilla_like_water // vanilla water texture along with shader water stuff
|
||||
|
||||
|
||||
float getWaterHeightmap(vec2 posxz, float waveM, float waveZ, float iswater) { // water waves
|
||||
vec2 pos = posxz;
|
||||
float moving = clamp(iswater*2.-1.0,0.0,1.0);
|
||||
vec2 movement = vec2(-0.035*frameTimeCounter*moving);
|
||||
float caustic = 0.0;
|
||||
vec2 movement = vec2(frameTimeCounter*0.05);
|
||||
vec2 pos = posxz ;
|
||||
float caustic = 1.0;
|
||||
float weightSum = 0.0;
|
||||
|
||||
float radiance = 2.39996;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
const vec2 wave_size[4] = vec2[](
|
||||
vec2(600.),
|
||||
vec2(32.,16.),
|
||||
vec2(16.,32.),
|
||||
vec2(48.)
|
||||
const vec2 wave_size[3] = vec2[](
|
||||
vec2(48.,12.),
|
||||
vec2(12.,48.),
|
||||
vec2(32.)
|
||||
);
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
pos = rotationMatrix * pos;
|
||||
float WavesLarge = clamp( pow(1.0-pow(1.0-texture2D(noisetex, pos / 600.0 ).b, 5.0),5.0),0.1,1.0);
|
||||
// float WavesLarge = pow(abs(0.5-texture2D(noisetex, pos / 600.0 ).b),2);
|
||||
|
||||
vec2 speed = movement;
|
||||
float waveStrength = 1.0;
|
||||
for (int i = 0; i < 3; i++){
|
||||
pos = rotationMatrix * pos ;
|
||||
|
||||
if( i == 0) {
|
||||
speed *= 0.15;
|
||||
waveStrength = 7.0;
|
||||
float Waves = texture2D(noisetex, pos / wave_size[i] + (1.0-WavesLarge)*0.5 + movement).b;
|
||||
|
||||
|
||||
caustic += exp2(pow(Waves,3.0) * -5.0);
|
||||
weightSum += exp2(-(3.0-caustic*pow(WavesLarge,2)));
|
||||
}
|
||||
|
||||
float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength;
|
||||
|
||||
caustic += small_wave;
|
||||
weightSum -= exp2(caustic);
|
||||
}
|
||||
return caustic / weightSum;
|
||||
return ((3.0-caustic) * weightSum / (30.0 * 3.0));
|
||||
}
|
||||
// float getWaterHeightmap(vec2 posxz, float waveM, float waveZ, float iswater) { // water waves
|
||||
// vec2 movement = vec2(frameTimeCounter*0.025);
|
||||
// vec2 pos = posxz ;
|
||||
// float caustic = 1.0;
|
||||
// float weightSum = 0.0;
|
||||
|
||||
// float radiance = 2.39996;
|
||||
// mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
// const vec2 wave_size[3] = vec2[](
|
||||
// vec2(60.,30.),
|
||||
// vec2(30.,60.),
|
||||
// vec2(45.)
|
||||
// );
|
||||
|
||||
// float WavesLarge = pow(abs(0.5-texture2D(noisetex, pos / 600.0 ).b),2);
|
||||
|
||||
// for (int i = 0; i < 3; i++){
|
||||
// pos = rotationMatrix * pos ;
|
||||
|
||||
// float Waves = 1.0-exp(pow(abs(0.5-texture2D(noisetex, pos / (wave_size[i] ) + movement).b),1.3) * -10) ;
|
||||
|
||||
// caustic += Waves*0.1;
|
||||
// weightSum += exp2(-caustic*pow(WavesLarge,2));
|
||||
// }
|
||||
// return caustic * weightSum/ 30;
|
||||
// }
|
||||
|
||||
|
||||
vec3 getWaveHeight(vec2 posxz, float iswater){
|
||||
|
||||
|
81
shaders/programs/all_particles.fsh
Normal file
81
shaders/programs/all_particles.fsh
Normal file
@ -0,0 +1,81 @@
|
||||
// #version 120
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2DShadow shadow;
|
||||
uniform sampler2D gaux1;
|
||||
uniform sampler2D noisetex;
|
||||
uniform float frameTimeCounter;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float rainStrength;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 shadowModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#include "/lib/diffuse_lighting.glsl"
|
||||
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
|
||||
vec3 toScreenSpace(vec3 p) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
|
||||
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 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
/* DRAWBUFFERS:2 */
|
||||
void main() {
|
||||
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color;
|
||||
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
|
||||
vec2 tempOffset = offsets[framemod8];
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
|
||||
vec3 Indirect_lighting = DoAmbientLighting_Nether(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.z, normalize(vec3(0.0)), normalize(vec3(0.0)), p3 + cameraPosition);
|
||||
|
||||
gl_FragData[0].rgb = Indirect_lighting * Albedo;
|
||||
}
|
45
shaders/programs/all_particles.vsh
Normal file
45
shaders/programs/all_particles.vsh
Normal file
@ -0,0 +1,45 @@
|
||||
// #version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
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//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
|
||||
#endif
|
||||
}
|
@ -1,26 +1,11 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#extension GL_ARB_shader_texture_lod : enable
|
||||
//#define Specular_Reflections // reflections on blocks. REQUIRES A PBR RESOURCEPACK.
|
||||
//#define POM
|
||||
#define POM_MAP_RES 128.0 // [16.0 32.0 64.0 128.0 256.0 512.0 1024.0] Increase to improve POM quality
|
||||
#define POM_DEPTH 0.1 // [0.025 0.05 0.075 0.1 0.125 0.15 0.20 0.25 0.30 0.50 0.75 1.0] //Increase to increase POM strength
|
||||
#define MAX_ITERATIONS 50 // [5 10 15 20 25 30 40 50 60 70 80 90 100 125 150 200 400] //Improves quality at grazing angles (reduces performance)
|
||||
#define MAX_DIST 25.0 // [5.0 10.0 15.0 20.0 25.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 125.0 150.0 200.0 400.0] //Increases distance at which POM is calculated
|
||||
//#define USE_LUMINANCE_AS_HEIGHTMAP //Can generate POM on any texturepack (may look weird in some cases)
|
||||
#define Texture_MipMap_Bias -1.00 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
|
||||
#define DISABLE_ALPHA_MIPMAPS //Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
|
||||
#define SSAO // screen-space ambient occlusion.
|
||||
#define texture_ao // ambient occlusion on the texture
|
||||
|
||||
#define Puddle_Size 1.0 // [0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5]
|
||||
#ifdef Specular_Reflections
|
||||
#define Puddles // yes
|
||||
#else
|
||||
// #define Puddles // yes
|
||||
#endif
|
||||
// #define Porosity
|
||||
flat varying int NameTags;
|
||||
|
||||
#ifndef USE_LUMINANCE_AS_HEIGHTMAP
|
||||
#ifndef MC_NORMAL_MAP
|
||||
@ -32,9 +17,11 @@
|
||||
#define MC_NORMAL_MAP
|
||||
#endif
|
||||
|
||||
|
||||
varying float VanillaAO;
|
||||
|
||||
const float mincoord = 1.0/4096.0;
|
||||
const float maxcoord = 1.0-mincoord;
|
||||
const vec3 intervalMult = vec3(1.0, 1.0, 1.0/POM_DEPTH)/POM_MAP_RES * 1.0;
|
||||
|
||||
const float MAX_OCCLUSION_DISTANCE = MAX_DIST;
|
||||
const float MIX_OCCLUSION_DISTANCE = MAX_DIST*0.9;
|
||||
@ -48,9 +35,12 @@ varying vec4 vtexcoordam; // .st for add, .pq for mul
|
||||
varying vec4 vtexcoord;
|
||||
|
||||
#endif
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 NoSeasonCol;
|
||||
varying vec4 seasonColor;
|
||||
uniform float far;
|
||||
varying vec4 normalMat;
|
||||
#ifdef MC_NORMAL_MAP
|
||||
@ -58,6 +48,7 @@ varying vec4 tangent;
|
||||
uniform float wetness;
|
||||
uniform sampler2D normals;
|
||||
uniform sampler2D specular;
|
||||
varying vec3 FlatNormals;
|
||||
#endif
|
||||
|
||||
#ifdef POM
|
||||
@ -80,20 +71,23 @@ uniform sampler2D noisetex;//depth
|
||||
uniform sampler2D depthtex0;
|
||||
in vec3 test_motionVectors;
|
||||
|
||||
varying vec4 materialMask;
|
||||
flat varying float blockID;
|
||||
|
||||
flat varying vec4 TESTMASK;
|
||||
|
||||
// float interleaved_gradientNoise(){
|
||||
// return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521);
|
||||
// }
|
||||
// float interleaved_gradientNoise(){
|
||||
// vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
// vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
// float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
// return noise;
|
||||
// }
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
@ -144,11 +138,6 @@ vec4 encode (vec3 n, vec2 lightmaps){
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
// vec3 applyBump(mat3 tbnMatrix, vec3 bump){
|
||||
// float bumpmult = 1.0;
|
||||
// bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
// return normalize(bump*tbnMatrix);
|
||||
// }
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){
|
||||
float bumpmult = clamp(puddle_values,0.0,1.0);
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
@ -206,15 +195,39 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
vec3 srgbToLinear2(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
}
|
||||
vec3 blackbody2(float Temp)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp(col,0.0,1.0);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
|
||||
|
||||
|
||||
// float getPuddleCoverage(vec3 samplePos){
|
||||
// float puddle = texture2D(noisetex, samplePos.xz/25000).b ;
|
||||
|
||||
// return max(puddle,0.0);
|
||||
// }
|
||||
return srgbToLinear2(col);
|
||||
}
|
||||
float densityAtPosSNOW(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
f = (f*f) * (3.-2.*f);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -222,17 +235,15 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
/* RENDERTARGETS: 1,7,8,13 */
|
||||
/* RENDERTARGETS: 1,7,8,15,10 */
|
||||
void main() {
|
||||
|
||||
#ifdef BLOCK_ENT
|
||||
gl_FragData[3] = TESTMASK;
|
||||
#endif
|
||||
|
||||
float phi = 2 * 3.14159265359;
|
||||
float noise = fract(fract(frameCounter * (1.0 / phi)) + interleaved_gradientNoise() ) ;
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec3 normal2 = normalMat.xyz;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
@ -240,30 +251,15 @@ void main() {
|
||||
tangent.y, tangent2.y, normal.y,
|
||||
tangent.z, tangent2.z, normal.z);
|
||||
#endif
|
||||
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
|
||||
|
||||
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
float lightmap = clamp( (lmtexcoord.w-0.66) * 5.0,0.,1.);
|
||||
|
||||
float rainfall = 0. ;
|
||||
float Puddle_shape = 0.;
|
||||
float puddle_shiny = 1.;
|
||||
float puddle_normal = 0.;
|
||||
|
||||
#ifndef ENTITIES
|
||||
#ifdef WORLD
|
||||
#ifdef Puddles
|
||||
rainfall = rainStrength ;
|
||||
Puddle_shape = 1.0 - max(texture2D(noisetex, worldpos.xz * (0.015 * Puddle_Size)).b - (1.0-lightmap) ,0.0);
|
||||
puddle_shiny = clamp( pow(1.0-Puddle_shape,2.0)*2,0.5,1.) ;
|
||||
puddle_normal = clamp( pow(Puddle_shape,5.0) * 50. ,0.,1.) ;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.);
|
||||
|
||||
|
||||
#ifdef POM
|
||||
// vec2 tempOffset=offsets[framemod8];
|
||||
@ -277,13 +273,26 @@ void main() {
|
||||
#ifdef WORLD
|
||||
if (dist < MAX_OCCLUSION_DISTANCE) {
|
||||
|
||||
if ( viewVector.z < 0.0 && readNormal(vtexcoord.st).a < 0.9999 && readNormal(vtexcoord.st).a > 0.00001) {
|
||||
float depthmap = readNormal(vtexcoord.st).a;
|
||||
float used_POM_DEPTH = 1.0;
|
||||
|
||||
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
|
||||
|
||||
#ifdef Adaptive_Step_length
|
||||
vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0) ;
|
||||
used_POM_DEPTH = 1.0;
|
||||
#else
|
||||
vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH;
|
||||
#endif
|
||||
vec3 coord = vec3(vtexcoord.st, 1.0);
|
||||
coord += noise*interval;
|
||||
float sumVec = noise;
|
||||
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH*readNormal(coord.st).a < coord.p) && coord.p >= 0.0; ++loopCount) { coord = coord+interval; sumVec += 1.0; }
|
||||
|
||||
coord += interval * used_POM_DEPTH;
|
||||
|
||||
float sumVec = 0.5;
|
||||
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) {
|
||||
coord = coord+interval * used_POM_DEPTH;
|
||||
sumVec += 1.0 * used_POM_DEPTH;
|
||||
}
|
||||
|
||||
if (coord.t < mincoord) {
|
||||
if (readTexture(vec2(coord.s,mincoord)).a == 0.0) {
|
||||
@ -301,93 +310,104 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
// color
|
||||
vec4 data0 = texture2DGradARB(texture, adjustedTexCoord.xy,dcdx,dcdy);
|
||||
////////////////////////////////
|
||||
//////////////////////////////// ALBEDO
|
||||
////////////////////////////////
|
||||
|
||||
#ifdef DISABLE_ALPHA_MIPMAPS
|
||||
data0.a = texture2DGradARB(texture, adjustedTexCoord.xy,vec2(0.),vec2(0.0)).a;
|
||||
vec4 Albedo = texture2DGradARB(texture, adjustedTexCoord.xy,dcdx,dcdy) * color;
|
||||
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
#endif
|
||||
|
||||
data0.rgb *= color.rgb;
|
||||
float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
|
||||
data0.rgb = clamp(data0.rgb*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
|
||||
|
||||
|
||||
#ifdef WORLD
|
||||
if (data0.a > 0.1) data0.a = normalMat.a;
|
||||
else data0.a = 0.0;
|
||||
if (Albedo.a > 0.1) Albedo.a = normalMat.a;
|
||||
else Albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef HAND
|
||||
if (data0.a > 0.1) data0.a = 0.75;
|
||||
else data0.a = 0.0;
|
||||
if (Albedo.a > 0.1) Albedo.a = 0.75;
|
||||
else Albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
// normal
|
||||
////////////////////////////////
|
||||
//////////////////////////////// NORMAL
|
||||
////////////////////////////////
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec3 normalTex = texture2DGradARB(normals, adjustedTexCoord.xy, dcdx,dcdy).rgb;
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0);
|
||||
normal = applyBump(tbnMatrix,normalTex, mix(1.0,puddle_normal,rainfall));
|
||||
vec3 NormalTex = texture2DGradARB(normals, adjustedTexCoord.xy, dcdx,dcdy).rgb;
|
||||
NormalTex.xy = NormalTex.xy*2.0-1.0;
|
||||
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0);
|
||||
|
||||
normal = applyBump(tbnMatrix,NormalTex, 1.0);
|
||||
#endif
|
||||
|
||||
// specular
|
||||
////////////////////////////////
|
||||
//////////////////////////////// SPECULAR
|
||||
////////////////////////////////
|
||||
|
||||
gl_FragData[2] = texture2DGradARB(specular, adjustedTexCoord.xy,dcdx,dcdy);
|
||||
|
||||
// finalize
|
||||
////////////////////////////////
|
||||
//////////////////////////////// FINALIZE
|
||||
////////////////////////////////
|
||||
|
||||
vec4 data1 = clamp(encode(viewToWorld(normal), lmtexcoord.zw),0.,1.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(data0.x,data1.x),encodeVec2(data0.y,data1.y),encodeVec2(data0.z,data1.z),encodeVec2(data1.w,data0.w));
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x),encodeVec2(Albedo.y,data1.y),encodeVec2(Albedo.z,data1.z),encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
gl_FragData[1].a = 0.0;
|
||||
|
||||
#else
|
||||
// specular
|
||||
vec4 specular = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
vec4 specular_modded = vec4( max(specular.r,puddle_shiny), max(specular.g, puddle_shiny*0.1),specular.ba);
|
||||
gl_FragData[2].rgba = mix(specular, specular_modded, rainfall);
|
||||
|
||||
float porosity = specular.z >= 64.5/255.0 ? 0.0 : (specular.z*255.0/64.0)*0.65;
|
||||
#ifndef Porosity
|
||||
porosity = 0.4;
|
||||
#endif
|
||||
// normal
|
||||
////////////////////////////////
|
||||
//////////////////////////////// NORMAL
|
||||
////////////////////////////////
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec4 normalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0) ;
|
||||
normal = applyBump(tbnMatrix, normalTex.xyz, mix(1.0,puddle_normal, rainfall) );
|
||||
vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
NormalTex.xy = NormalTex.xy*2.0-1.0;
|
||||
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ;
|
||||
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0);
|
||||
#endif
|
||||
|
||||
// color
|
||||
vec4 data0 = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) ;
|
||||
|
||||
data0.rgb *= mix(color.rgb, vec3(0.0), max((puddle_shiny*porosity)*0.5,0) * rainfall );
|
||||
////////////////////////////////
|
||||
//////////////////////////////// SPECULAR
|
||||
////////////////////////////////
|
||||
|
||||
vec4 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias);
|
||||
gl_FragData[2] = SpecularTex;
|
||||
|
||||
////////////////////////////////
|
||||
//////////////////////////////// ALBEDO
|
||||
////////////////////////////////
|
||||
|
||||
vec4 Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
|
||||
|
||||
|
||||
float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
|
||||
data0.rgb = clamp(data0.rgb*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
|
||||
|
||||
#ifndef ENTITIES
|
||||
if(TESTMASK.r==255) data0.rgb = vec3(0);
|
||||
#ifdef WhiteWorld
|
||||
Albedo.rgb = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_ALPHA_MIPMAPS
|
||||
data0.a = texture2DLod(texture,lmtexcoord.xy,0).a;
|
||||
#endif
|
||||
#ifdef WORLD
|
||||
if (data0.a > 0.1) data0.a = normalMat.a;
|
||||
else data0.a = 0.0;
|
||||
|
||||
if (Albedo.a > 0.1) Albedo.a = normalMat.a;
|
||||
else Albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef HAND
|
||||
if (data0.a > 0.1) data0.a = 0.75;
|
||||
else data0.a = 0.0;
|
||||
if (Albedo.a > 0.1) Albedo.a = 0.75;
|
||||
else Albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
// finalize
|
||||
vec4 data1 = clamp(blueNoise()/255.0 + encode(viewToWorld(normal), lmtexcoord.zw),0.0,1.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(data0.x,data1.x), encodeVec2(data0.y,data1.y), encodeVec2(data0.z,data1.z), encodeVec2(data1.w,data0.w));
|
||||
////////////////////////////////
|
||||
//////////////////////////////// FINALIZE
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), blueNoise()*lmtexcoord.zw/50.0+lmtexcoord.zw ),0.0,1.0);
|
||||
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
#ifdef WORLD
|
||||
gl_FragData[1].a = 0.0;
|
||||
@ -395,17 +415,12 @@ void main() {
|
||||
|
||||
#endif
|
||||
|
||||
gl_FragData[3] = vec4(FlatNormals* 0.5 + 0.5,VanillaAO);
|
||||
|
||||
|
||||
gl_FragData[4].x = 0;
|
||||
|
||||
#ifdef ENTITIES
|
||||
#ifdef WORLD
|
||||
gl_FragData[3].xyz = test_motionVectors;
|
||||
gl_FragData[4].x = 1;
|
||||
#endif
|
||||
#endif
|
||||
// float z = texture2D(depthtex0,texcoord).x;
|
||||
// vec3 fragpos = toScreenSpace(vec3(texcoord,z));
|
||||
// gl_FragData[0].rgb *= vec3(1- clamp( pow( length(fragpos)/far, 1), 0, 1)) ;
|
||||
|
||||
|
||||
|
||||
}
|
140
shaders/programs/all_solid.vsh
Normal file
140
shaders/programs/all_solid.vsh
Normal file
@ -0,0 +1,140 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef USE_LUMINANCE_AS_HEIGHTMAP
|
||||
#ifndef MC_NORMAL_MAP
|
||||
#undef POM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef POM
|
||||
#define MC_NORMAL_MAP
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 color;
|
||||
varying float VanillaAO;
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 normalMat;
|
||||
|
||||
#ifdef POM
|
||||
varying vec4 vtexcoordam; // .st for add, .pq for mul
|
||||
varying vec4 vtexcoord;
|
||||
#endif
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
attribute vec4 at_tangent;
|
||||
varying vec3 FlatNormals;
|
||||
#endif
|
||||
|
||||
|
||||
attribute vec4 mc_Entity;
|
||||
uniform int blockEntityId;
|
||||
uniform int entityId;
|
||||
|
||||
flat varying float blockID;
|
||||
|
||||
flat varying int NameTags;
|
||||
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
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.);
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
|
||||
FlatNormals = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
NameTags = 0;
|
||||
blockID = mc_Entity.x;
|
||||
|
||||
#ifdef POM
|
||||
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texcoordminusmid = lmtexcoord.xy-midcoord;
|
||||
vtexcoordam.pq = abs(texcoordminusmid)*2;
|
||||
vtexcoordam.st = min(lmtexcoord.xy,midcoord-texcoordminusmid);
|
||||
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
|
||||
#endif
|
||||
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
VanillaAO = 1.0 - clamp(color.a,0,1);
|
||||
if (color.a < 0.3) color.a = 1.0; // fix vanilla ao on some custom block models.
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0);
|
||||
|
||||
#ifdef ENTITIES
|
||||
// try and single out nametag text and then discard nametag background
|
||||
if( dot(gl_Color.rgb, vec3(0.35)) < 1.0) NameTags = 1;
|
||||
|
||||
if(gl_Color.a >= 0.24 && gl_Color.a <= 0.25 ) gl_Position = vec4(10,10,10,1);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef WORLD
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),mc_Entity.x == 10004 || mc_Entity.x == 10003 ? 0.5 : mc_Entity.x == 10001 ? 0.6 : 1.0);
|
||||
|
||||
normalMat.a = mc_Entity.x == 10005 ? 0.8 : normalMat.a;
|
||||
|
||||
if (mc_Entity.x == 100 ){
|
||||
color.rgb = normalize(color.rgb)*sqrt(3.0);
|
||||
normalMat.a = 0.9;
|
||||
}
|
||||
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
#endif
|
||||
|
||||
#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
|
||||
}
|
576
shaders/programs/all_translucent.fsh
Normal file
576
shaders/programs/all_translucent.fsh
Normal file
@ -0,0 +1,576 @@
|
||||
// #version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
uniform sampler2D normals;
|
||||
varying vec3 tangent;
|
||||
varying vec4 tangent_other;
|
||||
varying vec3 viewVector;
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2DShadow shadow;
|
||||
// uniform sampler2D gaux2;
|
||||
uniform sampler2D gaux1;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D colortex5;
|
||||
|
||||
uniform float nightVision;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float lightSign;
|
||||
uniform float near;
|
||||
uniform float far;
|
||||
uniform float moonIntensity;
|
||||
uniform float sunIntensity;
|
||||
uniform vec3 sunColor;
|
||||
uniform vec3 nsunColor;
|
||||
uniform vec3 upVec;
|
||||
uniform float sunElevation;
|
||||
uniform float fogAmount;
|
||||
uniform vec2 texelSize;
|
||||
uniform float rainStrength;
|
||||
uniform float skyIntensityNight;
|
||||
uniform float skyIntensity;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform int framemod8;
|
||||
uniform sampler2D specular;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/projections.glsl"
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
#include "/lib/waterBump.glsl"
|
||||
|
||||
#include "/lib/diffuse_lighting.glsl"
|
||||
|
||||
|
||||
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.);
|
||||
float interleaved_gradientNoise(float temporal){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal);
|
||||
return noise;
|
||||
}
|
||||
vec3 srgbToLinear2(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
}
|
||||
vec3 blackbody2(float Temp)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp(col,0.0,1.0);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
|
||||
return srgbToLinear2(col);
|
||||
}
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float invLinZ (float lindepth){
|
||||
return -((2.0*near/lindepth)-far-near)/(far-near);
|
||||
}
|
||||
float ld(float dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
vec3 nvec3(vec4 pos){
|
||||
return pos.xyz/pos.w;
|
||||
}
|
||||
|
||||
vec4 nvec4(vec3 pos){
|
||||
return vec4(pos.xyz, 1.0);
|
||||
}
|
||||
vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){
|
||||
|
||||
float quality = mix(15,SSR_STEPS,fresnel);
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
(-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(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*dither;
|
||||
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++) {
|
||||
// decode depth buffer
|
||||
float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).x;
|
||||
|
||||
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
|
||||
spos += stepv;
|
||||
|
||||
//small bias
|
||||
float biasamount = 0.0002 / dist;
|
||||
|
||||
minZ = maxZ-biasamount / ld(spos.z);
|
||||
|
||||
maxZ += stepv.z;
|
||||
}
|
||||
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
|
||||
float facos(float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
return sx > 0. ? a : pi - a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float bayer2(vec2 a){
|
||||
a = floor(a);
|
||||
return fract(dot(a,vec2(0.5,a.y*0.75)));
|
||||
}
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
|
||||
#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 1 //[2 4 6 8 16 32]
|
||||
#define bayer4(a) (bayer2( .5*(a))*.25+bayer2(a))
|
||||
#define bayer8(a) (bayer4( .5*(a))*.25+bayer2(a))
|
||||
#define bayer16(a) (bayer8( .5*(a))*.25+bayer2(a))
|
||||
#define bayer32(a) (bayer16(.5*(a))*.25+bayer2(a))
|
||||
#define bayer64(a) (bayer32(.5*(a))*.25+bayer2(a))
|
||||
#define bayer128(a) fract(bayer64(.5*(a))*.25+bayer2(a))
|
||||
vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) {
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
vec3 parallaxPos = posxz;
|
||||
vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH;
|
||||
float waterHeight = getWaterHeightmap(posxz.xz, waveM, waveZ, iswater) ;
|
||||
|
||||
parallaxPos.xz += waterHeight * vec;
|
||||
|
||||
return parallaxPos;
|
||||
|
||||
}
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
float alpha = (sampleNumber+jitter)/nb;
|
||||
float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
|
||||
float sin_v, cos_v;
|
||||
|
||||
sin_v = sin(angle);
|
||||
cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
//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);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
vec4 hash44(vec4 p4)
|
||||
{
|
||||
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
|
||||
p4 += dot(p4, p4.wzxy+33.33);
|
||||
return fract((p4.xxyz+p4.yzzw)*p4.zywx);
|
||||
}
|
||||
vec3 TangentToWorld(vec3 N, vec3 H)
|
||||
{
|
||||
vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 T = normalize(cross(UpVector, N));
|
||||
vec3 B = cross(N, T);
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
}
|
||||
float GGX (vec3 n, vec3 v, vec3 l, float r, float F0) {
|
||||
r*=r;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);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
|
||||
float k2 = .25 * r;
|
||||
|
||||
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
|
||||
}
|
||||
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump){
|
||||
float bumpmult = 1.0;
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
dither = center*inversesqrt(abs(center));
|
||||
return clamp(dither-fsign(center),0.0,1.0);
|
||||
}
|
||||
vec3 fp10Dither(vec3 color,float dither){
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000);
|
||||
// vec2 coord = gl_FragCoord.xy + frameTimeCounter;
|
||||
// vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
|
||||
return noise ;
|
||||
}
|
||||
//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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
vec3 GGX2_2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
float alpha = square(r) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
vec3 h = normalize(l + v) ;
|
||||
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
float D = alpha / (2.2 * square( (dotNH * alpha - 1.0) * square(dotNH) + 1.0) );
|
||||
|
||||
vec3 F = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
|
||||
return F * D;
|
||||
}
|
||||
// float SunGGX(vec3 n, vec3 v, vec3 l, float Roughness, float F0){
|
||||
|
||||
// vec3 h = normalize(l + v) ;
|
||||
|
||||
// float dotNH = clamp(dot(h,n),0.,1.);
|
||||
// float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
// float alpha =max(square(Roughness),1e-4) ;
|
||||
|
||||
// float WallFresnel = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
// float Sun = square( dotNH - pow(alpha,1.5) - 1.0);
|
||||
|
||||
// float Final = ((alpha / (10.0 * Sun + 1e-4)) * WallFresnel);
|
||||
|
||||
// return Final ;
|
||||
// }
|
||||
float SunGGX(vec3 n, vec3 v, vec3 l, float roughness,float F0, float fresnel){
|
||||
|
||||
|
||||
float alpha = square(roughness) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
vec3 h = normalize(l + v) * mix(1.000, 1.0025, pow(fresnel,2) );
|
||||
|
||||
float dotLH = clamp(dot(h,l),0.,1.);
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNV = clamp(dot(n,v),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
|
||||
float D = alpha / (0.0541592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
float getWaterHeightmap_dimension(vec2 posxz, float waveM, float waveZ, float iswater) { // water waves
|
||||
vec2 movement = vec2(frameTimeCounter*0.01);
|
||||
vec2 pos = posxz ;
|
||||
float caustic = 1.0;
|
||||
float weightSum = 0.0;
|
||||
|
||||
float radiance = 2.39996;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
pos = rotationMatrix * pos ;
|
||||
|
||||
float Waves = texture2D(noisetex, pos / 64.0 + movement).b;
|
||||
|
||||
|
||||
caustic += exp2(pow(Waves,3.0) * -5.0);
|
||||
weightSum += exp2(-(3.0-caustic));
|
||||
}
|
||||
return ((3.0-caustic) * weightSum / (30.0 * 3.0));
|
||||
}
|
||||
|
||||
vec3 getWaveHeightmap_dimension(vec2 posxz, float iswater){
|
||||
|
||||
vec2 coord = posxz;
|
||||
|
||||
float deltaPos = 0.25;
|
||||
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
float h0 = getWaterHeightmap_dimension(coord, waveM, waveZ, iswater);
|
||||
float h1 = getWaterHeightmap_dimension(coord + vec2(deltaPos,0.0), waveM, waveZ, iswater);
|
||||
float h3 = getWaterHeightmap_dimension(coord + vec2(0.0,deltaPos), waveM, waveZ, iswater);
|
||||
|
||||
|
||||
float xDelta = ((h1-h0))/deltaPos*2.;
|
||||
float yDelta = ((h3-h0))/deltaPos*2.;
|
||||
|
||||
vec3 wave = normalize(vec3(xDelta,yDelta,1.0-pow(abs(xDelta+yDelta),2.0)));
|
||||
|
||||
return wave;
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
/* RENDERTARGETS:2,7,1,11,13,14 */
|
||||
void main() {
|
||||
if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize.y < RENDER_SCALE.y ) {
|
||||
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy,Texture_MipMap_Bias)*color;
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
|
||||
float iswater = normalMat.w;
|
||||
|
||||
#ifdef HAND
|
||||
iswater = 0.1;
|
||||
#endif
|
||||
#ifndef Vanilla_like_water
|
||||
if (iswater > 0.9) {
|
||||
Albedo = vec3(0.0);
|
||||
gl_FragData[0] = vec4(vec3(0.0),1.0/255.0);
|
||||
}
|
||||
#endif
|
||||
#ifdef Vanilla_like_water
|
||||
if (iswater > 0.5) {
|
||||
gl_FragData[0].a = luma(Albedo.rgb);
|
||||
Albedo = color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
gl_FragData[4] = vec4(Albedo, gl_FragData[0].a);
|
||||
|
||||
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
vec3 fragC = gl_FragCoord.xyz*vec3(texelSize,1.0);
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec3 WaterNormals;
|
||||
vec3 TranslucentNormals;
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
|
||||
|
||||
|
||||
if (iswater > 0.4){
|
||||
float bumpmult = 1.;
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
posxz.xz-=posxz.y;
|
||||
|
||||
vec3 bump;
|
||||
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos));
|
||||
|
||||
bump = normalize(getWaveHeightmap_dimension(posxz.xz,iswater));
|
||||
WaterNormals = bump; // tangent space normals for refraction
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
normal = normalize(bump * tbnMatrix);
|
||||
|
||||
|
||||
}else{
|
||||
vec3 normalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgb;
|
||||
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0);
|
||||
|
||||
TranslucentNormals = normalTex;
|
||||
|
||||
normal = applyBump(tbnMatrix,normalTex);
|
||||
}
|
||||
|
||||
TranslucentNormals += WaterNormals;
|
||||
|
||||
vec4 data0 = vec4(1);
|
||||
vec4 data1 = clamp( encode(TranslucentNormals, lmtexcoord.zw),0.0,1.0);
|
||||
gl_FragData[3] = vec4(encodeVec2(data0.x,data1.x), encodeVec2(data0.y,data1.y), encodeVec2(data0.z,data1.z), encodeVec2(data1.w,data0.w));
|
||||
gl_FragData[5] = vec4(encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a));
|
||||
|
||||
|
||||
vec3 Indirect_lighting = DoAmbientLighting_Nether(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.z, viewToWorld(normal), np3, p3 + cameraPosition);
|
||||
vec3 FinalColor = Indirect_lighting * Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
float alphashit = min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
FinalColor *= alphashit;
|
||||
#endif
|
||||
|
||||
vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
SpecularTex = iswater > 0.0 && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02);
|
||||
|
||||
if (iswater > 0.0 || (SpecularTex.g > 0.0 || SpecularTex.r > 0.0)){
|
||||
vec3 Reflections_Final = vec3(0.0);
|
||||
float roughness = pow(1.0-SpecularTex.r,2.0);
|
||||
float f0 = SpecularTex.g;
|
||||
float F0 = f0;
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1);
|
||||
|
||||
vec3 reflectedVector = reflect(normalize(fragpos), normal);
|
||||
float normalDotEye = dot(normal, normalize(fragpos));
|
||||
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0);
|
||||
|
||||
// snells window looking thing
|
||||
if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0);
|
||||
|
||||
fresnel = F0 + (1.0 - F0) * fresnel;
|
||||
|
||||
vec4 Reflections = vec4(0.0);
|
||||
if(iswater > 0){
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1);
|
||||
if (rtPos.z < 1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reflections_Final = mix(FinalColor, Reflections.rgb, Reflections.a * fresnel * visibilityFactor);
|
||||
|
||||
|
||||
float F2 = pow(clamp(1.0 + normalDotEye,0.0,1.0),pow(1.0-roughness,2.0) * 1.5 + 0.5);
|
||||
F2 = mix(f0, 1.0, F2);
|
||||
|
||||
Reflections_Final += mix( gl_Fog.color.rgb * 0.25, vec3(0.0), Reflections.a * visibilityFactor) ;
|
||||
|
||||
gl_FragData[0].rgb = Reflections_Final;
|
||||
|
||||
//correct alpha channel with fresnel
|
||||
float alpha0 = gl_FragData[0].a;
|
||||
gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel;
|
||||
|
||||
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
|
||||
|
||||
|
||||
} else {
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
}
|
||||
|
||||
#ifndef HAND
|
||||
gl_FragData[1] = vec4(Albedo,iswater);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// #version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
|
||||
@ -16,22 +16,24 @@ varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
varying vec3 tangent;
|
||||
varying float dist;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
varying vec3 viewVector;
|
||||
|
||||
flat varying int glass;
|
||||
|
||||
attribute vec4 at_tangent;
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
uniform vec3 sunPosition;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform float sunElevation;
|
||||
|
||||
varying vec4 tangent_other;
|
||||
#define SHADOW_MAP_BIAS 0.8
|
||||
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
|
||||
flat varying vec3 avgAmbient;
|
||||
|
||||
|
||||
uniform vec2 texelSize;
|
||||
@ -49,6 +51,15 @@ uniform int framemod8;
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -56,23 +67,27 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 Swtich_gl_vertex = gl_Vertex;
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
gl_Position = toClipSpace3(position);
|
||||
color = gl_Color;
|
||||
float mat = 0.0;
|
||||
|
||||
if(mc_Entity.x == 8.0 || mc_Entity.x == 9.0) {
|
||||
mat = 1.0;
|
||||
|
||||
gl_Position.z -= 1e-4;
|
||||
}
|
||||
|
||||
|
||||
if (mc_Entity.x == 10002) mat = 0.01;
|
||||
if (mc_Entity.x == 10002) mat = 0.2;
|
||||
if (mc_Entity.x == 72) mat = 0.5;
|
||||
|
||||
// if (mc_Entity.x == 8) mat = 0.1;
|
||||
|
||||
normalMat = vec4(normalize( gl_NormalMatrix*gl_Normal),mat);
|
||||
@ -88,9 +103,7 @@ void main() {
|
||||
tangent.y, binormal.y, normalMat.y,
|
||||
tangent.z, binormal.z, normalMat.z);
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
viewVector = ( gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
viewVector = ( gl_ModelViewMatrix * Swtich_gl_vertex).xyz;
|
||||
viewVector = normalize(tbnMatrix * viewVector);
|
||||
|
||||
|
||||
@ -109,4 +122,6 @@ void main() {
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
}
|
@ -8,7 +8,7 @@ clouds=off
|
||||
stars=true
|
||||
vignette=false
|
||||
dynamicHandLight=true
|
||||
program.composite7.enabled=TAA_UPSCALING
|
||||
program.composite4.enabled=TAA_UPSCALING
|
||||
|
||||
#Get the correct alpha value : S_A*(1-DST_A)+DST_A
|
||||
blend.gbuffers_terrain = off
|
||||
@ -38,19 +38,15 @@ alphaTest.gbuffers_skytextured=false
|
||||
alphaTest.gbuffers_hand=true
|
||||
|
||||
|
||||
# profile.potato = shadowMapResolution=512 !Sub_surface_scattering !Variable_Penumbra_Shadows shadowDistance=32 VPS_Search_Samples=8 SHADOW_FILTER_SAMPLE_COUNT=8 !SCREENSPACE_CONTACT_SHADOWS !SSAO ambientOcclusionLevel=0.50 TAA_UPSCALING RENDER_SCALE_X=0.5 RENDER_SCALE_Y=0.5 SHARPENING= 1.0 !VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=-1 cloud_ShadowLevelOfDetail=-1 CLOUDS_QUALITY=0.2 minRayMarchSteps=20 maxRayMarchSteps=20 !High_Altitude_Clouds reflection_quality=10 Roughness_Strength=0 !Screen_Space_Reflections !Sky_reflection
|
||||
# profile.lower = shadowMapResolution=512 Sub_surface_scattering !Variable_Penumbra_Shadows shadowDistance=32 VPS_Search_Samples=8 SHADOW_FILTER_SAMPLE_COUNT=8 SCREENSPACE_CONTACT_SHADOWS !SSAO ambientOcclusionLevel=0.50 TAA_UPSCALING RENDER_SCALE_X=0.5 RENDER_SCALE_Y=0.5 SHARPENING= 1.0 !VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=-1 cloud_ShadowLevelOfDetail=-1 CLOUDS_QUALITY=0.2 minRayMarchSteps=20 maxRayMarchSteps=20 !High_Altitude_Clouds reflection_quality=10 Roughness_Strength=0 !Screen_Space_Reflections !Sky_reflection
|
||||
# profile.low = shadowMapResolution=512 Sub_surface_scattering Variable_Penumbra_Shadows shadowDistance=32 VPS_Search_Samples=8 SHADOW_FILTER_SAMPLE_COUNT=8 SCREENSPACE_CONTACT_SHADOWS !SSAO ambientOcclusionLevel=0.50 TAA_UPSCALING RENDER_SCALE_X=0.7 RENDER_SCALE_Y=0.7 SHARPENING= 0.5 VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=0 cloud_ShadowLevelOfDetail=0 CLOUDS_QUALITY=0.35 minRayMarchSteps=20 maxRayMarchSteps=20 High_Altitude_Clouds reflection_quality=10 Roughness_Strength=1 !Screen_Space_Reflections !Sky_reflection
|
||||
# profile.medium = shadowMapResolution=1024 Sub_surface_scattering Variable_Penumbra_Shadows shadowDistance=48 VPS_Search_Samples=15 SHADOW_FILTER_SAMPLE_COUNT=15 SCREENSPACE_CONTACT_SHADOWS SSAO ambientOcclusionLevel=0.15 TAA_UPSCALING RENDER_SCALE_X=0.7 RENDER_SCALE_Y=0.7 SHARPENING= 0.5 VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=1 cloud_ShadowLevelOfDetail=0 CLOUDS_QUALITY=0.5 minRayMarchSteps=20 maxRayMarchSteps=30 High_Altitude_Clouds reflection_quality=16 Roughness_Strength=2 Screen_Space_Reflections Sky_reflection
|
||||
# profile.high = shadowMapResolution=2048 Sub_surface_scattering Variable_Penumbra_Shadows shadowDistance=69. VPS_Search_Samples=15 SHADOW_FILTER_SAMPLE_COUNT=15 SCREENSPACE_CONTACT_SHADOWS SSAO ambientOcclusionLevel=0.15 !TAA_UPSCALING RENDER_SCALE_X=0.7 RENDER_SCALE_Y=0.7 SHARPENING= 0.35 VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=1 cloud_ShadowLevelOfDetail=0 CLOUDS_QUALITY=0.5 minRayMarchSteps=20 maxRayMarchSteps=30 High_Altitude_Clouds reflection_quality=35 Roughness_Strength=3 Screen_Space_Reflections Sky_reflection
|
||||
# profile.ultra = shadowMapResolution=4096 Sub_surface_scattering Variable_Penumbra_Shadows shadowDistance=80 VPS_Search_Samples=15 SHADOW_FILTER_SAMPLE_COUNT=25 SCREENSPACE_CONTACT_SHADOWS SSAO ambientOcclusionLevel=0.15 !TAA_UPSCALING RENDER_SCALE_X=0.7 RENDER_SCALE_Y=0.7 SHARPENING= 0.2 VOLUMETRIC_CLOUDS rain_clouds=1.0 cloudCoverage=0.36 cloud_LevelOfDetail=2 cloud_ShadowLevelOfDetail=2 CLOUDS_QUALITY=0.5 minRayMarchSteps=20 maxRayMarchSteps=50 High_Altitude_Clouds reflection_quality=35 Roughness_Strength=3 Screen_Space_Reflections Sky_reflection
|
||||
sliders = Cumulus_coverage Cumulus_density Alto_coverage Alto_density ORB_ColMult ORB_X ORB_Y ORB_Z ORB_R ORB_G ORB_B TOD_Fog_mult Morning_Uniform_Fog Noon_Uniform_Fog Evening_Uniform_Fog Night_Uniform_Fog Morning_Cloudy_Fog Noon_Cloudy_Fog Evening_Cloudy_Fog Night_Cloudy_Fog NetherFog_brightness WeatherDay Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength Cloud_Height Dynamic_sky_day ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B cloud_speed Rain_coverage override_R override_G override_B override_Cloudy_Fog_Density override_cloudyfog_fade override_fog override_Uniform_Fog_Density override_uniformfog_fade override_Bloomy_Fog override_Sun_Strength Moon_temp Haze_amount UniformFog_amount CloudyFog_amount TimeOfDayFog_multiplier RainFog_amount CaveFog_amount uniformfog_fade cloudyfog_fade cloudray_amount Swamp_cloudyfog_height Jungle_cloudyfog_fade Swamp_uniformfog_height Jungle_uniformfog_fade noise_mode Distant_shadow_quality ambient_temp Sun_temp Puddle_Size Cloud_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength Swamp_Sun_Strength Jungle_Sun_Strength Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_cloudyfog_Density Jungle_Cloudy_Fog_Density Swamp_UniformFog_Density Jungle_Uniform_Fog_Density Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_R Swamp_G Swamp_B Jungle_R Jungle_G Jungle_B Jungle_fog_strength Swamp_fog_strength Lush_fog_strength Snells_Window_Width self_shadow_samples Shadow_brightness Cloud_top_cutoff Cloud_base_cutoff Cloud_fade_amount BLOOMY_FOG FOG_RAIN_MULTIPLIER FOG_TOD_MULTIPLIER CLOUDY_FOG_AMOUNT BASE_FOG_AMOUNT WAVY_SPEED WAVY_STRENGTH ANTI_GHOSTING BLOOM_STRENGTH shadowDistance shadowDistanceRenderMul FinalR FinalG FinalB Ambient_Mult Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation SKY_BRIGHTNESS_DAY SKY_BRIGHTNESS_NIGHT BLEND_FACTOR FLICKER_REDUCTION MOTION_REJECTION VL_SAMPLES Exposure_Speed POM_MAP_RES POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL ATMOSPHERIC_DENSITY CLOUDS_SHADOWS_STRENGTH moon_illuminance moonColorR moonColorG moonColorB fog_mieg1 fog_mieg2 fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius SSAO_SAMPLES Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Mie_Phase Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK RENDER_SCALE_X RENDER_SCALE_Y VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ cloudDensity cloudCoverage fbmAmount fbmPower1 fbmPower2 cloudMieG cloudMieG2 cloudMie2Multiplier Strong_SSS_strength Medium_SSS_strength Weak_SSS_strength Shadow_brightness Roughness_Threshold Sun_specular_Strength reflection_quality Roughness_Strength SSS_mode DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS
|
||||
|
||||
sliders = WeatherDay Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength Cloud_Height Dynamic_sky_day ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B cloud_speed Rain_coverage override_R override_G override_B override_Cloudy_Fog_Density override_cloudyfog_fade override_fog override_Uniform_Fog_Density override_uniformfog_fade override_Bloomy_Fog override_Sun_Strength Moon_temp Haze_amount UniformFog_amount CloudyFog_amount TimeOfDayFog_multiplier RainFog_amount CaveFog_amount uniformfog_fade cloudyfog_fade cloudray_amount Swamp_cloudyfog_height Jungle_cloudyfog_fade Swamp_uniformfog_height Jungle_uniformfog_fade noise_mode Distant_shadow_quality ambient_temp Sun_temp Puddle_Size Cloud_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength Swamp_Sun_Strength Jungle_Sun_Strength Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_cloudyfog_Density Jungle_Cloudy_Fog_Density Swamp_UniformFog_Density Jungle_Uniform_Fog_Density Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_R Swamp_G Swamp_B Jungle_R Jungle_G Jungle_B Jungle_fog_strength Swamp_fog_strength Lush_fog_strength Snells_Window_Width self_shadow_samples Shadow_brightness Cloud_top_cutoff Cloud_base_cutoff Cloud_fade_amount BLOOMY_FOG FOG_RAIN_MULTIPLIER FOG_TOD_MULTIPLIER CLOUDY_FOG_AMOUNT BASE_FOG_AMOUNT WAVY_SPEED WAVY_STRENGTH ANTI_GHOSTING BLOOM_STRENGTH shadowDistance shadowDistanceRenderMul FinalR FinalG FinalB Ambient_Mult Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation SKY_BRIGHTNESS_DAY SKY_BRIGHTNESS_NIGHT BLEND_FACTOR FLICKER_REDUCTION MOTION_REJECTION VL_SAMPLES Exposure_Speed POM_MAP_RES POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL ATMOSPHERIC_DENSITY CLOUDS_SHADOWS_STRENGTH moon_illuminance moonColorR moonColorG moonColorB fog_mieg1 fog_mieg2 fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius SSAO_SAMPLES Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Mie_Phase Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK RENDER_SCALE_X RENDER_SCALE_Y VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ cloudDensity cloudCoverage fbmAmount fbmPower1 fbmPower2 cloudMieG cloudMieG2 cloudMie2Multiplier Strong_SSS_strength Medium_SSS_strength Weak_SSS_strength Shadow_brightness Roughness_Threshold Sun_specular_Strength reflection_quality Roughness_Strength SSS_mode DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS
|
||||
# screen=[Atmospherics] [TAA_OPTIONS] [Lighting] [Camera] [Shading] [Wavy_stuff] [Water_and_transparencies] [Xonk_settings]
|
||||
screen.columns=2
|
||||
screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds] [Misc_Settings] [Climate]
|
||||
|
||||
|
||||
screen.columns=1
|
||||
screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing] [Climate] [Misc_Settings]
|
||||
# screen = [Direct_Light] [World]
|
||||
# [Ambient_light] [Fog]
|
||||
# [Post_Processing] [Clouds]
|
||||
# [Misc_Settings] [Climate]
|
||||
|
||||
######## LIGHTING
|
||||
### DIRECT LIGHT
|
||||
@ -68,7 +64,7 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
|
||||
### AMBIENT LIGHT
|
||||
screen.Ambient_light.columns=1
|
||||
screen.Ambient_light = [Torch] [Ambient] [ambientlight_colors] <skip> indirect_effect HQ_SSGI AO_Strength GI_Strength
|
||||
screen.Ambient_light = [Torch] [Ambient] [ambientlight_colors] <skip> indirect_effect HQ_SSGI AO_Strength GI_Strength AO_in_sunlight
|
||||
|
||||
screen.ambientlight_colors.columns=1
|
||||
screen.ambientlight_colors = ambient_brightness ambient_colortype ambient_temp <skip> AmbientLight_R AmbientLight_G AmbientLight_B
|
||||
@ -91,13 +87,22 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
screen.Waving_Stuff = WAVY_STRENGTH WAVY_SPEED WAVY_PLANTS
|
||||
## POM
|
||||
screen.POM.columns=1
|
||||
screen.POM = POM MAX_ITERATIONS POM_DEPTH MAX_DIST Horrible_slope_normals
|
||||
screen.POM = POM MAX_ITERATIONS POM_DEPTH MAX_DIST Adaptive_Step_length Horrible_slope_normals
|
||||
|
||||
|
||||
|
||||
######## CLIMATE
|
||||
screen.Climate.columns=1
|
||||
screen.Climate = [Seasons] [Weather] [Biome_Fog]
|
||||
screen.Climate = [Weather] [Biome_Fog] [Seasons]
|
||||
|
||||
## DAILY WEATHER
|
||||
screen.Weather.columns=1
|
||||
screen.Weather = Daily_Weather WeatherDay
|
||||
|
||||
## BIOME SPECIFICS
|
||||
screen.Biome_Fog.columns=1
|
||||
screen.Biome_Fog = Biome_specific_environment
|
||||
|
||||
|
||||
## SEASONS
|
||||
screen.Seasons.columns=1
|
||||
@ -115,27 +120,11 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
screen.Spring_colors.columns=1
|
||||
screen.Spring_colors = Spring_R Spring_G Spring_B <skip> Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B
|
||||
|
||||
## DAILY WEATHER
|
||||
screen.Weather.columns=1
|
||||
screen.Weather = Daily_Weather WeatherDay
|
||||
|
||||
## BIOME SPECIFICS
|
||||
screen.Biome_Fog.columns=1
|
||||
screen.Biome_Fog = Biome_specific_environment <skip> Jungle_fog_strength [Jungle_Settings] Swamp_fog_strength [Swamp_Settings] override_fog [Override_Settings]
|
||||
|
||||
screen.Jungle_Settings.columns=1
|
||||
screen.Jungle_Settings = Jungle_R Jungle_G Jungle_B Jungle_Cloudy_Fog_Density Jungle_cloudyfog_fade Jungle_Uniform_Fog_Density Jungle_uniformfog_fade Jungle_Bloomy_Fog Jungle_Sun_Strength
|
||||
|
||||
screen.Swamp_Settings.columns=1
|
||||
screen.Swamp_Settings = Swamp_R Swamp_G Swamp_B Swamp_cloudyfog_Density Swamp_cloudyfog_height Swamp_UniformFog_Density Swamp_uniformfog_height Swamp_Bloomy_Fog Swamp_Sun_Strength
|
||||
|
||||
screen.Override_Settings.columns=1
|
||||
screen.Override_Settings = override_R override_G override_B override_Cloudy_Fog_Density override_cloudyfog_fade override_Uniform_Fog_Density override_uniformfog_fade override_Bloomy_Fog override_Sun_Strength
|
||||
|
||||
|
||||
######## ATMOSPHERICS
|
||||
screen.Atmospherics.columns=1
|
||||
screen.Atmospherics = [Sky] [Fog] [Biome_Fog] [Clouds] High_Altitude_Clouds Cumulus_Clouds Allow_Vanilla_sky CLOUDS_SHADOWS VL_CLOUDS_SHADOWS
|
||||
screen.Atmospherics = [Sky] [Fog] [Biome_Fog] [Clouds] Altostratus Cumulus_Clouds Allow_Vanilla_sky
|
||||
|
||||
### SKY
|
||||
screen.Sky.columns=1
|
||||
screen.Sky = [Sky_coefficients] [Sun_and_Moon_Colors] sunPathRotation
|
||||
@ -145,17 +134,22 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
|
||||
### CLOUDS
|
||||
screen.Clouds.columns=2
|
||||
screen.Clouds = VOLUMETRIC_CLOUDS Dynamic_Sky cloud_LevelOfDetail cloud_ShadowLevelOfDetail CLOUDS_QUALITY cloudDensity cloudCoverage Rain_coverage cloud_speed fbmAmount fbmPower1 fbmPower2 Cloud_top_cutoff Cloud_base_cutoff Shadow_brightness self_shadow_samples
|
||||
# screen.Clouds = VOLUMETRIC_CLOUDS Altostratus cloud_LevelOfDetail cloud_ShadowLevelOfDetail CLOUDS_QUALITY cloudDensity cloudCoverage Rain_coverage cloud_speed fbmAmount fbmPower1 fbmPower2 Cloud_top_cutoff Cloud_base_cutoff Shadow_brightness self_shadow_samples CLOUDS_SHADOWS VL_CLOUDS_SHADOWS
|
||||
screen.Clouds = VOLUMETRIC_CLOUDS CLOUDS_QUALITY Cumulus Altostratus Cumulus_coverage Alto_coverage Cumulus_density Alto_density CLOUDS_SHADOWS
|
||||
|
||||
### FOG
|
||||
screen.Fog.columns=1
|
||||
screen.Fog = [Biome_Fog] [cave_fog] [Fog_Densities] VL_RENDER_RESOLUTION VL_SAMPLES BLOOMY_FOG VL_Clouds_Shadows fog_selfShadowing
|
||||
screen.Fog = VL_RENDER_RESOLUTION VL_SAMPLES BLOOMY_FOG Haze_amount RainFog_amount [TOD_fog] [Biome_Fog] [Cave_Fog] BorderFog
|
||||
|
||||
screen.Fog_Densities.columns=1
|
||||
screen.Fog_Densities = Haze_amount UniformFog_amount CloudyFog_amount TimeOfDayFog_multiplier RainFog_amount CaveFog_amount uniformfog_fade cloudyfog_fade
|
||||
screen.TOD_fog.columns=2
|
||||
screen.TOD_fog = TOD_Fog_mult <skip> Morning_Uniform_Fog Morning_Cloudy_Fog Noon_Uniform_Fog Noon_Cloudy_Fog Evening_Uniform_Fog Evening_Cloudy_Fog Night_Uniform_Fog Night_Cloudy_Fog
|
||||
|
||||
screen.Cave_Fog.columns=1
|
||||
screen.Cave_Fog = Cave_fog CaveFog_amount CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B
|
||||
|
||||
screen.Fog_Color.columns=1
|
||||
screen.Fog_Color = fog_mieg1 fog_mieg2 fog_coefficientRayleighR fog_coefficientRayleighG fog_coefficientRayleighB fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB
|
||||
|
||||
### WATER
|
||||
screen.Water.columns=1
|
||||
screen.Water = Refraction Vanilla_like_water Dirt_Amount Dirt_Mie_Phase rayMarchSampleCount SCREENSPACE_REFLECTIONS SSR_STEPS USE_QUARTER_RES_DEPTH SUN_MICROFACET_SPECULAR Water_Top_Layer lightMapDepthEstimation [Water_fog_color]
|
||||
@ -184,7 +178,10 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
|
||||
######## MISC SETTINGS
|
||||
screen.Misc_Settings.columns=1
|
||||
screen.Misc_Settings =end_shadows WhiteWorld ambientLight_only Cloud_Size Cloud_Height BorderFog Texture_MipMap_Bias Glass_Tint display_LUT DISABLE_ALPHA_MIPMAPS
|
||||
screen.Misc_Settings = [the_orb] WhiteWorld ambientLight_only Glass_Tint display_LUT DISABLE_ALPHA_MIPMAPS
|
||||
|
||||
screen.the_orb.columns = 1
|
||||
screen.the_orb = THE_ORB ORB_X ORB_Y ORB_Z ORB_ColMult ORB_R ORB_G ORB_B
|
||||
|
||||
screen.LabPBR.columns = 1
|
||||
screen.LabPBR = [Reflections] [Subsurface_Scattering] [Emissives] [POM] [Porosity]
|
||||
@ -199,7 +196,6 @@ screen = [Direct_Light] [Ambient_light] [World] [Atmospherics] [Post_Processing]
|
||||
screen.Sun_and_Moon_Colors = sunColorR sunColorG sunColorB moonColorR moonColorG moonColorB colortype Sun_temp Moon_temp
|
||||
|
||||
screen.Advanced = Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B
|
||||
screen.cave_fog = Cave_fog CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B
|
||||
|
||||
######## moonphase based weather
|
||||
|
||||
@ -260,11 +256,19 @@ uniform.float.isCrimsonForest = smooth(12, if(in(biome,53), 1,0), 5, 5)
|
||||
uniform.float.isSoulValley = smooth(13, if(in(biome,54), 1,0), 5, 5)
|
||||
uniform.float.isBasaltDelta = smooth(14, if(in(biome,55), 1,0), 5, 5)
|
||||
|
||||
|
||||
|
||||
# uniform.float.ifEndBoss = smooth(if(bossBattle == 2, 1, 0 ), 1, 1)
|
||||
|
||||
# uniform.float.EndSequence1 = smooth(if(hideGUI == 1, 1.0, 0.0), 30, 0)
|
||||
|
||||
# uniform.float.EndSequence2 = smooth(if(EndSequence1 > 0.95, 1.0, 0.0), 1.25, 0)
|
||||
|
||||
# uniform.float.Winter = smooth(14, if( worldDay > 0 && worldDay < 10), 5, 5)
|
||||
|
||||
|
||||
# thank you sixthsurge!
|
||||
uniform.float.lightningFlash = smooth(if(equals(skyColor.r, skyColor.g, 0.01) && skyColor.r > 0.3, 1.0, 0.0), 0, 0.5)
|
||||
# uniform.float.lightningFlash = smooth(if(equals(skyColor.r, skyColor.g, 0.01) && skyColor.r > 0.3, 1.0, 0.0), 0, 0.5)
|
||||
|
||||
texture.noise=texture/noises.png
|
||||
texture.composite.colortex6=texture/blueNoise.png
|
||||
@ -327,3 +331,11 @@ variable.float.shSunZ = (shadowModelView.0.2 * wSunX + shadowModelView.1.2 * wSu
|
||||
uniform.vec3.shadowLightVec = vec3(lightSign*shSunX, lightSign*shSunY, lightSign*shSunZ)
|
||||
|
||||
uniform.float.shadowMaxProj = 150.0/abs(sunPosY)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# photon shit
|
||||
uniform.vec2.view_res = vec2(viewWidth, viewHeight)
|
||||
uniform.vec2.view_pixel_size = vec2(1.0 / viewWidth, 1.0 / viewHeight)
|
@ -20,9 +20,11 @@ float R2_dither(){
|
||||
}
|
||||
void main() {
|
||||
gl_FragData[0] = texture2D(tex,texcoord.xy);
|
||||
|
||||
#ifdef SHADOW_DISABLE_ALPHA_MIPMAPS
|
||||
gl_FragData[0].a = texture2DLod(tex,texcoord.xy,0).a;
|
||||
#endif
|
||||
|
||||
#ifdef Stochastic_Transparent_Shadows
|
||||
gl_FragData[0].a = float(gl_FragData[0].a >= R2_dither());
|
||||
#endif
|
||||
|
@ -1,20 +0,0 @@
|
||||
#if MC_VERSION >= 11300
|
||||
block.10001= minecraft:acacia_sapling minecraft:birch_sapling minecraft:dark_oak_sapling minecraft:jungle_sapling minecraft:oak_sapling minecraft:spruce_sapling minecraft:grass minecraft:dead_bush minecraft:fern minecraft:dandelion minecraft:poppy minecraft:blue_orchid minecraft:allium minecraft:azure_bluet minecraft:orange_tulip minecraft:pink_tulip minecraft:red_tulip minecraft:white_tulip minecraft:oxeye_daisy minecraft:brown_mushroom minecraft:red_mushroom minecraft:wheat minecraft:nether_wart minecraft:carrot minecraft:potato minecraft:beetroot_seeds
|
||||
block.10003 = minecraft:acacia_leaves minecraft:birch_leaves minecraft:dark_oak_leaves minecraft:jungle_leaves minecraft:oak_leaves minecraft:spruce_leaves minecraft:vine
|
||||
block.10004 = minecraft:cobweb minecraft:sugar_cane minecraft:pumpkin_seeds minecraft:lily_pad minecraft:lilac minecraft:sunflower minecraft:tall_grass minecraft:rose_bush minecraft:peony minecraft:large_fern
|
||||
block.10002= minecraft:black_stained_glass minecraft:black_stained_glass_pane minecraft:blue_stained_glass minecraft:blue_stained_glass_pane minecraft:brown_stained_glass minecraft:brown_stained_glass_pane minecraft:cyan_stained_glass minecraft:cyan_stained_glass_pane minecraft:gray_stained_glass minecraft:gray_stained_glass_pane minecraft:green_stained_glass minecraft:green_stained_glass_pane minecraft:light_blue_stained_glass minecraft:light_blue_stained_glass_pane minecraft:light_gray_stained_glass minecraft:light_gray_stained_glass_pane minecraft:lime_stained_glass minecraft:lime_stained_glass_pane minecraft:magenta_stained_glass minecraft:magenta_stained_glass_pane minecraft:orange_stained_glass minecraft:orange_stained_glass_pane minecraft:pink_stained_glass minecraft:pink_stained_glass_pane minecraft:purple_stained_glass minecraft:purple_stained_glass_pane minecraft:red_stained_glass minecraft:red_stained_glass_pane minecraft:white_stained_glass minecraft:white_stained_glass_pane minecraft:yellow_stained_glass minecraft:yellow_stained_glass_pane minecraft:glass_pane minecraft:glass
|
||||
block.8 = minecraft:water minecraft:flowing_water
|
||||
block.79 = minecraft:ice
|
||||
block.10005 = minecraft:glowstone minecraft:torch minecraft:wall_torch minecraft:lava minecraft:fire minecraft:redstone_torch minecraft:redstone_wall_torch minecraft:jack_o_lantern minecraft:magma_block minecraft:redstone_lamp:lit=true minecraft:lantern minecraft:campfire:lit=true minecraft:shroomlight minecraft:nether_portal minecraft:soul_torch minecraft:soul_wall_torch minecraft:soul_fire minecraft:end_rod minecraft:sea_lantern minecraft:soul_lantern minecraft:end_gateway minecraft:soul_campfire:lit=true minecraft:lava minecraft:fire
|
||||
#else
|
||||
#wavy plants, translucent, bottom vertices not moving
|
||||
block.10001= 6 31 32 37 38 39 40 59 115 141 142 207
|
||||
#wavy plants (blocks)
|
||||
block.10003 = 18 106 161
|
||||
#translucent
|
||||
block.10004 = 30 83 104 105 111 175 176 177
|
||||
#reflective surfaces (not including water and ice)
|
||||
block.10002=95 160
|
||||
#endif
|
||||
|
||||
layer.translucent=minecraft:glass_pane minecraft:glass
|
@ -1,28 +1,8 @@
|
||||
#version 120
|
||||
//Vignetting, applies bloom, applies exposure and tonemaps the final image
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#define Fake_purkinje
|
||||
#define BLOOMY_FOG 2.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0]
|
||||
#define BLOOM_STRENGTH 4.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0]
|
||||
#define TONEMAP ToneMap_Hejl2015 // Tonemapping operator [Tonemap_Uchimura HableTonemap reinhard Tonemap_Lottes ACESFilm ToneMap_Hejl2015]
|
||||
//#define USE_ACES_COLORSPACE_APPROXIMATION // Do the tonemap in another colorspace
|
||||
|
||||
#define Purkinje_strength 1.0 // Simulates how the eye is unable to see colors at low light intensities. 0 = No purkinje effect at low exposures [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define Purkinje_R 0.4 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define Purkinje_G 0.7 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define Purkinje_B 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define Purkinje_Multiplier 5.0 // How much the purkinje effect increases brightness [0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0 5.05 5.1 5.15 5.2 5.25 5.3 5.35 5.4 5.45 5.5 5.55 5.6 5.65 5.7 5.75 5.8 5.85 5.9 5.95 6.0 6.05 6.1 6.15 6.2 6.25 6.3 6.35 6.4 6.45 6.5 6.55 6.6 6.65 6.7 6.75 6.8 6.85 6.9 6.95 7.0 7.05 7.1 7.15 7.2 7.25 7.3 7.35 7.4 7.45 7.5 7.55 7.6 7.65 7.7 7.75 7.8 7.85 7.9 7.95 8.0 8.05 8.1 8.15 8.2 8.25 8.3 8.35 8.4 8.45 8.5 8.55 8.6 8.65 8.7 8.75 8.8 8.85 8.9 8.95 9.0 9.05 9.1 9.15 9.2 9.25 9.3 9.35 9.4 9.45 9.5 9.55 9.6 9.65 9.7 9.75 9.8 9.85 9.9 9.95 ]
|
||||
|
||||
|
||||
//#define DOF //enable depth of field (blur on non-focused objects)
|
||||
//#define HQ_DOF //Slow! Forces circular bokeh! Uses 4 times more samples with noise in order to remove sampling artifacts at great blur sizes.
|
||||
//#define HEXAGONAL_BOKEH //disabled : circular blur shape - enabled : hexagonal blur shape
|
||||
#define AUTOFOCUS
|
||||
//#define FAR_BLUR_ONLY // Removes DoF on objects closer to the camera than the focus point
|
||||
//lens properties
|
||||
#define focal 2.4 // Centimeters [0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0 5.05 5.1 5.15 5.2 5.25 5.3 5.35 5.4 5.45 5.5 5.55 5.6 5.65 5.7 5.75 5.8 5.85 5.9 5.95 6.0 6.05 6.1 6.15 6.2 6.25 6.3 6.35 6.4 6.45 6.5 6.55 6.6 6.65 6.7 6.75 6.8 6.85 6.9 6.95 7.0 7.05 7.1 7.15 7.2 7.25 7.3 7.35 7.4 7.45 7.5 7.55 7.6 7.65 7.7 7.75 7.8 7.85 7.9 7.95 8.0 8.05 8.1 8.15 8.2 8.25 8.3 8.35 8.4 8.45 8.5 8.55 8.6 8.65 8.7 8.75 8.8 8.85 8.9 8.95 9.0 9.05 9.1 9.15 9.2 9.25 9.3 9.35 9.4 9.45 9.5 9.55 9.6 9.65 9.7 9.75 9.8 9.85 9.9 9.95 ]
|
||||
#define aperture 0.8 // Centimeters [0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0 5.05 5.1 5.15 5.2 5.25 5.3 5.35 5.4 5.45 5.5 5.55 5.6 5.65 5.7 5.75 5.8 5.85 5.9 5.95 6.0 6.05 6.1 6.15 6.2 6.25 6.3 6.35 6.4 6.45 6.5 6.55 6.6 6.65 6.7 6.75 6.8 6.85 6.9 6.95 7.0 7.05 7.1 7.15 7.2 7.25 7.3 7.35 7.4 7.45 7.5 7.55 7.6 7.65 7.7 7.75 7.8 7.85 7.9 7.95 8.0 8.05 8.1 8.15 8.2 8.25 8.3 8.35 8.4 8.45 8.5 8.55 8.6 8.65 8.7 8.75 8.8 8.85 8.9 8.95 9.0 9.05 9.1 9.15 9.2 9.25 9.3 9.35 9.4 9.45 9.5 9.55 9.6 9.65 9.7 9.75 9.8 9.85 9.9 9.95 ]
|
||||
#define MANUAL_FOCUS 48.0 // If autofocus is turned off, sets the focus point (meters) [0.06948345122280154 0.07243975703425146 0.07552184450877376 0.07873506526686186 0.0820849986238988 0.08557746127787037 0.08921851740926011 0.09301448921066349 0.09697196786440505 0.10109782498721881 0.10539922456186433 0.10988363537639657 0.11455884399268773 0.11943296826671962 0.12451447144412296 0.129812176855438 0.1353352832366127 0.1410933807013415 0.1470964673929768 0.15335496684492847 0.1598797460796939 0.16668213447794653 0.17377394345044514 0.18116748694692214 0.18887560283756183 0.19691167520419406 0.20528965757990927 0.21402409717744744 0.22313016014842982 0.2326236579172927 0.2425210746356487 0.25283959580474646 0.26359713811572677 0.27481238055948964 0.2865047968601901 0.29869468928867837 0.3114032239145977 0.32465246735834974 0.3384654251067422 0.3528660814588489 0.36787944117144233 0.3835315728763107 0.39984965434484737 0.4168620196785084 0.4345982085070782 0.453089017280169 0.4723665527410147 0.49246428767540973 0.513417119032592 0.5352614285189903 0.5580351457700471 0.5817778142098083 0.6065306597126334 0.6323366621862497 0.6592406302004438 0.6872892787909722 0.7165313105737893 0.7470175003104326 0.7788007830714049 0.8119363461506349 0.8464817248906141 0.8824969025845955 0.9200444146293233 0.9591894571091382 1.0 1.0425469051899914 1.086904049521229 1.1331484530668263 1.1813604128656459 1.2316236423470497 1.2840254166877414 1.338656724353094 1.3956124250860895 1.4549914146182013 1.5168967963882134 1.5814360605671443 1.6487212707001282 1.7188692582893286 1.7920018256557555 1.8682459574322223 1.9477340410546757 2.030604096634748 2.117000016612675 2.2070718156067044 2.300975890892825 2.398875293967098 2.5009400136621287 2.6073472713092674 2.718281828459045 2.833936307694169 2.9545115270921065 3.080216848918031 3.211270543153561 3.347900166492527 3.4903429574618414 3.638846248353525 3.7936678946831774 3.955076722920577 4.123352997269821 4.298788906309526 4.4816890703380645 4.672371070304759 4.871165999245474 5.0784190371800815 5.29449005047003 5.51975421667673 5.754602676005731 5.999443210467818 6.254700951936329 6.5208191203301125 6.798259793203881 7.087504708082256 7.38905609893065 7.703437568215379 8.031194996067258 8.372897488127265 8.72913836372013 9.10053618607165 9.487735836358526 9.891409633455755 10.312258501325767 10.751013186076355 11.208435524800691 11.685319768402522 12.182493960703473 12.700821376227164 13.241202019156521 13.804574186067095 14.391916095149892 15.00424758475255 15.642631884188171 16.30817745988666 17.00203994009402 17.725424121461643 18.479586061009854 19.265835257097933 20.085536923187668 20.940114358348602 21.831051418620845 22.75989509352673 23.728258192205157 24.737822143832553 25.790339917193062 26.88763906446752 28.03162489452614 29.22428378123494 30.46768661252054 31.763992386181833 33.11545195869231 34.52441195350251 35.99331883562839 37.524723159600995 39.12128399815321 40.78577355933337 42.52108200006278 44.3302224444953 46.21633621589248 48.182698291098816 50.23272298708815 52.36996988945491 54.598150033144236 56.92113234615337 59.34295036739207 61.867809250367884 64.50009306485578 67.24437240923179 70.10541234668786 73.08818067910767 76.19785657297057 79.43983955226133 82.81975887399955 86.3434833026695 90.01713130052181 93.84708165144015 97.83998453682129 102.00277308269969 106.34267539816554 110.86722712598126 115.58428452718766 120.50203812241894 125.62902691361414 130.9741532108186 136.54669808981876 142.35633750745257 148.4131591025766 154.72767971186107 161.3108636308289 168.17414165184545 175.32943091211476 182.78915558614753 190.56626845863 198.67427341514983 ]
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#ifdef DOF
|
||||
//hexagon pattern
|
||||
@ -379,15 +359,10 @@ uniform float aspectRatio;
|
||||
uniform float far;
|
||||
|
||||
|
||||
uniform float screenBrightness;
|
||||
uniform float isWastes;
|
||||
uniform float isWarpedForest;
|
||||
uniform float isCrimsonForest;
|
||||
uniform float isSoulValley;
|
||||
uniform float isBasaltDelta;
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
|
||||
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/color_dither.glsl"
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
@ -440,7 +415,7 @@ void main() {
|
||||
#ifdef AUTOFOCUS
|
||||
float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far;
|
||||
#else
|
||||
float focus = MANUAL_FOCUS*screenBrightness;
|
||||
float focus = MANUAL_FOCUS;
|
||||
#endif
|
||||
float pcoc = min(abs(aperture * (focal/100.0 * (z - focus)) / (z * (focus - focal/100.0))),texelSize.x*15.0);
|
||||
#ifdef FAR_BLUR_ONLY
|
||||
@ -478,18 +453,14 @@ void main() {
|
||||
#endif
|
||||
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
|
||||
|
||||
float BiomeParams = isWastes + isWarpedForest*10 + isCrimsonForest*10 + isSoulValley*5 + isBasaltDelta*0 ;
|
||||
|
||||
|
||||
vec3 bloom = texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5).rgb/2./7.0;
|
||||
|
||||
float lightScat = clamp(4 * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette;
|
||||
|
||||
float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette;
|
||||
|
||||
float VL_abs = texture2D(colortex7,texcoord).r;
|
||||
VL_abs = clamp((1.0-VL_abs*1.05)*BLOOMY_FOG*0.5,0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0);
|
||||
|
||||
VL_abs = clamp((1.0-VL_abs*1.05)*0.5,0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0);
|
||||
col = (mix(col,bloom,VL_abs)+bloom*lightScat)*exposure.rgb;
|
||||
col = ( mix(col, bloom, VL_abs) + bloom*lightScat) * exposure.rgb;
|
||||
/*
|
||||
//Purkinje Effect
|
||||
float lum = dot(col,vec3(0.15,0.3,0.55));
|
||||
|
@ -1,9 +1,7 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define FinalR 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#define FinalG 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#define FinalB 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec4 exposure;
|
||||
|
@ -1,70 +1,33 @@
|
||||
#version 120
|
||||
//Render sky, volumetric clouds, direct lighting
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#define SCREENSPACE_CONTACT_SHADOWS //Raymarch towards the sun in screen-space, in order to cast shadows outside of the shadow map or at the contact of objects. Can get really expensive at high resolutions.
|
||||
#define SHADOW_FILTER_SAMPLE_COUNT 9 // Number of samples used to filter the actual shadows [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 ]
|
||||
#define CAVE_LIGHT_LEAK_FIX // Hackish way to remove sunlight incorrectly leaking into the caves. Can inacurrately remove shadows in some places
|
||||
#define CLOUDS_SHADOWS
|
||||
#define CLOUDS_SHADOWS_STRENGTH 1.0 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define CLOUDS_QUALITY 0.5 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define SSAO //It is also recommended to reduce the ambientOcclusionLevel value with this enabled
|
||||
#define SSAO_SAMPLES 7 //[4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]
|
||||
#define TORCH_R 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_G 0.75 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define indirect_effect 1 // Choose what effect is applied to indirect light. [0 1 2 3]
|
||||
#define AO_Strength 0.8 // strength of shadowed areas [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/diffuse_lighting.glsl"
|
||||
|
||||
#define GI_Strength 1.0 // strength of bounced light areas [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
|
||||
// #define HQ_SSGI
|
||||
|
||||
//////////// misc settings
|
||||
|
||||
// #define WhiteWorld // THIS IS A DEBUG VIEW. uses to see AO easier. used to see fake GI better (green light)
|
||||
// #define LabPBR_Emissives
|
||||
#define Emissive_Brightness 10.0 // [1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 100.]
|
||||
#define Emissive_Curve 2.0 // yes i blatantly copied kappa here. [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
|
||||
#define n_MIN_LIGHT_AMOUNT 1.0 //[0.0 0.5 1.0 1.5 2.0 3.0 4.0 5.0]
|
||||
|
||||
const bool shadowHardwareFiltering = true;
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform float nightVision;
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying vec3 avgAmbient;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
|
||||
uniform sampler2D colortex0;//clouds
|
||||
uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex4;//Skybox
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex6;//Skybox
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex15;
|
||||
uniform sampler2D colortex6;//Skybox
|
||||
uniform sampler2D depthtex1;//depth
|
||||
uniform sampler2D depthtex0;//depth
|
||||
uniform sampler2D noisetex;//depth
|
||||
|
||||
|
||||
uniform float isWastes;
|
||||
uniform float isWarpedForest;
|
||||
uniform float isCrimsonForest;
|
||||
uniform float isSoulValley;
|
||||
uniform float isBasaltDelta;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
@ -77,45 +40,52 @@ uniform float rainStrength;
|
||||
uniform mat4 gbufferProjection;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform mat4 shadowModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
uniform float aspectRatio;
|
||||
uniform vec3 cameraPosition;
|
||||
// uniform int framemod8;
|
||||
uniform vec3 sunVec;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
#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 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
#include "lib/waterOptions.glsl"
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "lib/stars.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
#include "lib/waterBump.glsl"
|
||||
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/waterBump.glsl"
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
|
||||
|
||||
|
||||
|
||||
float ld(float dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
vec3 ld(vec3 dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
|
||||
#include "lib/specular.glsl"
|
||||
vec2 RENDER_SCALE = vec2(1.0);
|
||||
|
||||
#include "/lib/specular.glsl"
|
||||
#include "/lib/nether_fog.glsl"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
@ -144,20 +114,12 @@ vec3 fp10Dither(vec3 color,float dither){
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
|
||||
vec2 R2_samples(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
|
||||
|
||||
float facos(float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
return sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
}
|
||||
vec3 worldToView(vec3 worldPos) {
|
||||
vec4 pos = vec4(worldPos, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
@ -171,6 +133,24 @@ vec2 decodeVec2(float a){
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
// float linZ(float depth) {
|
||||
// return (2.0 * near) / (far + near - depth * (far - near));
|
||||
// // l = (2*n)/(f+n-d(f-n))
|
||||
// // f+n-d(f-n) = 2n/l
|
||||
// // -d(f-n) = ((2n/l)-f-n)
|
||||
// // d = -((2n/l)-f-n)/(f-n)
|
||||
|
||||
// }
|
||||
// float invLinZ (float lindepth){
|
||||
// return -((2.0*near/lindepth)-far-near)/(far-near);
|
||||
// }
|
||||
|
||||
// vec3 toClipSpace3(vec3 viewSpacePosition) {
|
||||
// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
@ -185,12 +165,17 @@ vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth,float maxZ){
|
||||
vec4 sampled = vec4(texelFetch2D(tex,ivec2(coord),0).rgb,1.0);
|
||||
|
||||
return vec3(sampled.x,sampled.yz/sampled.w);
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord )%512 , 0);
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y);
|
||||
@ -215,123 +200,116 @@ vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0)
|
||||
|
||||
return vec2(cos_v, sin_v)*ssR;
|
||||
}
|
||||
void ssAO(inout vec3 lighting,vec3 fragpos,float mulfov, vec2 noise, vec3 normal, float lightmap){
|
||||
|
||||
|
||||
float ssao(vec3 fragpos, float dither,vec3 normal)
|
||||
{
|
||||
float mulfov = 1.0;
|
||||
ivec2 pos = ivec2(gl_FragCoord.xy);
|
||||
const float tan70 = tan(70.*3.14/240.);
|
||||
const float tan70 = tan(70.*3.14/180.);
|
||||
float mulfov2 = gbufferProjection[1][1]/tan70;
|
||||
|
||||
float maxR2 = fragpos.z*fragpos.z*mulfov2*2.*1.412/50.0;
|
||||
const float PI = 3.14159265;
|
||||
const float samplingRadius = 0.712;
|
||||
float angle_thresh = 0.05;
|
||||
|
||||
|
||||
float rd = mulfov2 * 0.04 ;
|
||||
|
||||
|
||||
float rd = mulfov2*0.05;
|
||||
//pre-rotate direction
|
||||
float n = 0.0;
|
||||
float n = 0.;
|
||||
|
||||
float occlusion = 0.0;
|
||||
|
||||
vec2 acc = -(TAA_Offset*(texelSize/2)) ;
|
||||
|
||||
int seed = (frameCounter%40000)*2 + frameCounter;
|
||||
vec2 ij = fract(R2_samples(seed) + noise.rg );
|
||||
vec2 v = ij;
|
||||
|
||||
for (int j = 0; j < 7 ;j++) {
|
||||
vec2 sp = tapLocation(j,v.x,7,1.682,v.y);
|
||||
vec2 sampleOffset = sp*rd ;
|
||||
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio));
|
||||
vec2 acc = -vec2(TAA_Offset)*texelSize*0.5;
|
||||
float mult = (dot(normal,normalize(fragpos))+1.0)*0.5+0.5;
|
||||
|
||||
vec2 v = fract(vec2(dither,interleaved_gradientNoise()) + (frameCounter%10000) * vec2(0.75487765, 0.56984026));
|
||||
for (int j = 0; j < 7+2 ;j++) {
|
||||
vec2 sp = tapLocation(j,v.x,7+2,2.,v.y);
|
||||
vec2 sampleOffset = sp*rd;
|
||||
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight));
|
||||
if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth && offset.y < viewHeight ) {
|
||||
vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize,texelFetch2D(depthtex1,offset,0).x));
|
||||
|
||||
vec3 vec = t0.xyz - fragpos;
|
||||
float dsquared = dot(vec,vec);
|
||||
|
||||
if (dsquared > 1e-5){
|
||||
if (dsquared < maxR2){
|
||||
float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal) ),0.,1.);
|
||||
occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0);
|
||||
if (dsquared < fragpos.z*fragpos.z*0.05*0.05*mulfov2*2.*1.412){
|
||||
float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.);
|
||||
occlusion += NdotV;
|
||||
}
|
||||
n += 1.0 ;
|
||||
n += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
occlusion *= mix(2.25,0.0,clamp(pow(lightmap,2),0,1));
|
||||
occlusion = max(1.0 - occlusion/n, 0.0);
|
||||
lighting = lighting * occlusion;
|
||||
|
||||
|
||||
|
||||
|
||||
return clamp(1.0-occlusion/n*2.0,0.,1.0);
|
||||
}
|
||||
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;
|
||||
}
|
||||
void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){
|
||||
inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value
|
||||
int spCount = rayMarchSampleCount;
|
||||
vec3 start = toShadowSpaceProjected(rayStart);
|
||||
vec3 end = toShadowSpaceProjected(rayEnd);
|
||||
vec3 dV = (end-start);
|
||||
//limit ray length at 32 blocks for performance and reducing integration error
|
||||
//you can't see above this anyway
|
||||
float maxZ = min(rayLength,12.0)/(1e-8+rayLength);
|
||||
dV *= maxZ;
|
||||
vec3 dVWorld = -mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ;
|
||||
rayLength *= maxZ;
|
||||
float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
|
||||
estEndDepth *= maxZ;
|
||||
estSunDepth *= maxZ;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
vec3 vL = vec3(0.0);
|
||||
|
||||
|
||||
float expFactor = 11.0;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
for (int i=0;i<spCount;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0);
|
||||
vec3 spPos = start.xyz + dV*d;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs);
|
||||
|
||||
vec3 light = (ambientMul*ambient) * scatterCoef;
|
||||
|
||||
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs *absorbance;
|
||||
absorbance *= exp(-dd * rayLength * waterCoefs);
|
||||
}
|
||||
inColor += vL;
|
||||
}
|
||||
|
||||
|
||||
vec3 cosineHemisphereSample(vec2 Xi, float roughness)
|
||||
{
|
||||
float r = sqrt(Xi.x);
|
||||
float theta = 2.0 * 3.14159265359 * Xi.y;
|
||||
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
|
||||
return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.)));
|
||||
}
|
||||
vec3 TangentToWorld(vec3 N, vec3 H, float roughness)
|
||||
{
|
||||
vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 T = normalize(cross(UpVector, N));
|
||||
vec3 B = cross(N, T);
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord )%512 , 0);
|
||||
}
|
||||
|
||||
vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes){
|
||||
float stepSize = stepsizes;
|
||||
int maxSteps = 12;
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * sqrt(3.0)*far) > -sqrt(3.0)*near) ?
|
||||
(-sqrt(3.0)*near -position.z) / dir.z : sqrt(3.0)*far;
|
||||
vec3 end = toClipSpace3(position+dir*rayLength) ;
|
||||
vec3 direction = end-clipPosition ; //convert to clip space
|
||||
float len = max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y)/stepSize;
|
||||
//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)*2000.0;
|
||||
|
||||
vec3 stepv = direction/len;
|
||||
|
||||
int iterations = min(int(min(len, mult*len)-2), maxSteps);
|
||||
|
||||
//Do one iteration for closest texel (good contact shadows)
|
||||
vec3 spos = clipPosition ;
|
||||
spos.xy += TAA_Offset*texelSize*0.5;
|
||||
spos += stepv/(stepSize/2);
|
||||
|
||||
for(int i = 0; i < iterations; i++){
|
||||
spos += stepv*noise;
|
||||
|
||||
float sp=texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).x;
|
||||
float currZ = (spos.z);
|
||||
|
||||
if( sp < currZ) {
|
||||
// float dist = abs(sp-currZ)/currZ;
|
||||
return vec3(spos.xy, invLinZ(sp));
|
||||
}
|
||||
}
|
||||
return vec3(1.1);
|
||||
}
|
||||
void rtAO(inout vec3 lighting, vec3 normal, vec2 noise, vec3 fragpos){
|
||||
int nrays = 4;
|
||||
float occlude = 0.0;
|
||||
|
||||
for (int i = 0; i < nrays; i++){
|
||||
int seed = (frameCounter%40000)*nrays+i;
|
||||
vec2 ij = fract(R2_samples(seed) + noise );
|
||||
|
||||
vec3 rayDir = TangentToWorld( normal, normalize(cosineHemisphereSample(ij,1.0)) ,1.0) ;
|
||||
|
||||
vec3 rayHit = RT(mat3(gbufferModelView)*rayDir, fragpos, blueNoise(), 12.); // choc sspt
|
||||
|
||||
float skyLightDir = rayDir.y < 0.0 ? 1.0 : 1.0 ; // the positons where the occlusion happens
|
||||
if (rayHit.z > 1.0) occlude += skyLightDir;
|
||||
}
|
||||
lighting *= occlude/nrays;
|
||||
void LabEmission(
|
||||
inout vec3 Lighting,
|
||||
vec3 Albedo,
|
||||
float Emission
|
||||
){
|
||||
// if( Emission < 255.0/255.0 ) Lighting = mix(Lighting, Albedo * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why
|
||||
if( Emission < 255.0/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve);
|
||||
}
|
||||
|
||||
void main() {
|
||||
@ -339,97 +317,109 @@ void main() {
|
||||
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
|
||||
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
|
||||
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
|
||||
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / pi;
|
||||
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14;
|
||||
|
||||
float z0 = texture2D(depthtex0,texcoord).x;
|
||||
float z = texture2D(depthtex1,texcoord).x;
|
||||
|
||||
vec2 tempOffset=TAA_Offset;
|
||||
float noise = blueNoise();
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(tempOffset)*texelSize*0.5,z));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
|
||||
vec4 trpData = texture2D(colortex7,texcoord);
|
||||
bool iswater = trpData.a > 0.99;
|
||||
vec4 SpecularTex = texture2D(colortex8,texcoord);
|
||||
|
||||
// for a thing
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
float dL = length(dVWorld);
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + dVWorld;
|
||||
|
||||
p3 += gbufferModelViewInverse[3].xyz;
|
||||
|
||||
bool iswater = texture2D(colortex7,texcoord).a > 0.99;
|
||||
|
||||
vec4 data = texture2D(colortex1,texcoord);
|
||||
vec4 data = texture2D(colortex1,texcoord); // terraom
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
|
||||
float Translucent_Programs = texture2D(colortex2,texcoord).a; // the shader for all translucent progams.
|
||||
// Normal //
|
||||
vec3 normal = decode(dataUnpacked0.yw) ;
|
||||
|
||||
vec4 normalAndAO = texture2D(colortex15,texcoord);
|
||||
vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0;
|
||||
float vanilla_AO = 1.0 - exp2(-5 * pow(1-normalAndAO.a,3)) ;
|
||||
|
||||
|
||||
vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x));
|
||||
vec3 normal = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw));
|
||||
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
bool translucent = abs(dataUnpacked1.w-0.5) <0.01;
|
||||
bool hand = abs(dataUnpacked1.w-0.75) <0.01;
|
||||
bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
|
||||
|
||||
vec3 lightSource = normalize(vec3(0.0, -1.0,0.0));
|
||||
vec3 viewspace_sunvec = mat3(gbufferModelView) * lightSource;
|
||||
if (z >=1.0) {
|
||||
vec3 color = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)*0.02;
|
||||
|
||||
vec3 WsunVec = normalize(mat3(gbufferModelViewInverse) * viewspace_sunvec);
|
||||
float LightDir = max(dot(normal, WsunVec),0.0);
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color*8./3. * (1.0-rainStrength*0.4),triangularize(noise)),0.0,65000.);
|
||||
|
||||
} else {
|
||||
|
||||
p3 += gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
// do all ambient lighting stuff
|
||||
vec3 Indirect_lighting = DoAmbientLighting_Nether(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3, p3 );
|
||||
|
||||
|
||||
vec3 ambientCoefs = normal/dot(abs(normal),vec3(1.));
|
||||
vec3 LightColor = LightSourceColor();
|
||||
|
||||
#ifdef WhiteWorld
|
||||
albedo = vec3(1.0);
|
||||
#endif
|
||||
float SdotV = dot(normalize(viewspace_sunvec), normalize(fragpos));
|
||||
float OrbMie = max(exp((p3.y - 60) / -30.),0);
|
||||
|
||||
////// ----- indirect ----- //////
|
||||
// 0.5 added because lightsources are always high radius.
|
||||
float NdotL = clamp( dot(normal,normalize(WsunVec)) + 0.25,0.0,1.0);
|
||||
|
||||
vec3 custom_lightmap = texture2D(colortex4, (vec2(lightmap.x, pow(lightmap.y,2))*15.0+0.5+vec2(0.0,19.))*texelSize).rgb*8./150./3.; // y = torch
|
||||
vec3 LightSource = LightColor * NdotL * OrbMie ;
|
||||
|
||||
// vec3 ambientLight = vec3(1.0) / 30;
|
||||
vec3 ambientLight = ((ambientUp + ambientDown + ambientRight + ambientLeft + ambientB + ambientF) ) * (abs(ambientCoefs.y * 0.5) + 0.5) ;
|
||||
// LightSource *= rayTraceShadow(worldToView(normalize(-LightPos)), fragpos, interleaved_gradientNoise());
|
||||
// LightSource *= GetCloudShadow(p3, WsunVec, blueNoise());
|
||||
|
||||
|
||||
vec3 Lightsources = custom_lightmap.y * vec3(TORCH_R,TORCH_G,TORCH_B) * 0.5;
|
||||
if(hand) Lightsources *= 0.15;
|
||||
if(blocklights) Lightsources *= 0.3;
|
||||
if(custom_lightmap.y > 10.) Lightsources *= 0.3;
|
||||
// finalize
|
||||
gl_FragData[0].rgb = (Indirect_lighting) * albedo;
|
||||
// gl_FragData[0].rgb = LightSource * albedo;
|
||||
|
||||
//apply a curve for the torch light so it doesnt mix with lab emissive colors too much
|
||||
#ifdef LabPBR_Emissives
|
||||
if(blocklights && (SpecularTex.a > 0.0 && SpecularTex.a < 1.0)) Lightsources = mix(vec3(0.0), Lightsources, SpecularTex.a);
|
||||
#endif
|
||||
|
||||
ambientLight += Lightsources;
|
||||
|
||||
#if indirect_effect == 1
|
||||
if (!hand) ssAO(ambientLight, fragpos, 1.0, blueNoise(gl_FragCoord.xy).rg, worldToView(decode(dataUnpacked0.yw)), lightmap.x) ;
|
||||
#endif
|
||||
// #if indirect_effect == 2
|
||||
// if (!hand ) rtAO(ambientLight, normal, blueNoise(gl_FragCoord.xy).rg, fragpos);
|
||||
// #endif
|
||||
// #if indirect_effect == 3
|
||||
// if (!hand) rtGI(ambientLight, normal, blueNoise(gl_FragCoord.xy).rg, fragpos, 1, albedo);
|
||||
// #endif
|
||||
|
||||
|
||||
vec3 Indirect_lighting = ambientLight;
|
||||
|
||||
////// ----- finalize ----- //////
|
||||
|
||||
gl_FragData[0].rgb = Indirect_lighting * albedo ;
|
||||
|
||||
#ifdef LabPBR_Emissives
|
||||
gl_FragData[0].rgb = SpecularTex.a < 255.0/255.0 ? mix(gl_FragData[0].rgb, albedo * Emissive_Brightness*0.5 , SpecularTex.a): gl_FragData[0].rgb;
|
||||
#endif
|
||||
|
||||
// do this after water and stuff is done because yea
|
||||
#ifdef Specular_Reflections
|
||||
MaterialReflections(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, WsunVec, vec3(0), 0.0 , lightmap.y, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,blueNoise()), hand);
|
||||
MaterialReflections_N(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand);
|
||||
#endif
|
||||
|
||||
if(!hand) gl_FragData[0].rgb *= ssao(fragpos,noise,FlatNormals) * vanilla_AO;
|
||||
|
||||
#ifdef LabPBR_Emissives
|
||||
LabEmission(gl_FragData[0].rgb, albedo, SpecularTex.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ////// border Fog
|
||||
// if(Translucent_Programs > 0.0){
|
||||
// vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
// float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
|
||||
|
||||
// gl_FragData[0].rgb = mix(gl_FragData[0].rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
|
||||
// }
|
||||
|
||||
|
||||
////// Water Fog
|
||||
if ((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)){
|
||||
vec3 fragpos0 = toScreenSpace(vec3(texcoord-vec2(tempOffset)*texelSize*0.5,z0));
|
||||
float Vdiff = distance(fragpos,fragpos0);
|
||||
|
||||
if(isEyeInWater == 1) Vdiff = (length(fragpos));
|
||||
|
||||
float VdotU = np3.y;
|
||||
float estimatedDepth = Vdiff; //assuming water plane
|
||||
float estimatedSunDepth = estimatedDepth; //assuming water plane
|
||||
|
||||
vec3 ambientColVol = vec3(1.0,0.25,0.5) * 0.33 ;
|
||||
|
||||
waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol);
|
||||
}
|
||||
|
||||
|
||||
/* DRAWBUFFERS:3 */
|
||||
}
|
||||
|
@ -1,17 +1,12 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#define TAA
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying vec3 avgAmbient;
|
||||
flat varying vec4 lightCol;
|
||||
|
||||
flat varying float tempOffsets;
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying vec3 zMults;
|
||||
@ -43,26 +38,14 @@ void main() {
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
|
||||
TAA_Offset = offsets[frameCounter%8];
|
||||
|
||||
#ifndef TAA
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
ambientRight = texelFetch2D(colortex4,ivec2(3,37),0).rgb;
|
||||
ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb;
|
||||
ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb;
|
||||
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb;
|
||||
|
||||
lightCol.a = float(sunElevation > 1e-5)*2-1.;
|
||||
lightCol.rgb = sc;
|
||||
|
||||
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
|
||||
avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
zMults = vec3((far * near)*2.0,far+near,far-near);
|
||||
|
||||
|
||||
}
|
||||
|
79
shaders/world-1/composite3.fsh
Normal file
79
shaders/world-1/composite3.fsh
Normal file
@ -0,0 +1,79 @@
|
||||
#version 120
|
||||
//Volumetric fog rendering
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying float tempOffsets;
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex4;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float far;
|
||||
uniform int frameCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float sunElevation;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
#include "/lib/projections.glsl"
|
||||
#include "/lib/nether_fog.glsl"
|
||||
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
|
||||
float interleaved_gradientNoise(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets);
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
|
||||
// if (isEyeInWater == 0){
|
||||
// vec2 tc = floor(gl_FragCoord.xy)*2.0*texelSize+0.5*texelSize;
|
||||
// float z = texture2D(depthtex0,tc).x;
|
||||
// vec3 fragpos = toScreenSpace(vec3(tc,z));
|
||||
|
||||
// vec3 fragpos_ALT = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
|
||||
// float noise = blueNoise();
|
||||
// mat2x3 vl = getVolumetricRays(noise,fragpos, interleaved_gradientNoise());
|
||||
|
||||
// float absorbance = dot(vl[1],vec3(0.22,0.71,0.07));
|
||||
|
||||
// gl_FragData[0] = clamp(vec4(vl[0],absorbance),0.000001,65000.);
|
||||
|
||||
// } else {
|
||||
// gl_FragData[0] = vec4(0.0);
|
||||
// }
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec3 zMults;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
uniform int frameCounter;
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -12,8 +14,9 @@ uniform float near;
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
zMults = vec3(1.0/(far * near),far+near,far-near);
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0;
|
||||
}
|
@ -1,271 +0,0 @@
|
||||
#version 120
|
||||
//Volumetric fog rendering
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define VL_SAMPLES 8 //[4 6 8 10 12 14 16 20 24 30 40 50]
|
||||
#define Ambient_Mult 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.5 2.0 3.0 4.0 5.0 6.0 10.0]
|
||||
#define SEA_LEVEL 70 //[0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190] //The volumetric light uses an altitude-based fog density, this is where fog density is the highest, adjust this value according to your world.
|
||||
#define ATMOSPHERIC_DENSITY 1.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 4.0 5.0 7.5 10.0 12.5 15.0 20.]
|
||||
#define fog_mieg1 0.40 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
#define fog_mieg2 0.10 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
#define fog_coefficientRayleighR 5.8 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientRayleighG 1.35 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientRayleighB 3.31 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
|
||||
#define fog_coefficientMieR 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientMieG 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientMieB 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
|
||||
#define Underwater_Fog_Density 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.5 2.0 3.0 4.0]
|
||||
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying float tempOffsets;
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float far;
|
||||
uniform int frameCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float sunElevation;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
|
||||
uniform float isWastes;
|
||||
uniform float isWarpedForest;
|
||||
uniform float isCrimsonForest;
|
||||
uniform float isSoulValley;
|
||||
uniform float isBasaltDelta;
|
||||
|
||||
|
||||
#include "lib/waterOptions.glsl"
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/color_dither.glsl"
|
||||
#include "lib/projections.glsl"
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
|
||||
float interleaved_gradientNoise(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets);
|
||||
}
|
||||
|
||||
|
||||
float phaseg(float x, float g){
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) /3.14;
|
||||
}
|
||||
float phaseRayleigh(float cosTheta) {
|
||||
const vec2 mul_add = vec2(0.1, 0.28) /acos(-1.0);
|
||||
return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation
|
||||
}
|
||||
|
||||
float densityAtPos(in vec3 pos)
|
||||
{
|
||||
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
|
||||
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
|
||||
f = (f*f) * (3.-2.*f);
|
||||
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
|
||||
vec2 coord = uv / 512.0;
|
||||
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
// float cloudVol(in vec3 pos){
|
||||
|
||||
// vec3 samplePos = pos*vec3(1.0,1./32.,1.0)*5.0+frameTimeCounter*vec3(0.5,0.,0.5)*1.;
|
||||
// float noise = densityAtPos(samplePos*12.);
|
||||
// float unifCov = exp2(-max(pos.y-SEA_LEVEL,0.0)/50.);
|
||||
|
||||
// float cloud = pow(clamp(1.0-noise-0.76,0.0,1.0),2.)+0.005;
|
||||
|
||||
// return cloud;
|
||||
// }
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
|
||||
// float[4] BiomeParams = float[4](
|
||||
// /*[0] Cloudy amount */ isWastes*5 + isWarpedForest*0 + isCrimsonForest*0 + isSoulValley + isBasaltDelta*2
|
||||
// /*[1] uniform amount*/ ,isWastes*0 + isWarpedForest*0.005 + isCrimsonForest*0.005 + isSoulValley*0.5 + isBasaltDelta*0
|
||||
// /*[2] uniform height*/ ,isWastes*3 + isWarpedForest*100 + isCrimsonForest*100 + isSoulValley*2 + isBasaltDelta
|
||||
// /*[3] cloudy height*/ ,isWastes*20 + isWarpedForest + isCrimsonForest + isSoulValley*100 + isBasaltDelta*100
|
||||
// );
|
||||
|
||||
// cloudy fog shapes
|
||||
vec3 samplePos = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
samplePos.x += frameTimeCounter*2.0;
|
||||
float cloudy_fog_erosion = densityAtPos(samplePos * 200.0);
|
||||
|
||||
samplePos += cloudy_fog_erosion;
|
||||
|
||||
samplePos.y -= frameTimeCounter*0.2;
|
||||
float main_cloudy_fog = densityAtPos(samplePos * 50.0);
|
||||
|
||||
float final = main_cloudy_fog/100.0;
|
||||
return final;
|
||||
}
|
||||
|
||||
mat2x3 getVolumetricRays(float dither,vec3 fragpos) {
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = toShadowSpaceProjected(vec3(0.));
|
||||
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = (fragposition-start);
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
|
||||
float maxLength = min(length(dVWorld),far)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
vec3 vL = vec3(0.);
|
||||
|
||||
float SdotV = dot(sunVec,normalize(fragpos))*lightCol.a;
|
||||
float dL = length(dVWorld);
|
||||
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
|
||||
float mie = max(phaseg(SdotV,fog_mieg1),1.0/13.0);
|
||||
float rayL = phaseRayleigh(SdotV);
|
||||
// wpos.y = clamp(wpos.y,0.0,1.0);
|
||||
|
||||
vec3 ambientCoefs = dVWorld/dot(abs(dVWorld),vec3(1.));
|
||||
|
||||
vec3 ambientLight = ambientUp;
|
||||
ambientLight += ambientDown;
|
||||
ambientLight += ambientRight;
|
||||
ambientLight += ambientLeft;
|
||||
ambientLight += ambientB;
|
||||
ambientLight += ambientF;
|
||||
|
||||
vec3 skyCol0 = ambientLight*8.*2./150./3.*Ambient_Mult*3.1415;
|
||||
|
||||
float mu = 1.0;
|
||||
float muS = 1.05;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float expFactor = 11.0;
|
||||
|
||||
vec3 fogColor = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)*0.05;
|
||||
|
||||
// float testcolor = clamp(exp2(-max(progressW.y-25,0.0)/5) ,0,1);
|
||||
// fogColor = mix(fogColor, vec3(0,1,0), testcolor);
|
||||
|
||||
for (int i=0;i<VL_SAMPLES+10;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES+10))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES+10)) * log(expFactor) / float(VL_SAMPLES+10)/(expFactor-1.0);
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
float densityVol = cloudVol(progressW)*2.0;
|
||||
float density = densityVol;
|
||||
vec3 vL0 = density*fogColor;
|
||||
vL += (vL0 - vL0 * exp(-density*mu*dd*dL)) / (density*mu+0.00000001)*absorbance;
|
||||
absorbance *= clamp(exp(-density*mu*dd*dL),0.0,1.0);
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
|
||||
|
||||
|
||||
}
|
||||
void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEyeDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){
|
||||
int spCount = 16;
|
||||
|
||||
vec3 start = toShadowSpaceProjected(rayStart);
|
||||
vec3 end = toShadowSpaceProjected(rayEnd);
|
||||
vec3 dV = (end-start);
|
||||
//limit ray length at 32 blocks for performance and reducing integration error
|
||||
//you can't see above this anyway
|
||||
float maxZ = min(rayLength,32.0)/(1e-8+rayLength);
|
||||
dV *= maxZ;
|
||||
rayLength *= maxZ;
|
||||
float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
vec3 vL = vec3(0.0);
|
||||
float phase = phaseg(VdotL, Dirt_Mie_Phase);
|
||||
float expFactor = 11.0;
|
||||
for (int i=0;i<spCount;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); // exponential step position (0-1)
|
||||
float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0); //step length (derivative)
|
||||
vec3 spPos = start.xyz + dV*d;
|
||||
vec3 ambientMul = exp(-max(estEyeDepth - dY * d,0.0) * waterCoefs * 1.1);
|
||||
vec3 light = (ambientMul*ambient )*scatterCoef;
|
||||
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs *absorbance;
|
||||
absorbance *= exp(-dd * rayLength * waterCoefs);
|
||||
}
|
||||
inColor += vL;
|
||||
}
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
if (isEyeInWater == 0){
|
||||
vec2 tc = floor(gl_FragCoord.xy)*2.0*texelSize+0.5*texelSize;
|
||||
float z = texture2D(depthtex0,tc).x;
|
||||
vec3 fragpos = toScreenSpace(vec3(tc,z));
|
||||
float noise = blueNoise();
|
||||
mat2x3 vl = getVolumetricRays(noise,fragpos);
|
||||
float absorbance = dot(vl[1],vec3(0.22,0.71,0.07));
|
||||
gl_FragData[0] = clamp(vec4(vl[0],absorbance),0.000001,65000.);
|
||||
}
|
||||
else {
|
||||
float dirtAmount = Dirt_Amount;
|
||||
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
|
||||
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
|
||||
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
|
||||
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / pi;
|
||||
vec2 tc = floor(gl_FragCoord.xy)*2.0*texelSize+0.5*texelSize;
|
||||
float z = texture2D(depthtex0,tc).x;
|
||||
vec3 fragpos = toScreenSpace(vec3(tc,z));
|
||||
float noise=blueNoise();
|
||||
vec3 vl = vec3(0.0);
|
||||
float estEyeDepth = clamp((14.0-eyeBrightnessSmooth.y/255.0*16.0)/14.0,0.,1.0);
|
||||
estEyeDepth *= estEyeDepth*estEyeDepth*34.0;
|
||||
#ifndef lightMapDepthEstimation
|
||||
estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0);
|
||||
#endif
|
||||
waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, ambientUp*8./150./3.*0.84*2.0/pi, lightCol.rgb*8./150./3.0*(0.91-pow(1.0-sunElevation,5.0)*0.86), dot(normalize(fragpos), normalize(sunVec)));
|
||||
gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.);
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define BASE_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0] Base fog amount amount (does not change the "cloudy" fog)
|
||||
#define CLOUDY_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
#define FOG_TOD_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of time of day on fog amount
|
||||
#define FOG_RAIN_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of rain on fog amount
|
||||
|
||||
flat varying vec4 lightCol;
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
flat varying vec3 ambientB;
|
||||
flat varying vec3 ambientF;
|
||||
flat varying vec3 ambientDown;
|
||||
flat varying float tempOffsets;
|
||||
flat varying float fogAmount;
|
||||
flat varying float VFAmount;
|
||||
|
||||
varying vec2 texcoord;
|
||||
uniform sampler2D colortex4;
|
||||
uniform float sunElevation;
|
||||
uniform float rainStrength;
|
||||
uniform int isEyeInWater;
|
||||
uniform int frameCounter;
|
||||
uniform int worldTime;
|
||||
#include "/lib/util.glsl"
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
gl_Position = ftransform();
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0;
|
||||
vec3 avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb;
|
||||
ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb;
|
||||
ambientRight = texelFetch2D(colortex4,ivec2(3,37),0).rgb;
|
||||
ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb;
|
||||
ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb;
|
||||
|
||||
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
}
|
@ -2,22 +2,17 @@
|
||||
//Horizontal bilateral blur for volumetric fog + Forward rendered objects + Draw volumetric fog
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define Cave_fog // cave fog....
|
||||
#define CaveFogFallOff 1.3 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#define CaveFogColor_R 0.1 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define CaveFogColor_G 0.2 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define CaveFogColor_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
// #define display_LUT // aaaaaaaaaaaaaaaaaaaaaaa
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec3 zMults;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D colortex13;
|
||||
uniform sampler2D colortex11;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D noisetex;
|
||||
@ -28,29 +23,18 @@ uniform float far;
|
||||
uniform float near;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform vec2 texelSize;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
|
||||
|
||||
uniform float isWastes;
|
||||
uniform float isWarpedForest;
|
||||
uniform float isCrimsonForest;
|
||||
uniform float isSoulValley;
|
||||
uniform float isBasaltDelta;
|
||||
|
||||
uniform int isEyeInWater;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float rainStrength;
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
uniform float darknessLightFactor;
|
||||
uniform float nightVision;
|
||||
|
||||
|
||||
#include "/lib/waterBump.glsl"
|
||||
|
||||
#include "lib/waterBump.glsl"
|
||||
#include "lib/waterOptions.glsl"
|
||||
float ld(float depth) {
|
||||
return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
|
||||
}
|
||||
@ -98,86 +82,93 @@ vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth){
|
||||
|
||||
return vl/sum;
|
||||
}
|
||||
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
n.xy = abs(encn);
|
||||
n.z = 1.0 - n.x - n.y;
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
|
||||
vec3 worldToView(vec3 worldPos) {
|
||||
vec4 pos = vec4(worldPos, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
void main() {
|
||||
/* DRAWBUFFERS:73 */
|
||||
//3x3 bilateral upscale from half resolution
|
||||
float z = texture2D(depthtex0,texcoord).x;
|
||||
float z2 = texture2D(depthtex1,texcoord).x;
|
||||
float frDepth = ld(z);
|
||||
vec4 vl = BilateralUpscale(colortex0,depthtex0,gl_FragCoord.xy,frDepth);
|
||||
float glassdepth = clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15);
|
||||
|
||||
// vec4 vl = BilateralUpscale(colortex0,depthtex0,gl_FragCoord.xy,frDepth);
|
||||
float bloomyfogmult = 1.0;
|
||||
|
||||
vec4 Translucent_Programs = texture2D(colortex2,texcoord); // the shader for all translucent progams.
|
||||
|
||||
vec4 transparencies = texture2D(colortex2,texcoord);
|
||||
vec4 trpData = texture2D(colortex7,texcoord);
|
||||
bool iswater = trpData.a > 0.99;
|
||||
vec2 refractedCoord = texcoord;
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
vec3 fragpos2 = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z2));
|
||||
// vec3 np3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
|
||||
if (iswater){
|
||||
float norm = getWaterHeightmap(np3.xz*1.71, 4.0, 0.25, 1.0);
|
||||
float displ = norm/(length(fragpos)/far)/35.;
|
||||
refractedCoord += displ;
|
||||
vec2 data = texture2D(colortex11,texcoord).xy; // translucents
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
|
||||
if (texture2D(colortex7,refractedCoord).a < 0.99)
|
||||
refractedCoord = texcoord;
|
||||
vec3 normals = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw) );
|
||||
|
||||
}
|
||||
// vec4 vl = BilateralUpscale(colortex0,depthtex0,gl_FragCoord.xy,frDepth);
|
||||
|
||||
#ifdef Refraction
|
||||
refractedCoord += normals.xy * glassdepth;
|
||||
|
||||
float refractedalpha = texture2D(colortex13,refractedCoord).a;
|
||||
if(refractedalpha <= 0.0) refractedCoord = texcoord; // remove refracted coords on solids
|
||||
#endif
|
||||
|
||||
vec3 color = texture2D(colortex3,refractedCoord).rgb;
|
||||
if (frDepth > 2.5/far || transparencies.a < 0.99) // Discount fix for transparencies through hand
|
||||
color = color*(1.0-transparencies.a)+transparencies.rgb*10.;
|
||||
|
||||
float dirtAmount = Dirt_Amount;
|
||||
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
|
||||
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
|
||||
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
|
||||
if (Translucent_Programs.a > 0.0){
|
||||
#ifdef Glass_Tint
|
||||
vec3 GlassAlbedo = texture2D(colortex13,texcoord).rgb * 5.0;
|
||||
color = color*GlassAlbedo.rgb + color * clamp(pow(1.0-luma(GlassAlbedo.rgb),10.),0.0,1.0);
|
||||
#endif
|
||||
|
||||
color *= vl.a;
|
||||
|
||||
|
||||
// vec3 fogColor = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)*0.05;
|
||||
|
||||
//cave fog
|
||||
if (isEyeInWater == 0){
|
||||
vec3 fogColor = clamp(gl_Fog.color.rgb,0.0,1.0) * 8. * (1.0-vl.a);
|
||||
|
||||
float fogdistfade = clamp(length(fragpos)/far, 0.0, 1.0);
|
||||
|
||||
float fogfade = clamp(exp((1.0 - np3.y)*4 - 8),0.0,1.0);
|
||||
|
||||
// float fog = 1.0 - clamp( exp2(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
|
||||
|
||||
float fog = clamp( pow(length(fragpos / far),0.5) ,0.0,1.0);
|
||||
|
||||
color.rgb = mix(color.rgb, fogColor * fogfade , fog ) ;
|
||||
vl.a *= 1.0 - fogdistfade;
|
||||
color = color*(1.0-Translucent_Programs.a) + Translucent_Programs.rgb;
|
||||
}
|
||||
|
||||
if (isEyeInWater == 0){
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
|
||||
bloomyfogmult = 1.0 - fogdistfade*0.5 ;
|
||||
|
||||
color.rgb = mix(color.rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
|
||||
}
|
||||
|
||||
// color *= vl.a;
|
||||
// color += vl.rgb;
|
||||
// bloomyfogmult *= pow(vl.a,0.1);
|
||||
|
||||
|
||||
|
||||
// underwater fog
|
||||
if (isEyeInWater == 1){
|
||||
// color.rgb *= exp(-length(fragpos)/2*totEpsilon);
|
||||
// vl.a *= (dot(exp(-length(fragpos)/1.2*totEpsilon),vec3(0.2,0.7,0.1)))*0.5+0.5;
|
||||
|
||||
float fogfade = clamp(exp(-length(fragpos) /12 ) ,0.0,1.0);
|
||||
float fogcolfade = clamp(exp(np3.y*1.5 - 1.5),0.0,1.0);
|
||||
color.rgb *= fogfade;
|
||||
color.rgb = color.rgb * (1.0 + vec3(0.0,0.1,0.2) * 12 * (1.0 - fogfade)) + (vec3(0.0,0.1,0.2) * 0.5 * (1.0 - fogfade))*fogcolfade;
|
||||
|
||||
vl.a *= fogfade*0.75 +0.25;
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
float fogfade = clamp(exp(-length(fragpos) /5. ) ,0.0,1.0);
|
||||
bloomyfogmult *= fogfade*0.70+0.3 ;
|
||||
}
|
||||
/// lava.
|
||||
if (isEyeInWater == 2){
|
||||
@ -185,21 +176,21 @@ void main() {
|
||||
}
|
||||
/// powdered snow
|
||||
if (isEyeInWater == 3){
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.));
|
||||
vl.a = 0.0;
|
||||
bloomyfogmult = 0.0;
|
||||
}
|
||||
// blidnesss
|
||||
color.rgb *= mix(1.0, clamp(1.5-pow(length(fragpos2)*(blindness*0.2),2.0),0.0,1.0), blindness);
|
||||
if (blindness > 0.0){
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
|
||||
color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(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);
|
||||
if(darknessFactor > 0.0){
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z2));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// float BiomeParams = isWastes + isWarpedForest + isCrimsonForest + isSoulValley + isBasaltDelta ;
|
||||
|
||||
gl_FragData[0] = vec4(vl.a, 0.0, 0.0, 0.0);
|
||||
gl_FragData[0].r = bloomyfogmult;
|
||||
gl_FragData[1].rgb = clamp(color,6.11*1e-5,65000.0);
|
||||
|
||||
#ifdef display_LUT
|
||||
gl_FragData[1].rgb = texture2D(colortex4,texcoord*0.45).rgb * 0.000035;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,20 +1,8 @@
|
||||
#version 120
|
||||
//Temporal Anti-Aliasing + Dynamic exposure calculations (vertex shader)
|
||||
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define TAA //if disabled you should increase most samples counts as I rely on TAA to filter noise
|
||||
|
||||
//#define FAST_TAA //disables bicubic resampling and closest velocity, improves fps especially at high resolutions
|
||||
|
||||
//TAA OPTIONS
|
||||
//#define NO_CLIP //Removes all anti-ghosting techniques used and creates a sharp image (good for still screenshots)
|
||||
#define BLEND_FACTOR 0.05 //[0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16] higher values = more flickering but sharper image, lower values = less flickering but the image will be blurrier
|
||||
#define MOTION_REJECTION 0.5 //[0.0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.5] //Higher values=sharper image in motion at the cost of flickering
|
||||
#define ANTI_GHOSTING 1.0 //[0.0 0.25 0.5 0.75 1.0] High values reduce ghosting but may create flickering
|
||||
#define FLICKER_REDUCTION 0.75 //[0.0 0.25 0.5 0.75 1.0] High values reduce flickering but may reduce sharpness
|
||||
#define CLOSEST_VELOCITY //improves edge quality in motion at the cost of performance
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
const int noiseTextureResolution = 32;
|
||||
|
||||
@ -48,12 +36,18 @@ uniform sampler2D depthtex0;
|
||||
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int framemod8;
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
|
||||
|
||||
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
#include "lib/projections.glsl"
|
||||
|
||||
#include "/lib/projections.glsl"
|
||||
|
||||
|
||||
float luma(vec3 color) {
|
||||
@ -231,15 +225,54 @@ vec3 clip_aabb(vec3 q,vec3 aabb_min, vec3 aabb_max)
|
||||
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
vec3 tonemap(vec3 col){
|
||||
return col/(1+luma(col));
|
||||
}
|
||||
vec3 invTonemap(vec3 col){
|
||||
return col/(1-luma(col));
|
||||
}
|
||||
vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
|
||||
{
|
||||
vec2 du = vec2(texelSize.x*2., 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y*2.);
|
||||
|
||||
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x);
|
||||
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x);
|
||||
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x);
|
||||
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x);
|
||||
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x);
|
||||
|
||||
vec3 dmin = dmc;
|
||||
dmin = dmin.z > dtr.z? dtr : dmin;
|
||||
dmin = dmin.z > dtl.z? dtl : dmin;
|
||||
dmin = dmin.z > dbl.z? dbl : dmin;
|
||||
dmin = dmin.z > dbr.z? dbr : dmin;
|
||||
#ifdef TAA_UPSCALING
|
||||
dmin.xy = dmin.xy/RENDER_SCALE;
|
||||
#endif
|
||||
return dmin;
|
||||
}
|
||||
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 TAA_hq(){
|
||||
|
||||
vec2 adjTC = texcoord;
|
||||
|
||||
|
||||
//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 = closestToCamera3x3();
|
||||
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
|
||||
#endif
|
||||
|
||||
#ifndef CLOSEST_VELOCITY
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex0,texcoord).x);
|
||||
vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x);
|
||||
#endif
|
||||
|
||||
//reproject previous frame
|
||||
@ -250,44 +283,47 @@ vec3 TAA_hq(){
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
//to reduce error propagation caused by interpolation during history resampling, we will introduce back some aliasing in motion
|
||||
vec2 d = 0.5-abs(fract(previousPosition.xy*vec2(viewWidth,viewHeight)-texcoord*vec2(viewWidth,viewHeight))-0.5);
|
||||
float mixFactor = dot(d,d);
|
||||
float rej = mixFactor*MOTION_REJECTION;
|
||||
//reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return texture2D(colortex3, texcoord).rgb;
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
|
||||
return smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
|
||||
//Samples current frame 3x3 neighboorhood
|
||||
vec3 albedoCurrent0 = texture2D(colortex3, texcoord).rgb;
|
||||
vec3 albedoCurrent1 = texture2D(colortex3, texcoord + vec2(texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex3, texcoord + vec2(texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex3, texcoord + vec2(-texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex3, texcoord + vec2(-texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent5 = texture2D(colortex3, texcoord + vec2(0.0,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent6 = texture2D(colortex3, texcoord + vec2(0.0,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent7 = texture2D(colortex3, texcoord + vec2(-texelSize.x,0.0)).rgb;
|
||||
vec3 albedoCurrent8 = texture2D(colortex3, texcoord + vec2(texelSize.x,0.0)).rgb;
|
||||
|
||||
#ifndef NO_CLIP
|
||||
#ifdef TAA_UPSCALING
|
||||
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
|
||||
// Interpolating neighboorhood clampling boundaries between pixels
|
||||
vec3 cMax = texture2D(colortex0, adjTC).rgb;
|
||||
vec3 cMin = texture2D(colortex6, adjTC).rgb;
|
||||
#else
|
||||
vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb;
|
||||
vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb;
|
||||
vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb;
|
||||
vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb;
|
||||
vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb;
|
||||
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
|
||||
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
|
||||
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
|
||||
albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb;
|
||||
#endif
|
||||
|
||||
|
||||
vec3 albedoPrev = FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.82).xyz;
|
||||
#ifndef NO_CLIP
|
||||
vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0);
|
||||
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
|
||||
|
||||
//Increases blending factor when far from AABB and in motion, reduces ghosting
|
||||
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5;
|
||||
float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0);
|
||||
|
||||
float test = 0.05;
|
||||
// if(hand) movementRejection *= 5;
|
||||
// if(istranslucent) test = 0.1;
|
||||
|
||||
//increases blending factor if history is far away from aabb, reduces ghosting at the cost of some flickering
|
||||
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev);
|
||||
//Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
// vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, min(luma(motionVector) *255,1.0),1.)));
|
||||
|
||||
//reduces blending factor if current texel is far from history, reduces flickering
|
||||
float lumDiff2 = distance(albedoPrev,albedoCurrent0)/luma(albedoPrev);
|
||||
lumDiff2 = 1.0-clamp(lumDiff2*lumDiff2,0.,1.)*FLICKER_REDUCTION;
|
||||
|
||||
//Blend current pixel with clamped history
|
||||
vec3 supersampled = mix(finalcAcc,albedoCurrent0,clamp(BLEND_FACTOR*lumDiff2+rej+isclamped*ANTI_GHOSTING+0.01,0.,1.));
|
||||
vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, test,1.)));
|
||||
#endif
|
||||
|
||||
|
||||
@ -303,11 +339,13 @@ vec3 TAA_hq(){
|
||||
void main() {
|
||||
|
||||
/* DRAWBUFFERS:5 */
|
||||
gl_FragData[0].a = 1.0;
|
||||
gl_FragData[0].a = 1.0;
|
||||
|
||||
#ifdef TAA
|
||||
vec3 color = TAA_hq();
|
||||
gl_FragData[0].rgb = clamp(fp10Dither(color,triangularize(interleaved_gradientNoise())),6.11*1e-5,65000.0);
|
||||
#endif
|
||||
|
||||
#ifndef TAA
|
||||
vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.);
|
||||
gl_FragData[0].rgb = color;
|
||||
|
@ -7,7 +7,10 @@ flat varying float exposureA;
|
||||
flat varying float tempOffsets;
|
||||
uniform sampler2D colortex4;
|
||||
uniform int frameCounter;
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
|
||||
void main() {
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
|
@ -2,7 +2,6 @@
|
||||
//downsample 1st pass (half res) for bloom
|
||||
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex8;
|
||||
uniform vec2 texelSize;
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
@ -18,9 +17,6 @@ void main() {
|
||||
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
|
||||
vec2 quarterResTC = gl_FragCoord.xy*2.*resScale*texelSize;
|
||||
|
||||
float emissives = texture2D(colortex8,quarterResTC).a;
|
||||
if(emissives == 1.0) emissives = 0.0;
|
||||
emissives *= 5;
|
||||
//0.5
|
||||
gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
|
||||
@ -43,10 +39,6 @@ emissives *= 5;
|
||||
gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125;
|
||||
|
||||
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
|
||||
|
||||
// gl_FragData[0].rgb += gl_FragData[0].rgb*emissives;
|
||||
|
||||
|
||||
if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0);
|
||||
|
||||
|
||||
|
@ -2,14 +2,7 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
|
||||
//Prepares sky textures (2 * 256 * 256), computes light values and custom lightmaps
|
||||
#define Ambient_Mult 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.5 2.0 3.0 4.0 5.0 6.0 10.0]
|
||||
#define Sky_Brightness 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.5 2.0 3.0 4.0 5.0 6.0 10.0]
|
||||
#define MIN_LIGHT_AMOUNT 1.0 //[0.0 0.5 1.0 1.5 2.0 3.0 4.0 5.0]
|
||||
#define TORCH_AMOUNT 1.0 //[0.0 0.5 0.75 1. 1.2 1.4 1.6 1.8 2.0]
|
||||
#define TORCH_R 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_G 0.75 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
|
||||
flat varying vec3 ambientUp;
|
||||
@ -53,8 +46,12 @@ uniform float sunElevation;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform float far;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/ROBOBO_sky.glsl"
|
||||
|
||||
|
||||
vec3 toShadowSpaceProjected(vec3 p3){
|
||||
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
||||
p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
@ -75,62 +72,8 @@ const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:4 */
|
||||
|
||||
gl_FragData[0] = vec4(0.0);
|
||||
float minLight = MIN_LIGHT_AMOUNT * 0.007/ (exposure + rodExposure/(rodExposure+1.0)*exposure*1.);
|
||||
vec3 minLight_col = MIN_LIGHT_AMOUNT * 0.007/ (exposure + rodExposure/(rodExposure+1.0)*exposure*1.) * vec3(0.8,0.9,1.0);
|
||||
//Lightmap for forward shading (contains average integrated sky color across all faces + torch + min ambient)
|
||||
vec3 avgAmbient = (ambientUp + ambientLeft + ambientRight + ambientB + ambientF + ambientDown)/6.;
|
||||
if (gl_FragCoord.x < 17. && gl_FragCoord.y < 17.){
|
||||
float torchLut = clamp(16.0-gl_FragCoord.x,0.5,15.5);
|
||||
torchLut = torchLut+0.712;
|
||||
float torch_lightmap = max(1.0/torchLut/torchLut - 1/17.212/17.212,0.0);
|
||||
torch_lightmap = pow(torch_lightmap*2.5,1.5)*TORCH_AMOUNT*10.;
|
||||
float sky_lightmap = (Slightmap[int(gl_FragCoord.y)]-14.0)/235.;
|
||||
sky_lightmap = pow(sky_lightmap,1.4);
|
||||
vec3 ambient = avgAmbient*sky_lightmap+torch_lightmap*vec3(TORCH_R,TORCH_G,TORCH_B)*TORCH_AMOUNT;
|
||||
|
||||
gl_FragData[0] = vec4(ambient*Ambient_Mult,1.0);
|
||||
}
|
||||
|
||||
//Lightmap for deferred shading (contains only torch + min ambient)
|
||||
if (gl_FragCoord.x < 17. && gl_FragCoord.y > 19. && gl_FragCoord.y < 19.+17. ){
|
||||
float torchLut = clamp(16.0-gl_FragCoord.x,0.5,15.5);
|
||||
torchLut = torchLut+0.712;
|
||||
float torch_lightmap = max(1.0/torchLut/torchLut - 1/17.212/17.212,0.0);
|
||||
float ambient = pow(torch_lightmap*2.5,1.5)*TORCH_AMOUNT*10.;
|
||||
float sky_lightmap = (Slightmap[int(gl_FragCoord.y-19.0)]-14.0)/235./150.;
|
||||
|
||||
gl_FragData[0] = vec4(sky_lightmap,ambient,minLight,1.0)*Ambient_Mult;
|
||||
}
|
||||
|
||||
//Save light values
|
||||
if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientUp,1.0);
|
||||
if (gl_FragCoord.x > 1. && gl_FragCoord.x < 2. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientDown,1.0);
|
||||
if (gl_FragCoord.x > 2. && gl_FragCoord.x < 3. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientLeft,1.0);
|
||||
if (gl_FragCoord.x > 3. && gl_FragCoord.x < 4. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientRight,1.0);
|
||||
if (gl_FragCoord.x > 4. && gl_FragCoord.x < 5. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientB,1.0);
|
||||
if (gl_FragCoord.x > 5. && gl_FragCoord.x < 6. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(ambientF,1.0);
|
||||
if (gl_FragCoord.x > 6. && gl_FragCoord.x < 7. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(lightSourceColor,1.0);
|
||||
if (gl_FragCoord.x > 7. && gl_FragCoord.x < 8. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(avgAmbient,1.0);
|
||||
|
||||
//Sky gradient (no clouds)
|
||||
const float pi = 3.141592653589793238462643383279502884197169;
|
||||
if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){
|
||||
gl_FragData[0] = vec4(vec3(1.0,0.4,0.12)*100.,1.0);
|
||||
}
|
||||
|
||||
//Temporally accumulate sky and light values
|
||||
vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb;
|
||||
vec3 curr = gl_FragData[0].rgb*150.;
|
||||
gl_FragData[0].rgb = clamp(mix(temp,curr,0.06),0.0,65000.);
|
||||
|
||||
//Exposure values
|
||||
if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
|
@ -1,14 +1,8 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#define EXPOSURE_MULTIPLIER 1.0 //[0.25 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.1 1.2 1.3 1.4 1.5 2.0 3.0 4.0]
|
||||
#define AUTO_EXPOSURE //Highly recommended to keep it on unless you want to take screenshots
|
||||
#define Manual_exposure_value 1.0 // [0.000553 0.000581 0.000611 0.000642 0.000675 0.000710 0.000746 0.000784 0.000825 0.000867 0.000911 0.000958 0.001007 0.001059 0.001113 0.001170 0.001230 0.001294 0.001360 0.001430 0.001503 0.001580 0.001661 0.001746 0.001836 0.001930 0.002029 0.002133 0.002242 0.002357 0.002478 0.002605 0.002739 0.002879 0.003027 0.003182 0.003345 0.003517 0.003697 0.003887 0.004086 0.004296 0.004516 0.004748 0.004991 0.005247 0.005516 0.005799 0.006096 0.006409 0.006737 0.007083 0.007446 0.007828 0.008229 0.008651 0.009095 0.009561 0.010051 0.010567 0.011108 0.011678 0.012277 0.012906 0.013568 0.014264 0.014995 0.015764 0.016572 0.017422 0.018315 0.019254 0.020241 0.021279 0.022370 0.023517 0.024723 0.025991 0.027323 0.028724 0.030197 0.031745 0.033373 0.035084 0.036883 0.038774 0.040762 0.042852 0.045049 0.047358 0.049787 0.052339 0.055023 0.057844 0.060810 0.063927 0.067205 0.070651 0.074273 0.078081 0.082084 0.086293 0.090717 0.095369 0.100258 0.105399 0.110803 0.116484 0.122456 0.128734 0.135335 0.142274 0.149568 0.157237 0.165298 0.173773 0.182683 0.192049 0.201896 0.212247 0.223130 0.234570 0.246596 0.259240 0.272531 0.286504 0.301194 0.316636 0.332871 0.349937 0.367879 0.386741 0.406569 0.427414 0.449328 0.472366 0.496585 0.522045 0.548811 0.576949 0.606530 0.637628 0.670320 0.704688 0.740818 0.778800 0.818730 0.860707 0.904837 0.951229 1.0 1.051271 1.105170 1.161834 1.221402 1.284025 1.349858 1.419067 1.491824 1.568312 1.648721 1.733253 1.822118 1.915540 2.013752 2.117000 2.225540 2.339646 2.459603 2.585709 2.718281 2.857651 3.004166 3.158192 3.320116 3.490342 3.669296 3.857425 4.055199 4.263114 4.481689 4.711470 4.953032 5.206979 5.473947 5.754602 6.049647 6.359819 6.685894 7.028687 7.389056 7.767901 8.166169 8.584858 9.025013 9.487735 9.974182 10.48556 11.02317 11.58834 12.18249 ]
|
||||
#define Exposure_Speed 1.0 //[0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 4.0 5.0]
|
||||
#define CLOUDS_SHADOWS
|
||||
#define BASE_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0] Base fog amount amount (does not change the "cloudy" fog)
|
||||
#define CLOUDY_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
|
||||
#define FOG_TOD_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of time of day on fog amount
|
||||
#define FOG_RAIN_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of rain on fog amount
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
flat varying vec3 ambientUp;
|
||||
flat varying vec3 ambientLeft;
|
||||
flat varying vec3 ambientRight;
|
||||
@ -47,9 +41,11 @@ vec3 sunVec = vec3(0.0,1.0,0.0);
|
||||
|
||||
|
||||
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/ROBOBO_sky.glsl"
|
||||
|
||||
|
||||
vec3 rodSample(vec2 Xi)
|
||||
{
|
||||
float r = sqrt(1.0f - Xi.x*Xi.y);
|
||||
@ -100,107 +96,101 @@ void main() {
|
||||
gl_Position.xy = gl_Position.xy*vec2(18.+258*2,258.)*texelSize;
|
||||
gl_Position.xy = gl_Position.xy*2.-1.0;
|
||||
|
||||
tempOffsets = R2_samples(frameCounter%10000);
|
||||
// tempOffsets = R2_samples(frameCounter%10000);
|
||||
|
||||
ambientUp = vec3(0.0);
|
||||
ambientDown = vec3(0.0);
|
||||
ambientLeft = vec3(0.0);
|
||||
ambientRight = vec3(0.0);
|
||||
ambientB = vec3(0.0);
|
||||
ambientF = vec3(0.0);
|
||||
avgSky = vec3(0.0);
|
||||
// ambientUp = vec3(0.0);
|
||||
// ambientDown = vec3(0.0);
|
||||
// ambientLeft = vec3(0.0);
|
||||
// ambientRight = vec3(0.0);
|
||||
// ambientB = vec3(0.0);
|
||||
// ambientF = vec3(0.0);
|
||||
// avgSky = vec3(0.0);
|
||||
|
||||
|
||||
|
||||
//Fake bounced sunlight
|
||||
vec3 bouncedSun = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)/4000.*0.08;
|
||||
ambientUp += bouncedSun*clamp(-sunVec.y+5.,0.,6.0);
|
||||
ambientLeft += bouncedSun*clamp(sunVec.x+5.,0.0,6.);
|
||||
ambientRight += bouncedSun*clamp(-sunVec.x+5.,0.0,6.);
|
||||
ambientB += bouncedSun*clamp(-sunVec.z+5.,0.0,6.);
|
||||
ambientF += bouncedSun*clamp(sunVec.z+5.,0.0,6.);
|
||||
ambientDown += bouncedSun*clamp(sunVec.y+5.,0.0,6.);
|
||||
// //Fake bounced sunlight
|
||||
// vec3 bouncedSun = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)/4000.*0.08;
|
||||
// ambientUp += bouncedSun*clamp(-sunVec.y+5.,0.,6.0);
|
||||
// ambientLeft += bouncedSun*clamp(sunVec.x+5.,0.0,6.);
|
||||
// ambientRight += bouncedSun*clamp(-sunVec.x+5.,0.0,6.);
|
||||
// ambientB += bouncedSun*clamp(-sunVec.z+5.,0.0,6.);
|
||||
// ambientF += bouncedSun*clamp(sunVec.z+5.,0.0,6.);
|
||||
// ambientDown += bouncedSun*clamp(sunVec.y+5.,0.0,6.);
|
||||
|
||||
|
||||
float avgLuma = 0.0;
|
||||
float m2 = 0.0;
|
||||
int n=100;
|
||||
vec2 clampedRes = max(1.0/texelSize,vec2(1920.0,1080.));
|
||||
float avgExp = 0.0;
|
||||
vec2 resScale = vec2(1920.,1080.)/clampedRes;
|
||||
float v[25];
|
||||
float temp;
|
||||
// 5x5 Median filter by morgan mcguire
|
||||
// We take the median value of the most blurred bloom buffer
|
||||
#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);
|
||||
#define t2(a, b) s2(v[a], v[b]);
|
||||
#define t24(a, b, c, d, e, f, g, h) t2(a, b); t2(c, d); t2(e, f); t2(g, h);
|
||||
#define t25(a, b, c, d, e, f, g, h, i, j) t24(a, b, c, d, e, f, g, h); t2(i, j);
|
||||
for (int i = 0; i < 5; i++){
|
||||
for (int j = 0; j < 5; j++){
|
||||
vec2 tc = 0.5 + vec2(i-2,j-2)/2.0 * 0.35;
|
||||
v[i+j*5] = luma(texture2D(colortex6,tc/128. * resScale+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb);
|
||||
}
|
||||
}
|
||||
t25(0, 1, 3, 4, 2, 4, 2, 3, 6, 7);
|
||||
t25(5, 7, 5, 6, 9, 7, 1, 7, 1, 4);
|
||||
t25(12, 13, 11, 13, 11, 12, 15, 16, 14, 16);
|
||||
t25(14, 15, 18, 19, 17, 19, 17, 18, 21, 22);
|
||||
t25(20, 22, 20, 21, 23, 24, 2, 5, 3, 6);
|
||||
t25(0, 6, 0, 3, 4, 7, 1, 7, 1, 4);
|
||||
t25(11, 14, 8, 14, 8, 11, 12, 15, 9, 15);
|
||||
t25(9, 12, 13, 16, 10, 16, 10, 13, 20, 23);
|
||||
t25(17, 23, 17, 20, 21, 24, 18, 24, 18, 21);
|
||||
t25(19, 22, 8, 17, 9, 18, 0, 18, 0, 9);
|
||||
t25(10, 19, 1, 19, 1, 10, 11, 20, 2, 20);
|
||||
t25(2, 11, 12, 21, 3, 21, 3, 12, 13, 22);
|
||||
t25(4, 22, 4, 13, 14, 23, 5, 23, 5, 14);
|
||||
t25(15, 24, 6, 24, 6, 15, 7, 16, 7, 19);
|
||||
t25(3, 11, 5, 17, 11, 17, 9, 17, 4, 10);
|
||||
t25(6, 12, 7, 14, 4, 6, 4, 7, 12, 14);
|
||||
t25(10, 14, 6, 7, 10, 12, 6, 10, 6, 17);
|
||||
t25(12, 17, 7, 17, 7, 10, 12, 18, 7, 12);
|
||||
t24(10, 18, 12, 20, 10, 20, 10, 12);
|
||||
avgExp = v[12]; // Median value
|
||||
// float avgLuma = 0.0;
|
||||
// float m2 = 0.0;
|
||||
// int n=100;
|
||||
// vec2 clampedRes = max(1.0/texelSize,vec2(1920.0,1080.));
|
||||
// float avgExp = 0.0;
|
||||
// vec2 resScale = vec2(1920.,1080.)/clampedRes;
|
||||
// float v[25];
|
||||
// float temp;
|
||||
// // 5x5 Median filter by morgan mcguire
|
||||
// // We take the median value of the most blurred bloom buffer
|
||||
// #define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);
|
||||
// #define t2(a, b) s2(v[a], v[b]);
|
||||
// #define t24(a, b, c, d, e, f, g, h) t2(a, b); t2(c, d); t2(e, f); t2(g, h);
|
||||
// #define t25(a, b, c, d, e, f, g, h, i, j) t24(a, b, c, d, e, f, g, h); t2(i, j);
|
||||
// for (int i = 0; i < 5; i++){
|
||||
// for (int j = 0; j < 5; j++){
|
||||
// vec2 tc = 0.5 + vec2(i-2,j-2)/2.0 * 0.35;
|
||||
// v[i+j*5] = luma(texture2D(colortex6,tc/128. * resScale+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb);
|
||||
// }
|
||||
// }
|
||||
// t25(0, 1, 3, 4, 2, 4, 2, 3, 6, 7);
|
||||
// t25(5, 7, 5, 6, 9, 7, 1, 7, 1, 4);
|
||||
// t25(12, 13, 11, 13, 11, 12, 15, 16, 14, 16);
|
||||
// t25(14, 15, 18, 19, 17, 19, 17, 18, 21, 22);
|
||||
// t25(20, 22, 20, 21, 23, 24, 2, 5, 3, 6);
|
||||
// t25(0, 6, 0, 3, 4, 7, 1, 7, 1, 4);
|
||||
// t25(11, 14, 8, 14, 8, 11, 12, 15, 9, 15);
|
||||
// t25(9, 12, 13, 16, 10, 16, 10, 13, 20, 23);
|
||||
// t25(17, 23, 17, 20, 21, 24, 18, 24, 18, 21);
|
||||
// t25(19, 22, 8, 17, 9, 18, 0, 18, 0, 9);
|
||||
// t25(10, 19, 1, 19, 1, 10, 11, 20, 2, 20);
|
||||
// t25(2, 11, 12, 21, 3, 21, 3, 12, 13, 22);
|
||||
// t25(4, 22, 4, 13, 14, 23, 5, 23, 5, 14);
|
||||
// t25(15, 24, 6, 24, 6, 15, 7, 16, 7, 19);
|
||||
// t25(3, 11, 5, 17, 11, 17, 9, 17, 4, 10);
|
||||
// t25(6, 12, 7, 14, 4, 6, 4, 7, 12, 14);
|
||||
// t25(10, 14, 6, 7, 10, 12, 6, 10, 6, 17);
|
||||
// t25(12, 17, 7, 17, 7, 10, 12, 18, 7, 12);
|
||||
// t24(10, 18, 12, 20, 10, 20, 10, 12);
|
||||
// avgExp = v[12]; // Median value
|
||||
|
||||
|
||||
avgBrightness = clamp(mix(avgExp,texelFetch2D(colortex4,ivec2(10,37),0).g,0.95),0.00003051757,65000.0);
|
||||
// avgBrightness = clamp(mix(avgExp,texelFetch2D(colortex4,ivec2(10,37),0).g,0.95),0.00003051757,65000.0);
|
||||
|
||||
float currentExposure = texelFetch2D(colortex4,ivec2(10,37),0).b;
|
||||
float L = max(avgBrightness,1e-8);
|
||||
float keyVal = 1.03-2.0/(log(L+1.0)/log(10.0)+2.0);
|
||||
float targetExposure = 1.0*keyVal/L;
|
||||
// float currentExposure = texelFetch2D(colortex4,ivec2(10,37),0).b;
|
||||
// float L = max(avgBrightness,1e-8);
|
||||
// float keyVal = 1.03-2.0/(log(L+1.0)/log(10.0)+2.0);
|
||||
// float targetExposure = 1.0*keyVal/L;
|
||||
|
||||
float targetrodExposure = clamp(log(targetExposure*2.0+1.0)-0.1,0.0,2.0);
|
||||
float currentrodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r;
|
||||
// float targetrodExposure = clamp(log(targetExposure*2.0+1.0)-0.1,0.0,2.0);
|
||||
// float currentrodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r;
|
||||
|
||||
targetExposure = clamp(targetExposure,2.0,3.0);
|
||||
float rad = sqrt(currentExposure);
|
||||
float rtarget = sqrt(targetExposure);
|
||||
float dir = sign(rtarget-rad);
|
||||
float dist = abs(rtarget-rad);
|
||||
float maxApertureChange = 0.0032*frameTime/0.016666*(Exposure_Speed*2) * exp2(max(rad,rtarget)*0.5);
|
||||
// targetExposure = clamp(targetExposure,2.0,3.0);
|
||||
// float rad = sqrt(currentExposure);
|
||||
// float rtarget = sqrt(targetExposure);
|
||||
// float dir = sign(rtarget-rad);
|
||||
// float dist = abs(rtarget-rad);
|
||||
// float maxApertureChange = 0.0032*frameTime/0.016666*Exposure_Speed * exp2(max(rad,rtarget)*0.5);
|
||||
|
||||
maxApertureChange *= 1.0+nightVision*4.;
|
||||
rad = rad+dir*min(dist,maxApertureChange);
|
||||
// maxApertureChange *= 1.0+nightVision*4.;
|
||||
// rad = rad+dir*min(dist,maxApertureChange);
|
||||
|
||||
exposureF = rad*rad;
|
||||
exposure=exposureF*EXPOSURE_MULTIPLIER;
|
||||
// exposureF = rad*rad;
|
||||
// exposure=exposureF*EXPOSURE_MULTIPLIER;
|
||||
|
||||
|
||||
dir = sign(targetrodExposure-currentrodExposure);
|
||||
dist = abs(targetrodExposure-currentrodExposure);
|
||||
maxApertureChange = 0.0032*frameTime/0.016666*(Exposure_Speed*2) * exp2(max(rad,rtarget)*0.5);
|
||||
// dir = sign(targetrodExposure-currentrodExposure);
|
||||
// dist = abs(targetrodExposure-currentrodExposure);
|
||||
// maxApertureChange = 0.0032*frameTime/0.016666*Exposure_Speed * exp2(max(rad,rtarget)*0.5);
|
||||
|
||||
rodExposure = currentrodExposure + dir * min(dist,maxApertureChange);
|
||||
// rodExposure = currentrodExposure + dir * min(dist,maxApertureChange);
|
||||
|
||||
#ifndef AUTO_EXPOSURE
|
||||
exposure = Manual_exposure_value;
|
||||
rodExposure = clamp(log(Manual_exposure_value*2.0+1.0)-0.1,0.0,2.0);
|
||||
#endif
|
||||
float modWT = (worldTime%24000)*1.0;
|
||||
exposure = 1.0;
|
||||
rodExposure = clamp(log(1.0*2.0+1.0)-0.1,0.0,2.0);
|
||||
|
||||
float fogAmount0 = 1/3000.+FOG_TOD_MULTIPLIER*(1/180.*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.))*(clamp(modWT-11000.,0.,2000.0)/2000.+(1.0-clamp(modWT,0.,3000.0)/3000.)) + 1/200.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.));
|
||||
VFAmount = CLOUDY_FOG_AMOUNT*(fogAmount0*fogAmount0+FOG_RAIN_MULTIPLIER*1.8/20000.*rainStrength);
|
||||
fogAmount = BASE_FOG_AMOUNT*(fogAmount0+max(FOG_RAIN_MULTIPLIER*1/15.*rainStrength , FOG_TOD_MULTIPLIER*1/50.*clamp(modWT-13000.,0.,1000.0)/1000.*(1.0-clamp(modWT-23000.,0.,1000.0)/1000.)));
|
||||
}
|
||||
|
30
shaders/world-1/deferred2.fsh
Normal file
30
shaders/world-1/deferred2.fsh
Normal file
@ -0,0 +1,30 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
uniform float near;
|
||||
uniform float far;
|
||||
|
||||
|
||||
float linZ(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:4 */
|
||||
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)
|
||||
gl_FragData[0] = vec4(oldTex, linZ(newTex)*linZ(newTex)*65000.0);
|
||||
else
|
||||
gl_FragData[0] = vec4(oldTex, 2.0);
|
||||
}
|
11
shaders/world-1/deferred2.vsh
Normal file
11
shaders/world-1/deferred2.vsh
Normal file
@ -0,0 +1,11 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
uniform vec2 texelSize;
|
||||
#include "/lib/res_params.glsl"
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
vec2 scaleRatio = max(vec2(0.25), vec2(18.+258*2,258.)*texelSize);
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(scaleRatio+0.01,0.0,1.0)*2.0-1.0;
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
#version 120
|
||||
//Vignetting, applies bloom, applies exposure and tonemaps the final image
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
//#define BICUBIC_UPSCALING //Provides a better interpolation when using a render quality different of 1.0, slower
|
||||
#define CONTRAST_ADAPTATIVE_SHARPENING
|
||||
#define SHARPENING 0.35 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define SATURATION 0.00 // Negative values desaturates colors, Positive values saturates color, 0 is no change [-1.0 -0.98 -0.96 -0.94 -0.92 -0.9 -0.88 -0.86 -0.84 -0.82 -0.8 -0.78 -0.76 -0.74 -0.72 -0.7 -0.68 -0.66 -0.64 -0.62 -0.6 -0.58 -0.56 -0.54 -0.52 -0.5 -0.48 -0.46 -0.44 -0.42 -0.4 -0.38 -0.36 -0.34 -0.32 -0.3 -0.28 -0.26 -0.24 -0.22 -0.2 -0.18 -0.16 -0.14 -0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 ]
|
||||
#define CROSSTALK 0.0 // Desaturates bright colors and preserves saturation in darker areas (inverted if negative). Helps avoiding almsost fluorescent colors [-1.0 -0.98 -0.96 -0.94 -0.92 -0.9 -0.88 -0.86 -0.84 -0.82 -0.8 -0.78 -0.76 -0.74 -0.72 -0.7 -0.68 -0.66 -0.64 -0.62 -0.6 -0.58 -0.56 -0.54 -0.52 -0.5 -0.48 -0.46 -0.44 -0.42 -0.4 -0.38 -0.36 -0.34 -0.32 -0.3 -0.28 -0.26 -0.24 -0.22 -0.2 -0.18 -0.16 -0.14 -0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 ]
|
||||
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform sampler2D colortex7;
|
||||
@ -15,9 +14,11 @@ uniform float viewHeight;
|
||||
uniform float frameTimeCounter;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/color_dither.glsl"
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
|
@ -1,9 +1,7 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
#define FinalR 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#define FinalG 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#define FinalB 1.0 //[0.0 0.025315 0.051271 0.077884 0.105170 0.133148 0.161834 0.191246 0.221402 0.252322 0.284025 0.316530 0.349858 0.384030 0.419067 0.454991 0.491824 0.529590 0.568312 0.608014 0.648721 0.690458 0.733253 0.777130 0.822118 0.868245 0.915540 0.964032 1.013752 1.064731 1.117000 1.170592 1.225540 1.281880 1.339646 1.398875 1.459603 1.521868 1.585709 1.651167 1.718281 1.787095 1.857651 1.929992 2.004166 2.080216 2.158192 2.238142 2.320116 2.404166 2.490342 2.578701 2.669296 2.762185 2.857425 2.955076 3.055199 3.157857 3.263114 3.371035 3.481689 3.595143 3.711470 3.830741 3.953032 4.078419 4.206979 4.338795 4.473947 4.612521 4.754602 4.900281 5.049647 5.202795 5.359819 5.520819 5.685894 5.855148 6.028687 6.206619 6.389056 6.576110 6.767901 6.964546 7.166169 7.372897 7.584858 7.802185 8.025013 8.253482 8.487735 8.727919 8.974182 9.226680 9.485569 9.751013 10.02317 10.30222 10.58834 10.88170 11.18249 ]
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec4 exposure;
|
||||
|
@ -1,213 +0,0 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#include "/lib/res_params.glsl"
|
||||
#define WAVY_PLANTS
|
||||
#define WAVY_STRENGTH 1.0 //[0.1 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0]
|
||||
#define WAVY_SPEED 1.0 //[0.001 0.01 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.0 1.25 1.5 2.0 3.0 4.0]
|
||||
#define SEPARATE_AO
|
||||
//#define POM
|
||||
//#define USE_LUMINANCE_AS_HEIGHTMAP //Can generate POM on any texturepack (may look weird in some cases)
|
||||
// #define RTAO // I recommend turning ambientOcclusionLevel to zero with this on. like ssao, but rt, nicer, noiser, and slower. SSAO will turn OFF when this is ON
|
||||
#define indirect_effect 1 // Choose what effect is applied to indirect light. [0 1 2 3]
|
||||
|
||||
#define Variable_Penumbra_Shadows //Makes the shadows more blurry the more distant they are to objects (costs fps)
|
||||
#define mob_SSS
|
||||
|
||||
#ifndef USE_LUMINANCE_AS_HEIGHTMAP
|
||||
#ifndef MC_NORMAL_MAP
|
||||
#undef POM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef POM
|
||||
#define MC_NORMAL_MAP
|
||||
#endif
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
#ifdef POM
|
||||
varying vec4 vtexcoordam; // .st for add, .pq for mul
|
||||
varying vec4 vtexcoord;
|
||||
#endif
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
out vec3 test_motionVectors;
|
||||
in vec3 at_velocity;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
const float PI48 = 150.796447372*WAVY_SPEED;
|
||||
float pi2wt = PI48*frameTimeCounter;
|
||||
attribute vec4 mc_Entity;
|
||||
uniform int blockEntityId;
|
||||
uniform int entityId;
|
||||
varying vec4 materialMask;
|
||||
flat varying vec4 TESTMASK;
|
||||
flat varying int lightningBolt;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
uniform vec3 cameraPosition;
|
||||
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.);
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
vec2 calcWave(in vec3 pos) {
|
||||
|
||||
float magnitude = abs(sin(dot(vec4(frameTimeCounter, pos),vec4(1.0,0.005,0.005,0.005)))*0.5+0.72)*0.013;
|
||||
vec2 ret = (sin(pi2wt*vec2(0.0063,0.0015)*4. - pos.xz + pos.y*0.05)+0.1)*magnitude;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
vec3 calcMovePlants(in vec3 pos) {
|
||||
vec2 move1 = calcWave(pos );
|
||||
float move1y = -length(move1);
|
||||
return vec3(move1.x,move1y,move1.y)*5.*WAVY_STRENGTH;
|
||||
}
|
||||
|
||||
vec3 calcWaveLeaves(in vec3 pos, in float fm, in float mm, in float ma, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5) {
|
||||
|
||||
float magnitude = abs(sin(dot(vec4(frameTimeCounter, pos),vec4(1.0,0.005,0.005,0.005)))*0.5+0.72)*0.013;
|
||||
vec3 ret = (sin(pi2wt*vec3(0.0063,0.0224,0.0015)*1.5 - pos))*magnitude;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
vec3 calcMoveLeaves(in vec3 pos, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5, in vec3 amp1, in vec3 amp2) {
|
||||
vec3 move1 = calcWaveLeaves(pos , 0.0054, 0.0400, 0.0400, 0.0127, 0.0089, 0.0114, 0.0063, 0.0224, 0.0015) * amp1;
|
||||
return move1*5.*WAVY_STRENGTH;
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
|
||||
TESTMASK = vec4(normalize(gl_NormalMatrix * gl_Normal), 1.0);
|
||||
|
||||
TESTMASK.r = blockEntityId == 222 ? 255 : TESTMASK.r;
|
||||
|
||||
|
||||
#ifdef ENTITIES
|
||||
test_motionVectors = at_velocity;
|
||||
#endif
|
||||
|
||||
#ifdef POM
|
||||
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texcoordminusmid = lmtexcoord.xy-midcoord;
|
||||
vtexcoordam.pq = abs(texcoordminusmid)*2;
|
||||
vtexcoordam.st = min(lmtexcoord.xy,midcoord-texcoordminusmid);
|
||||
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
|
||||
#endif
|
||||
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord;
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
color = gl_Color;
|
||||
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0);
|
||||
|
||||
#ifdef ENTITIES
|
||||
|
||||
#ifdef mob_SSS
|
||||
#ifdef Variable_Penumbra_Shadows
|
||||
normalMat.a = entityId == 1100 ? 1.0 : normalMat.a;
|
||||
normalMat.a = entityId == 1200 ? 1.0 : normalMat.a;
|
||||
normalMat.a = entityId == 1400 ? 1.0 : normalMat.a;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef WORLD
|
||||
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),mc_Entity.x == 10004 || mc_Entity.x == 10003 ? 0.5 : mc_Entity.x == 10001 ? 0.6 : 1.0);
|
||||
normalMat.a = (mc_Entity.x == 10006 || mc_Entity == 100061) ? 0.6 : normalMat.a;
|
||||
normalMat.a = (mc_Entity.x == 10007 || mc_Entity.x == 10008) ? 0.55 : normalMat.a;
|
||||
|
||||
normalMat.a = mc_Entity.x == 10005 ? 0.8 : normalMat.a;
|
||||
normalMat.a = mc_Entity.x == 99 ? 0.65 : normalMat.a;
|
||||
|
||||
|
||||
#ifdef WAVY_PLANTS
|
||||
if ((mc_Entity.x == 10001 && istopv) && abs(position.z) < 64.0) {
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
worldpos.xyz += calcMovePlants(worldpos.xyz)*lmtexcoord.w - cameraPosition;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
}
|
||||
|
||||
if (mc_Entity.x == 10003 && abs(position.z) < 64.0) {
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
worldpos.xyz += calcMoveLeaves(worldpos.xyz, 0.0040, 0.0064, 0.0043, 0.0035, 0.0037, 0.0041, vec3(1.0,0.2,1.0), vec3(0.5,0.1,0.5))*lmtexcoord.w - cameraPosition;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mc_Entity.x == 100 ){
|
||||
color.rgb = normalize(color.rgb)*sqrt(3.0);
|
||||
normalMat.a = 0.9;
|
||||
}
|
||||
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
if (color.a < 0.3) color.a = 1.0;
|
||||
|
||||
|
||||
#ifdef SEPARATE_AO
|
||||
|
||||
#if indirect_effect == 1 || indirect_effect == 0
|
||||
lmtexcoord.zw *= sqrt(color.a);
|
||||
#endif
|
||||
|
||||
#else
|
||||
color.rgb *= color.a;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#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
|
||||
}
|
@ -1,624 +0,0 @@
|
||||
// #version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
uniform sampler2D normals;
|
||||
varying vec3 tangent;
|
||||
varying vec4 tangent_other;
|
||||
varying vec3 viewVector;
|
||||
varying float dist;
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
#define CLOUDS_SHADOWS
|
||||
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL (slow)
|
||||
#define SCREENSPACE_REFLECTIONS //can be really expensive at high resolutions/render quality, especially on ice
|
||||
#define SSR_STEPS 30 //[10 15 20 25 30 35 40 50 100 200 400]
|
||||
#define SUN_MICROFACET_SPECULAR // If enabled will use realistic rough microfacet model, else will just reflect the sun. No performance impact.
|
||||
#define USE_QUARTER_RES_DEPTH // Uses a quarter resolution depth buffer to raymarch screen space reflections, improves performance but may introduce artifacts
|
||||
#define saturate(x) clamp(x,0.0,1.0)
|
||||
#define Dirt_Amount 0.14 //How much dirt there is in water [0.0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1.0 1.04 1.08 1.12 1.16 1.2 1.24 1.28 1.32 1.36 1.4 1.44 1.48 1.52 1.56 1.6 1.64 1.68 1.72 1.76 1.8 1.84 1.88 1.92 1.96 2.0 ]
|
||||
|
||||
#define Dirt_Scatter_R 0.6 //How much dirt diffuses red [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define Dirt_Scatter_G 0.6 //How much dirt diffuses green [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define Dirt_Scatter_B 0.6 //How much dirt diffuses blue [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
|
||||
#define Dirt_Absorb_R 1.65 //How much dirt absorbs red [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
#define Dirt_Absorb_G 1.85 //How much dirt absorbs green [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
#define Dirt_Absorb_B 2.05 //How much dirt absorbs blue [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
|
||||
#define Water_Absorb_R 0.2629 //How much water absorbs red [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
#define Water_Absorb_G 0.0565 //How much water absorbs green [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
#define Water_Absorb_B 0.01011 //How much water absorbs blue [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
#define Texture_MipMap_Bias -1.00 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
|
||||
|
||||
#define ambient_colortype 0 // Toggle which method you want to change the color of ambient light with. [0 1]
|
||||
#define ambient_temp 9000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 15000 50000]
|
||||
|
||||
#define AmbientLight_R 0.91 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define AmbientLight_G 0.86 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define AmbientLight_B 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
|
||||
|
||||
#define MIN_LIGHT_AMOUNT 1.0 //[0.0 0.5 1.0 1.5 2.0 3.0 4.0 5.0]
|
||||
//#define Vanilla_like_water // vanilla water texture along with shader water stuff
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2DShadow shadow;
|
||||
uniform sampler2D gaux2;
|
||||
uniform sampler2D gaux1;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
uniform vec4 lightCol;
|
||||
uniform float nightVision;
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float lightSign;
|
||||
uniform float near;
|
||||
uniform float far;
|
||||
uniform float moonIntensity;
|
||||
uniform float sunIntensity;
|
||||
uniform vec3 sunColor;
|
||||
uniform vec3 nsunColor;
|
||||
uniform vec3 upVec;
|
||||
uniform float sunElevation;
|
||||
uniform float fogAmount;
|
||||
uniform vec2 texelSize;
|
||||
uniform float rainStrength;
|
||||
uniform float skyIntensityNight;
|
||||
uniform float skyIntensity;
|
||||
flat varying vec3 WsunVec;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform int framemod8;
|
||||
uniform sampler2D specular;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "lib/Shadow_Params.glsl"
|
||||
#include "lib/color_transforms.glsl"
|
||||
#include "lib/projections.glsl"
|
||||
#include "lib/sky_gradient.glsl"
|
||||
#include "lib/waterBump.glsl"
|
||||
#include "lib/clouds.glsl"
|
||||
#include "lib/stars.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
|
||||
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.);
|
||||
float interleaved_gradientNoise(float temporal){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal);
|
||||
return noise;
|
||||
}
|
||||
vec3 srgbToLinear2(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
}
|
||||
vec3 blackbody2(float Temp)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp(col,0.0,1.0);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
|
||||
return srgbToLinear2(col);
|
||||
}
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float invLinZ (float lindepth){
|
||||
return -((2.0*near/lindepth)-far-near)/(far-near);
|
||||
}
|
||||
float ld(float dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
vec3 nvec3(vec4 pos){
|
||||
return pos.xyz/pos.w;
|
||||
}
|
||||
|
||||
vec4 nvec4(vec3 pos){
|
||||
return vec4(pos.xyz, 1.0);
|
||||
}
|
||||
vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){
|
||||
|
||||
float quality = mix(15,SSR_STEPS,fresnel);
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
(-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(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*dither;
|
||||
float minZ = clipPosition.z;
|
||||
float maxZ = spos.z+stepv.z*0.5;
|
||||
|
||||
spos.xy += offsets[framemod8]*texelSize*0.5/RENDER_SCALE;
|
||||
|
||||
for (int i = 0; i <= int(quality); i++) {
|
||||
#ifdef USE_QUARTER_RES_DEPTH
|
||||
// decode depth buffer
|
||||
float sp = sqrt(texelFetch2D(gaux1,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
sp = invLinZ(sp);
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)){
|
||||
return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
}
|
||||
spos += stepv;
|
||||
#else
|
||||
float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r;
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)){
|
||||
return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
}
|
||||
spos += stepv;
|
||||
#endif
|
||||
//small bias
|
||||
minZ = maxZ-0.00004/ld(spos.z);
|
||||
if(inwater) minZ = maxZ-0.0004/ld(spos.z);
|
||||
maxZ += stepv.z;
|
||||
}
|
||||
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
|
||||
float facos(float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
return sx > 0. ? a : pi - a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float bayer2(vec2 a){
|
||||
a = floor(a);
|
||||
return fract(dot(a,vec2(0.5,a.y*0.75)));
|
||||
}
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
|
||||
#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 1 //[2 4 6 8 16 32]
|
||||
#define bayer4(a) (bayer2( .5*(a))*.25+bayer2(a))
|
||||
#define bayer8(a) (bayer4( .5*(a))*.25+bayer2(a))
|
||||
#define bayer16(a) (bayer8( .5*(a))*.25+bayer2(a))
|
||||
#define bayer32(a) (bayer16(.5*(a))*.25+bayer2(a))
|
||||
#define bayer64(a) (bayer32(.5*(a))*.25+bayer2(a))
|
||||
#define bayer128(a) fract(bayer64(.5*(a))*.25+bayer2(a))
|
||||
vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) {
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
vec3 parallaxPos = posxz;
|
||||
vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH;
|
||||
float waterHeight = getWaterHeightmap(posxz.xz, waveM, waveZ, iswater) ;
|
||||
|
||||
parallaxPos.xz += waterHeight * vec;
|
||||
|
||||
return parallaxPos;
|
||||
|
||||
}
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
float alpha = (sampleNumber+jitter)/nb;
|
||||
float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
|
||||
float sin_v, cos_v;
|
||||
|
||||
sin_v = sin(angle);
|
||||
cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
//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);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
vec4 hash44(vec4 p4)
|
||||
{
|
||||
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
|
||||
p4 += dot(p4, p4.wzxy+33.33);
|
||||
return fract((p4.xxyz+p4.yzzw)*p4.zywx);
|
||||
}
|
||||
vec3 TangentToWorld(vec3 N, vec3 H)
|
||||
{
|
||||
vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 T = normalize(cross(UpVector, N));
|
||||
vec3 B = cross(N, T);
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
}
|
||||
float GGX (vec3 n, vec3 v, vec3 l, float r, float F0) {
|
||||
r*=r;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);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
|
||||
float k2 = .25 * r;
|
||||
|
||||
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
|
||||
}
|
||||
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump){
|
||||
float bumpmult = 1.0;
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
dither = center*inversesqrt(abs(center));
|
||||
return clamp(dither-fsign(center),0.0,1.0);
|
||||
}
|
||||
vec3 fp10Dither(vec3 color,float dither){
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
}
|
||||
//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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
float g(float NdotL, float roughness){
|
||||
float alpha = square(max(roughness, 0.02));
|
||||
return 2.0 * NdotL / (NdotL + sqrt(square(alpha) + (1.0 - square(alpha)) * square(NdotL)));
|
||||
}
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
|
||||
vec3 GGX2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
float roughness = r + 1.0/255.0; // when roughness is zero it fucks up
|
||||
|
||||
float alpha = square(roughness);
|
||||
|
||||
|
||||
vec3 h = normalize(l + v);
|
||||
|
||||
float dotLH = clamp(dot(h,l),0.,1.);
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNV = clamp(dot(n,v),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
|
||||
float D = alpha / (3.141592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
/* RENDERTARGETS:2,7,1,11 */
|
||||
void main() {
|
||||
if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize.y < RENDER_SCALE.y ) {
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
float iswater = normalMat.w;
|
||||
vec3 fragC = gl_FragCoord.xyz*vec3(texelSize,1.0);
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color;
|
||||
float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
|
||||
gl_FragData[0].rgb = clamp((gl_FragData[0].rgb)*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
|
||||
|
||||
vec3 albedo = toLinear(gl_FragData[0].rgb);
|
||||
|
||||
#ifndef Vanilla_like_water
|
||||
if (iswater > 0.4) {
|
||||
albedo = vec3(0.42,0.6,0.7);
|
||||
gl_FragData[0] = vec4(0.42,0.6,0.7,0.7);
|
||||
}
|
||||
if (iswater > 0.9) {
|
||||
gl_FragData[0] = vec4(0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Vanilla_like_water
|
||||
if (iswater > 0.5) {
|
||||
gl_FragData[0].a = luma(albedo.rgb);
|
||||
albedo = color.rgb;
|
||||
}
|
||||
#endif
|
||||
vec2 specularstuff = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
if (iswater > 0.4){
|
||||
float bumpmult = 1.;
|
||||
if (iswater > 0.9)
|
||||
bumpmult = 1.;
|
||||
float parallaxMult = bumpmult;
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
posxz.xz-=posxz.y;
|
||||
if (iswater < 0.9)
|
||||
posxz.xz *= 3.0;
|
||||
vec3 bump;
|
||||
|
||||
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos));
|
||||
|
||||
bump = normalize(getWaveHeight(posxz.xz,iswater));
|
||||
|
||||
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
|
||||
normal = normalize(bump * tbnMatrix);
|
||||
}else {
|
||||
vec3 normalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgb;
|
||||
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0);
|
||||
normal = applyBump(tbnMatrix,normalTex);
|
||||
}
|
||||
vec4 data0 = vec4(1);
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), lmtexcoord.zw),0.0,1.0);
|
||||
gl_FragData[3] = vec4(encodeVec2(data0.x,data1.x), encodeVec2(data0.y,data1.y), encodeVec2(data0.z,data1.z), encodeVec2(data1.w,data0.w));
|
||||
// gl_FragData[3].a = 0.0;
|
||||
|
||||
|
||||
float NdotL = lightSign*dot(normal,sunVec);
|
||||
float NdotU = dot(upVec,normal);
|
||||
float diffuseSun = clamp(NdotL,0.0f,1.0f);
|
||||
|
||||
vec3 direct = texelFetch2D(gaux1,ivec2(6,37),0).rgb/3.1415;
|
||||
|
||||
float shading = 1.0;
|
||||
float cloudShadow = 1.0;
|
||||
//compute shadows only if not backface
|
||||
if (diffuseSun > 0.001) {
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
//apply distortion
|
||||
float distortFactor = calcDistort(projectedShadowPosition.xy);
|
||||
projectedShadowPosition.xy *= distortFactor;
|
||||
//do shadows only if on shadow map
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
|
||||
float distortThresh = (sqrt(1.0-diffuseSun*diffuseSun)/diffuseSun+0.7)/distortFactor;
|
||||
float diffthresh = distortThresh/6000.0*threshMul;
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
|
||||
|
||||
shading = 0.0;
|
||||
float noise = blueNoise();
|
||||
float rdMul = 4.0/shadowMapResolution;
|
||||
for(int i = 0; i < 9; i++){
|
||||
vec2 offsetS = tapLocation(i,9, 1.618,noise,0.0);
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
shading += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0;
|
||||
}
|
||||
direct *= shading;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
vec3 campos = (p3 + cameraPosition)-319 ;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
// cloudShadow = exp(-cloudShadow*sqrt(cloudDensity)*25);
|
||||
|
||||
cloudShadow = clamp(exp(-cloudShadow*10),0,1);
|
||||
|
||||
// make these turn to zero when occluded by the cloud shadow
|
||||
direct *= cloudShadow;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if ambient_colortype == 0
|
||||
vec3 colortype = blackbody2(ambient_temp);
|
||||
#else
|
||||
vec3 colortype = vec3(AmbientLight_R,AmbientLight_G,AmbientLight_B) ;
|
||||
#endif
|
||||
|
||||
vec3 ambientLight = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * colortype;
|
||||
|
||||
direct *= (iswater > 0.9 ? 0.2: 1.0)*diffuseSun*lmtexcoord.w;
|
||||
|
||||
|
||||
vec3 diffuseLight = (direct*1.5) + (ambientLight*2.5);
|
||||
vec3 color = diffuseLight * albedo * 8./150./3.0 ;
|
||||
|
||||
|
||||
|
||||
if (iswater > 0.0){
|
||||
|
||||
float roughness = iswater > 0.4 ? 0.0 : specularstuff.r > 0.0 ? pow(1.0-specularstuff.r,2.0) : 0.05*(1.0-gl_FragData[0].a );
|
||||
float f0 = iswater > 0.4 ? 0.02 : specularstuff.g;
|
||||
if(f0 > 0.9) f0 = 0.02;
|
||||
float F0 = f0;
|
||||
|
||||
// float f0 = iswater > 0.1 ? 0.02 : 0.05*(1.0-gl_FragData[0].a);
|
||||
// float roughness = 0.02;
|
||||
// float F0 = f0;
|
||||
|
||||
vec3 reflectedVector = reflect(normalize(fragpos), normal);
|
||||
|
||||
|
||||
float normalDotEye = dot(normal, normalize(fragpos));
|
||||
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0);
|
||||
float fresnel2 = pow(clamp(1.0 + normalDotEye,0.0,1.0), 1.0);
|
||||
|
||||
// gl_FragData[3].a = fresnel2;
|
||||
|
||||
// snells window looking thing
|
||||
if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0);
|
||||
|
||||
fresnel = mix(F0,1.0,fresnel);
|
||||
|
||||
// adjust the amount of sunlight based on f0. max f0 should
|
||||
color = mix(color, (ambientLight*2.5) * albedo * 8./150./3.0 , mix(1.0-roughness, F0, 0.5));
|
||||
|
||||
vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector;
|
||||
vec3 sky_c = mix(skyCloudsFromTex(wrefl,gaux1).rgb,texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb*0.5,isEyeInWater);
|
||||
sky_c.rgb *= lmtexcoord.w*lmtexcoord.w*255*255/240./240./150.*8./3.;
|
||||
|
||||
vec4 reflection = vec4(sky_c.rgb,0.);
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, blueNoise(), fresnel, isEyeInWater == 0);
|
||||
if (rtPos.z <1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, 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) {
|
||||
reflection.a = 1.0;
|
||||
reflection.rgb = texture2D(gaux2,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if(isEyeInWater ==1 ) sky_c.rgb = color.rgb*lmtexcoord.y;
|
||||
|
||||
reflection.rgb = mix(sky_c.rgb, reflection.rgb, reflection.a);
|
||||
|
||||
#ifdef SUN_MICROFACET_SPECULAR
|
||||
vec3 sunSpec = GGX2(normal, -normalize(fragpos), lightSign*sunVec ,roughness, vec3(f0)) * direct;
|
||||
|
||||
// vec3 sunSpec = GGX(normal,-normalize(fragpos), lightSign*sunVec, rainStrength*0.2+roughness+0.05+clamp(-lightSign*0.15,0.0,1.0), f0) * texelFetch2D(gaux1,ivec2(6,37),0).rgb*8./3./150.0/3.1415 * (1.0-rainStrength*0.9);
|
||||
#else
|
||||
vec3 sunSpec = drawSun(dot(lightSign * sunVec,reflectedVector), 0.0,texelFetch2D(gaux1,ivec2(6,37),0).rgb,vec3(0.0))*8./3./150.0*fresnel/3.1415 * (1.0-rainStrength*0.9);
|
||||
#endif
|
||||
|
||||
|
||||
// vec3 albedoTint = F0 >= (230.0/255.0) ? clamp(color.rgb + fresnel,0.0,1.0) : vec3(1.0);
|
||||
// reflection.rgb *= albedoTint;
|
||||
// sunSpec.rgb *= albedoTint;
|
||||
sunSpec *= max(cloudShadow-0.5,0.0);
|
||||
|
||||
vec3 reflected = reflection.rgb*fresnel+shading*sunSpec;
|
||||
|
||||
float alpha0 = gl_FragData[0].a;
|
||||
|
||||
vec3 np3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
float borderfog = clamp( pow( length(fragpos)/far, 5), 0, 1);
|
||||
vec3 bordercolor = skyFromTex(np3,colortex4)/150.;
|
||||
vec3 finalborderfog = clamp(fp10Dither(bordercolor*8./3.,triangularize(R2_dither())),0.0,65000.);
|
||||
|
||||
// alpha0 = mix(0.0, alpha0, borderfog);
|
||||
|
||||
//correct alpha channel with fresnel
|
||||
gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel;
|
||||
|
||||
gl_FragData[0].rgb = clamp(color/gl_FragData[0].a*alpha0*(1.0-fresnel)*0.1+reflected/gl_FragData[0].a*0.1,0.0,65100.0);
|
||||
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
gl_FragData[0].rgb = color*.1;
|
||||
|
||||
gl_FragData[1] = vec4(albedo,iswater);
|
||||
|
||||
// vec3 np3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
// float borderfog = clamp( pow( length(fragpos)/far, 5), 0, 1);
|
||||
// vec3 bordercolor = skyFromTex(np3,colortex4)/150.;
|
||||
// vec3 finalborderfog = clamp(fp10Dither(bordercolor*8./3.,triangularize(R2_dither())),0.0,65000.);
|
||||
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ varying vec4 normalMat;
|
||||
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
uniform sampler2D gaux1;
|
||||
uniform vec4 lightCol;
|
||||
uniform vec3 sunVec;
|
||||
|
||||
@ -66,34 +66,15 @@ void main() {
|
||||
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy);
|
||||
|
||||
|
||||
vec3 albedo = toLinear(gl_FragData[0].rgb*color.rgb);
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize,1.0));
|
||||
float exposure = texelFetch2D(gaux1,ivec2(10,37),0).r;
|
||||
|
||||
|
||||
|
||||
float NdotL = lightCol.a*dot(normal,sunVec);
|
||||
|
||||
float diffuseSun = clamp(NdotL,0.0f,1.0f);
|
||||
|
||||
vec3 direct = lightCol.rgb;
|
||||
|
||||
|
||||
direct *= (diffuseSun*lmtexcoord.w)*10.;
|
||||
|
||||
float torch_lightmap = ((lmtexcoord.z*lmtexcoord.z)*(lmtexcoord.z*lmtexcoord.z))*(lmtexcoord.z*20.)+lmtexcoord.z;
|
||||
|
||||
vec3 ambient = (lightCol.a*sunElevation)*(-NdotL*0.45+0.9)*lightCol.rgb*0.6 + (1.2*skyIntensity)*vec3(0.65,0.7,1.)*30. + skyIntensityNight*vec3(0.09,0.1,0.15)/1.5;
|
||||
|
||||
vec3 diffuseLight = (lmtexcoord.w)*ambient + vec3(1.,0.4,0.1)*torch_lightmap*0.08*1.0 + 0.0006;
|
||||
|
||||
vec3 col = dot(diffuseLight,vec3(1.0/3))*albedo;
|
||||
vec3 col = albedo*exp(-exposure*3.);
|
||||
|
||||
|
||||
gl_FragData[0].rgb = col*color.a;
|
||||
gl_FragData[0].a = 0.0;
|
||||
gl_FragData[0].a = gl_FragData[0].a*0.1;
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#version 120
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
#define TAA
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
/*
|
||||
!! DO NOT REMOVE !!
|
||||
@ -26,6 +26,12 @@ uniform int framemod8;
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -38,8 +44,9 @@ void main() {
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
lmtexcoord.zw = lmcoord*lmcoord;
|
||||
|
||||
gl_Position = ftransform();
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
color = gl_Color;
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
@ -47,6 +54,9 @@ void main() {
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
|
||||
#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
|
||||
|
@ -1,4 +1,6 @@
|
||||
#version 120
|
||||
|
||||
// #define ENTITIES
|
||||
#define BLOCKENTITIES
|
||||
#define WORLD
|
||||
#include "gbuffers_all_solid.fsh"
|
||||
#include "/programs/all_solid.fsh"
|
@ -1,4 +1,7 @@
|
||||
#version 120
|
||||
|
||||
// #define ENTITIES
|
||||
// #define LINE
|
||||
#define BLOCKENTITIES
|
||||
#define WORLD
|
||||
#include "gbuffers_all_solid.vsh"
|
||||
#include "/programs/all_solid.vsh"
|
@ -1,5 +1,5 @@
|
||||
#version 120
|
||||
|
||||
#define BLOCK_ENT
|
||||
#define WORLD
|
||||
#include "gbuffers_all_solid.fsh"
|
||||
#define BLOCKENTITIES
|
||||
#include "/gbuffers_all_solid.fsh"
|
@ -1,5 +1,5 @@
|
||||
#version 120
|
||||
|
||||
#define BLOCK_ENT
|
||||
#define WORLD
|
||||
#include "gbuffers_all_solid.vsh"
|
||||
#define BLOCKENTITIES
|
||||
#include "/gbuffers_all_solid.vsh"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user