Add Photonics 0.3.1 support, add denoised rough reflections, add reflections of handheld colored lights, improve look of hardcoded SSS on snowy grass, fix multiple photonics issues, add more photonics settings, fix physics mod oceans not working with newest physics mod

This commit is contained in:
Merlin1809 committed 2026-03-22 21:13:52 +01:00
1 parent 0c26cb0274
commit efb6925a35
59 files changed
+4377 -3307

No files matched your search

+3 -1
View File
@@ -198,7 +198,7 @@ block.80=minecraft:pink_petals minecraft:wildflowers minecraft:attached_melon_st
#define snow_layers_5_8_entry snow:layers=5 snow:layers=6 snow:layers=7 snow:layers=8
#endif
## weak sss and floodfill ignore
block.81=minecraft:pitcher_plant minecraft:grass_block:snowy=true weeping_vines_plant twisting_vines_plant tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan minecraft:spore_blossom minecraft:mushroom_stem minecraft:sea_pickle:waterlogged=false \
block.81=minecraft:pitcher_plant weeping_vines_plant twisting_vines_plant tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan minecraft:spore_blossom minecraft:mushroom_stem minecraft:sea_pickle:waterlogged=false \
aquamirae:painting_anglerfish aquamirae:painting_oxygelium aquamirae:painting_tortured_soul aquamirae:painting_aurora \
beachparty:seashell_block beachparty:beach_parasol \
biomesoplenty:toadstool \
@@ -243,6 +243,8 @@ block.88=minecraft:small_amethyst_bud pointed_dripstone
block.89=minecraft:cactus
block.90=minecraft:grass_block:snowy=true
####### ----- lightsources ----- #######
block.101=large_amethyst_bud \
+2 -2
View File
@@ -17,7 +17,7 @@ uniform float frameTimeCounter;
uniform sampler2D noisetex;
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2DShadow shadowtex0HW;
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
@@ -393,7 +393,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
Shadows = 0.0;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
Shadows = texture(shadow, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x;
Shadows = texture(shadowtex0HW, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x;
}
#endif
+6 -7
View File
@@ -41,12 +41,11 @@ in DATA {
#ifdef OVERWORLD_SHADER
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2DShadow shadowtex0HW;
#ifdef TRANSLUCENT_COLORED_SHADOWS
uniform sampler2D shadowcolor0;
uniform sampler2DShadow shadowtex0;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex1HW;
#endif
#endif
@@ -208,10 +207,10 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
#ifdef TRANSLUCENT_COLORED_SHADOWS
// determine when opaque shadows are overlapping translucent shadows by getting the difference of opaque depth and translucent depth
float shadowDepthDiff = pow(clamp((texture(shadowtex1, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
float shadowDepthDiff = pow(clamp((texture(shadowtex1HW, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
// get opaque shadow data to get opaque data from translucent shadows.
float opaqueShadow = texture(shadowtex0, projectedShadowPosition).x;
float opaqueShadow = texture(shadowtex0HW, projectedShadowPosition).x;
shadowmap += max(opaqueShadow, shadowDepthDiff);
// get translucent shadow data
@@ -228,7 +227,7 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
translucentTint += mix(translucentShadow.rgb, vec3(1.0), opaqueShadow*shadowDepthDiff);
#else
shadowmap += texture(shadow, projectedShadowPosition).x;
shadowmap += texture(shadowtex0HW, projectedShadowPosition).x;
#endif
#ifdef TRANSLUCENT_COLORED_SHADOWS
@@ -345,7 +344,7 @@ void main() {
float maxdist = MAX_OCCLUSION_DISTANCE;
if (dist < maxdist) {
float depthmap = readNormal(clamp(texcoord.st, texcoordam.st, texcoordam.st + texcoordam.pq)).a;
float depthmap = readNormal(texcoord.st).a;
float used_POM_DEPTH = 1.0;
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
+4 -2
View File
@@ -445,7 +445,7 @@ void main() {
if (falloff > 0.0)
#endif
{
float depthmap = readNormal(clamp(data_in.texcoord.st, data_in.texcoordam.st, data_in.texcoordam.st + data_in.texcoordam.pq)).a;
float depthmap = readNormal(data_in.texcoord.st).a;
float pomdepth = POM_DEPTH * falloff;
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
@@ -799,7 +799,9 @@ void main() {
#endif
) {
SSSAMOUNT = 0.5;
}
} else if(data_in.blockID == GRASS_BLOCK_SNOWY) {
SSSAMOUNT = 0.5 * smoothstep(0.0, 1.0, fract(worldpos.y));
}
#if defined CUTOUT
else if (data_in.blockID == -BLOCK_GRASS) {
SSSAMOUNT = 0.3;
+6 -6
View File
@@ -53,12 +53,11 @@ uniform vec4 entityColor;
#if defined OVERWORLD_SHADER || (defined END_ISLAND_LIGHT && defined END_SHADER)
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2DShadow shadowtex0HW;
#ifdef TRANSLUCENT_COLORED_SHADOWS
uniform sampler2D shadowcolor0;
uniform sampler2DShadow shadowtex0;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex1HW;
#endif
uniform float lightSign;
@@ -225,6 +224,7 @@ vec2 decodeVec2(float a){
#define VOXEL_REFLECTIONS_TRANSLUCENT
#ifdef VOXEL_REFLECTIONS_TRANSLUCENT
#define VOXEL_REFLECTIONS
#endif
#ifdef PHOTONICS
@@ -441,10 +441,10 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
#ifdef TRANSLUCENT_COLORED_SHADOWS
// determine when opaque shadows are overlapping translucent shadows by getting the difference of opaque depth and translucent depth
float shadowDepthDiff = pow(clamp((texture(shadowtex1, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
float shadowDepthDiff = pow(clamp((texture(shadowtex1HW, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
// get opaque shadow data to get opaque data from translucent shadows.
float opaqueShadow = texture(shadowtex0, projectedShadowPosition).x;
float opaqueShadow = texture(shadowtex0HW, projectedShadowPosition).x;
shadowmap += max(opaqueShadow, shadowDepthDiff);
// get translucent shadow data
@@ -461,7 +461,7 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
translucentTint += mix(translucentShadow.rgb, vec3(1.0), opaqueShadow*shadowDepthDiff);
#else
shadowmap += texture(shadow, projectedShadowPosition).x;
shadowmap += texture(shadowtex0HW, projectedShadowPosition).x;
#endif
#ifdef BASIC_SHADOW_FILTER
+4
View File
@@ -221,6 +221,10 @@ void main() {
customShadowMatrixSSBO = BuildShadowViewMatrix(normalize(END_LIGHT_POS));
customShadowPerspectiveSSBO = createPerspectiveMatrix();
#endif
#ifdef PHOTONICS
customShadowMatrixInverseSSBO = inverse(customShadowMatrixSSBO);
#endif
#ifdef OVERWORLD_SHADER
////////////////////////////////
+33 -38
View File
@@ -10,6 +10,7 @@ in DATA {
#endif
};
#include "/lib/util.glsl"
#include "/lib/res_params.glsl"
uniform sampler2D depthtex0;
@@ -30,8 +31,12 @@ uniform sampler2D depthtex2;
#define dhVoxyDepthTex1 vxDepthTexOpaque
#endif
#include "/lib/Shadow_Params.glsl"
uniform sampler2D colortex1;
uniform sampler2D colortex3; // Noise
uniform sampler2D colortex4;
uniform sampler2D colortex5;
uniform sampler2D colortex6; // Noise
uniform sampler2D colortex7; // Noise
uniform sampler2D colortex8; // Noise
@@ -41,11 +46,13 @@ uniform sampler2D colortex10; // Noise
uniform sampler2D colortex12; // Noise
uniform sampler2D colortex13; // Noise
uniform int isEyeInWater;
uniform sampler2D shadow;
const bool shadowHardwareFiltering = true;
uniform sampler2D shadowtex0;
uniform sampler2DShadow shadowtex0HW;
#ifdef TRANSLUCENT_COLORED_SHADOWS
uniform sampler2D shadowcolor0;
uniform sampler2D shadowtex0;
uniform sampler2D shadowtex1;
#endif
@@ -58,21 +65,9 @@ uniform float rainStrength;
uniform int frameCounter;
uniform ivec2 eyeBrightnessSmooth;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferModelView;
uniform vec3 cameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferPreviousModelView;
uniform mat4 shadowModelView;
uniform mat4 shadowProjection;
uniform float viewWidth;
uniform float aspectRatio;
uniform float viewHeight;
@@ -81,19 +76,32 @@ uniform float viewHeight;
uniform float near;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
uniform float nightVision;
#define DEFERRED_SPECULAR
#define DEFERRED_SSR_QUALITY 30 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 200 300 400 500]
#define DEFERRED_BACKGROUND_REFLECTION
#define DEFERRED_ROUGH_REFLECTION
#ifdef DEFERRED_SPECULAR
#endif
#if DEFERRED_SSR_QUALITY > -1
#endif
#ifdef DEFERRED_BACKGROUND_REFLECTION
#endif
#ifdef DEFERRED_ROUGH_REFLECTION
#endif
uniform float waterEnteredAltitude;
uniform float sunElevation;
#include "/lib/projections.glsl"
#include "/lib/DistantHorizons_projections.glsl"
#include "/lib/color_transforms.glsl"
#include "/lib/waterBump.glsl"
#include "/lib/Shadows.glsl"
#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;
}
vec3 worldToView(vec3 worldPos) {
vec4 pos = vec4(worldPos, 0.0);
@@ -178,13 +186,6 @@ vec2 R2_samples(int n){
return fract(alpha * n);
}
vec3 viewToWorld(vec3 viewPos) {
vec4 pos;
pos.xyz = viewPos;
@@ -193,10 +194,7 @@ vec3 viewToWorld(vec3 viewPos) {
return pos.xyz;
}
#include "/lib/Shadow_Params.glsl"
const float PI = 3.141592653589793238462643383279502884197169;
vec2 SpiralSample(
int samples, int totalSamples, float rotation, float Xi
){
@@ -238,8 +236,6 @@ vec2 CleanSample(
#include "/lib/DistantHorizons_projections.glsl"
float DH_ld(float dist) {
return (2.0 * dhVoxyNearPlane) / (dhVoxyFarPlane + dhVoxyNearPlane - dist * (dhVoxyFarPlane - dhVoxyNearPlane));
}
@@ -398,7 +394,6 @@ float ld(float dist) {
/* RENDERTARGETS:3,14,9*/
void main() {
float noise = R2_dither();
vec2 texcoord = gl_FragCoord.xy*texelSize;
@@ -411,7 +406,7 @@ void main() {
float lightLeakFix = clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0);
gl_FragData[1] = vec4(0.0,0.0, texelFetch(colortex14, ivec2(gl_FragCoord.xy), 0).b, 0.0);
gl_FragData[1] = vec4(0.0);
vec4 SpecularData = texelFetch(colortex8, ivec2(gl_FragCoord.xy), 0);
@@ -602,7 +597,7 @@ void main() {
float weight = 3.0 + (i+noise) * rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7;
float d = texelFetch(shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x;
float d = texelFetch(shadowtex0, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x;
float b = smoothstep(weight*diffthresh/2.0, weight*diffthresh, projectedShadowPosition.z - d);
blockerCount += b;
+56 -17
View File
@@ -29,12 +29,11 @@ uniform float rainStrength;
#if defined OVERWORLD_SHADER || (defined END_ISLAND_LIGHT && defined END_SHADER)
const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2DShadow shadowtex0HW;
#ifdef TRANSLUCENT_COLORED_SHADOWS
uniform sampler2D shadowcolor0;
uniform sampler2DShadow shadowtex0;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex1HW;
#endif
#if ShaderSnow > 0
@@ -118,6 +117,8 @@ uniform sampler2D colortex12;
uniform sampler2D colortex13;
uniform sampler2D colortex14;
uniform sampler2D colortex15;
uniform sampler2D colortex17;
uniform sampler2D colortex18;
in DATA {
flat vec2 TAA_Offset;
@@ -132,7 +133,7 @@ in DATA {
uniform float sunElevation;
#if defined IS_LPV_ENABLED || defined PHOTONICS && defined PHOTONICS && !defined PH_ENABLE_HANDHELD_LIGHT
#if defined IS_LPV_ENABLED || defined PHOTONICS
uniform usampler1D texBlockData;
uniform sampler3D texLpv1;
uniform sampler3D texLpv2;
@@ -168,14 +169,13 @@ uniform vec3 sunVec;
#define VOXEL_REFLECTIONS_SOLID
#ifdef VOXEL_REFLECTIONS_SOLID
#define VOXEL_REFLECTIONS
#endif
#ifdef PHOTONICS
#ifdef VOXEL_REFLECTIONS
#define PHOTONICS_INCLUDED
#define PHOTONICS_INCLUDED
#include "/photonics/photonics.glsl"
#endif
#include "/photonics/photonics.glsl"
#endif
@@ -242,6 +242,10 @@ float convertHandDepth_2(in float depth, bool hand) {
#ifdef DEFERRED_ROUGH_REFLECTION
#endif
#ifndef DEFERRED_ROUGH_REFLECTION
#undef DENOISED_REFLECTIONS
#endif
#define MAIN_SHADOW_PASS
#define FULLRESDEPTH
@@ -746,8 +750,8 @@ vec3 ComputeShadowMap_COLOR(in vec3 projectedShadowPosition, float distortFactor
#endif
#ifdef TRANSLUCENT_COLORED_SHADOWS
float opaqueShadow = texture(shadowtex0, projectedShadowPosition).x;
float opaqueShadowT = texture(shadowtex1, projectedShadowPosition).x;
float opaqueShadow = texture(shadowtex0HW, projectedShadowPosition).x;
float opaqueShadowT = texture(shadowtex1HW, projectedShadowPosition).x;
vec4 translucentShadow = texture(shadowcolor0, projectedShadowPosition.xy);
float shadowAlpha = pow(1.0-pow(1.0-translucentShadow.a,2.0),5.0);
@@ -760,8 +764,8 @@ vec3 ComputeShadowMap_COLOR(in vec3 projectedShadowPosition, float distortFactor
translucentTint += mix(translucentShadow.rgb, vec3(1.0), max(opaqueShadow, backface * (shadowAlpha < 1.0 ? 0.0 : 1.0)));
FUNNYSHADOW += ((1.0-shadowAlpha) * opaqueShadowT)/samples;
#else
// shadowColor += directLightColor * texture(shadow, projectedShadowPosition).x;
shadowColor += vec3(1.0) * texture(shadow, projectedShadowPosition).x;
// shadowColor += directLightColor * texture(shadowtex0HW, projectedShadowPosition).x;
shadowColor += vec3(1.0) * texture(shadowtex0HW, projectedShadowPosition).x;
#endif
@@ -770,7 +774,7 @@ vec3 ComputeShadowMap_COLOR(in vec3 projectedShadowPosition, float distortFactor
#endif
#if DEBUG_VIEW == debug_SHADOWMAP
shadowDebug = texture(shadow, projectedShadowPosition).x;
shadowDebug = texture(shadowtex0HW, projectedShadowPosition).x;
#endif
// #ifdef TRANSLUCENT_COLORED_SHADOWS
// // directLightColor *= mix(vec3(1.0), translucentTint.rgb / samples, maxDistFade);
@@ -865,8 +869,8 @@ uniform float wetness;
vec2 driprate = vec2(0.0,frameTimeCounter)*0.05;
vec2 UV = mix(worldPos.xz, worldPos.xy*vec2(2.0, 0.5)+driprate, abs(flatNormals.z));
UV = mix(UV, worldPos.zy*vec2(2.0, 0.5)+driprate, abs(flatNormals.x));
vec2 UV = mix(worldPos.xz, worldPos.xy*vec2(2.0, 0.5)+driprate, 0.0);
UV = mix(UV, worldPos.zy*vec2(2.0, 0.5)+driprate, 0.0);
#ifdef SHADER_GRASS
if(isShaderGrass) UV = worldPos.xz;
@@ -968,8 +972,30 @@ uniform float wetness;
}
#endif
void main() {
//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));
}
vec2 encodeNormal(vec3 n){
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 encn;
}
void main() {
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
gl_FragData[1] = vec4(0.0);
gl_FragData[2] = vec4(0.0);
gl_FragData[3] = vec4(0.0);
#endif
vec3 DEBUG = vec3(1.0);
////// --------------- SETUP STUFF --------------- //////
@@ -1676,8 +1702,17 @@ void main() {
vec2 specularNoises = vec2(blueNoise(), ig_noise);
vec3 specularNormal = normal;
if (dot(normal, (feetPlayerPos_normalized)) > 0.0) specularNormal = FlatNormals;
vec4 reflections = vec4(0.0,0.0,0.0,1.0);
float SunReflectionAlpha = 0.0;
FINAL_COLOR = specularReflections(viewPos, feetPlayerPos, feetPlayerPos_normalized, WsunVec, specularNoises, FlatNormals, specularNormal, SpecularTex.r, SpecularTex.g, albedo, FINAL_COLOR, DirectLightColor*shadowColor*shadowColor, lightmap.y, hand, flashLightSpecularData);
FINAL_COLOR = specularReflections(viewPos, feetPlayerPos, feetPlayerPos_normalized, WsunVec, specularNoises, FlatNormals, specularNormal, SpecularTex.r, SpecularTex.g, albedo, FINAL_COLOR, DirectLightColor*shadowColor*shadowColor, lightmap.y, hand, reflections, SunReflectionAlpha, flashLightSpecularData);
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
gl_FragData[1] = reflections;
gl_FragData[2].rgb = DirectLightColor*shadowColor*shadowColor*SunReflectionAlpha;
gl_FragData[3] = vec4(encodeNormal(specularNormal), SpecularTex.r, SpecularTex.g);
#endif
#endif
gl_FragData[0].rgb = FINAL_COLOR;
@@ -1886,5 +1921,9 @@ void main() {
// }
#endif
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
/* RENDERTARGETS:3,0,15,8 */
#else
/* RENDERTARGETS:3 */
#endif
}
+40 -352
View File
@@ -1,367 +1,55 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
#include "/lib/SSBOs.glsl"
in vec2 texcoord;
const bool colortex5MipmapEnabled = true;
// uniform sampler2D colortex4;
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 sampler2D colortex6;
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 int hideGUI;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
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(texelFetch(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
}
// uniform float viewWidth;
// uniform float viewHeight;
// uniform sampler2D depthtex0;
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
#define dhVoxyDepthTex dhDepthTex
#endif
#ifdef VOXY
uniform sampler2D vxDepthTexTrans;
#define dhVoxyDepthTex vxDepthTexTrans
#endif
uniform float dhVoxyNearPlane;
uniform float dhVoxyFarPlane;
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
float bloomWeight(){
float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 );
// float weights[7] = float[]( 0.7, pow(0.5,2), pow(0.5,3), pow(0.5,4), pow(0.5,5), pow(0.5,6), pow(0.5,7) );
float result = 0.0;
for ( int i = 0; i < 7; i++) {
result += weights[i];
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
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 = exp(-i*i*alpha*4.0);
vec2 spCoord = coord+dir*texelSize*(2.0*i+0.5);
tot += vec4(texture(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.y > minTC && spCoord.y < maxTC);
}
return result;
}
vec3 invTonemap(vec3 col){
return col/(1-luma(col));
}
#define linear_to_srgb(x) (pow(x, vec3(1.0/2.2)))
uniform sampler2D colortex6;
float w0(float a)
{
return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0);
return tot.rgb/max(1.0,tot.a);
}
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 texture_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 * texture(tex, p0) +
g1x * texture(tex, p1)) +
g1(fuv.y) * (g0x * texture(tex, p2) +
g1x * texture(tex, p3));
}
// vec3 lenseFlare(vec2 UV){
// float noise = blueNoise();
// float vignetteLength = 0.2;
// float vignette = 0.5+length(texcoord-0.5);//min(max(length(texcoord-0.5) - vignetteLength,0.0) / (1.0/(1.0-vignetteLength)),1.0);
// float aberrationStrength = vignette;//clamp(CHROMATIC_ABERRATION_STRENGTH * 0.01 * (1.0 - vignette),0.0,0.9) * vignette * 0.75;
// vec2 centeredUV = texcoord - 0.5;
// vec3 color = vec3(0.0);
// color = texture(colortex7, texcoord).rgb;
// vec2 distortedUV = (centeredUV - (centeredUV ) * aberrationStrength) + 0.5;
// color += texture(colortex7, distortedUV).rgb;
// // color.r = texture(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r;
// // color.g = texture(colortex7, texcoord).g;
// // color.b = texture(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b;
// return color;
// }
vec3 srgbToLinear(vec3 srgb){
return mix(
srgb / 12.92,
pow(.947867 * srgb + .0521327, vec3(2.4) ),
step( .04045, srgb )
);
}
vec3 blackbody(float Temp)
{
float t = pow(Temp, -1.5);
float lt = log(Temp);
vec3 WB_temp = vec3(0.0);
WB_temp.r = 220000.0 * t + 0.58039215686;
WB_temp.g = 0.39231372549 * lt - 2.44549019608;
WB_temp.g = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : WB_temp.g;
WB_temp.b = 0.76078431372 * lt - 5.68078431373;
WB_temp = clamp(WB_temp,0,1);
WB_temp = Temp < 1000. ? WB_temp * Temp * 0.001 : WB_temp;
return srgbToLinear(WB_temp);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* RENDERTARGETS:7 */
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
vec3 col = texture(colortex5,texcoord).rgb;
/* RENDERTARGETS:6 */
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
vec2 rodExposureDepth = rodExposureDepthSSBO;
rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0);
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);
vec4 exposure = vec4(exposureSSBO);
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);
#if DOF_QUALITY >= 0
/*--------------------------------*/
float z = ld(texture(depthtex1, texcoord*RENDER_SCALE).r)*far;
#if MANUAL_FOCUS == -2
float focus = rodExposureDepth.y*far;
#elif MANUAL_FOCUS == -1
float focus = mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25);
#elif MANUAL_FOCUS > 0
float focus = MANUAL_FOCUS;
#endif
#if DOF_QUALITY < 5
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
#ifdef REMOVE_HAND_BLUR
pcoc *= float(z > 0.56);
#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;
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 dispersion = (texcoord - 0.5) * pcoc * 200.0 * DOF_DISPERSION_MULT;
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);
for ( int i = 0; i < BOKEH_SAMPLES; i++) {
// bcolor += textureLod(colortex5, texcoord.xy + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).rgb;
bcolor.r += textureLod(colortex5, texcoord + (bokeh_offsets[i] + dispersion)*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).r;
bcolor.g += textureLod(colortex5, texcoord + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).g;
bcolor.b += textureLod(colortex5, texcoord + (bokeh_offsets[i] - dispersion)*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).b;
}
col = bcolor/BOKEH_SAMPLES;
#endif
#endif
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);
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
vec2 resScale = vec2(1920.,1080.)/clampedRes;
vec2 bloomTileUV = (((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0) / clampedRes*vec2(1920.,1080.);
vec3 bloomTile0 = texture_bicubic(colortex3, bloomTileUV/2.).rgb; //1/4 res
vec3 bloomTile1 = texture_bicubic(colortex6, bloomTileUV/4.).rgb; //1/8 res
vec3 bloomTile2 = texture_bicubic(colortex6, bloomTileUV/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res
vec3 bloomTile3 = texture_bicubic(colortex6, bloomTileUV/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res
vec3 bloomTile4 = texture_bicubic(colortex6, bloomTileUV/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb; //1/64 res
vec3 bloomTile5 = texture_bicubic(colortex6, bloomTileUV/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb; //1/128 res
vec3 bloomTile6 = texture_bicubic(colortex6, bloomTileUV/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb; //1/256 res
#ifdef OLD_BLOOM
vec3 bloom = (bloomTile0 + bloomTile1 + bloomTile2 + bloomTile3 + bloomTile4 + bloomTile5 + bloomTile6) / 7.0;
vec3 fogBloom = bloom;
float lightScat = clamp((BLOOM_STRENGTH+3.0) * 0.05 * pow(exposure.a, 0.2) ,0.0,1.0) * vignette;
#else
float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 );
vec3 bloom = (bloomTile0*weights[0] + bloomTile1*weights[1] + bloomTile2*weights[2] + bloomTile3*weights[3] + bloomTile4*weights[4] + bloomTile5*weights[5] + bloomTile6*weights[6]) / bloomWeight();
vec3 fogBloom = (bloomTile0 + bloomTile1 + bloomTile2 + bloomTile3 + bloomTile4 + bloomTile5 + bloomTile6) / 7.0;
float lightScat = clamp(BLOOM_STRENGTH * 0.3,0.0,1.0) * vignette;
#endif
float VL_abs = texture(colortex7, texcoord*RENDER_SCALE).r;
float bloomyFog_Mult = BLOOMY_FOG;
if(isEyeInWater == 1) bloomyFog_Mult = UNDERWATER_BLOOMY_FOG;
#if Purkinje_strength > 0
float pstrength = float(Purkinje_strength) / 100.0;
#ifdef AUTO_EXPOSURE
float purkinje = clamp(exposure.a*exposure.a,0.0,1.0) * clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*pstrength,0,1);
#else
float purkinje = clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*pstrength,0,1);
#endif
VL_abs = clamp((1.0-VL_abs)*bloomyFog_Mult*0.75*(1.0+rainStrength) * (1.0-purkinje*0.3),0.0,1.0)*clamp(1.0-pow(cdist(texcoord),15.0),0.0,1.0);
col = (mix(col, fogBloom, VL_abs) + bloom*lightScat) * exposure.rgb;
float lum = dot(col, vec3(0.15,0.3,0.55));
float lum2 = dot(col, vec3(0.85,0.7,0.45));
float rodLum = lum2*200.0;
float rodCurve = clamp(mix(1.0, rodLum/(2.5+rodLum), purkinje),0.0,1.0);
col = mix(lum * vec3(Purkinje_R, Purkinje_G, Purkinje_B) * Purkinje_Multiplier, col, rodCurve);
#else
VL_abs = clamp((1.0-VL_abs)*bloomyFog_Mult*0.75*(1.0+rainStrength),0.0,1.0)*clamp(1.0-pow(cdist(texcoord),15.0),0.0,1.0);
col = (mix(col, fogBloom, VL_abs) + bloom*lightScat) * exposure.rgb;
#endif
#if WHITE_BALANCE != 6500
col *= blackbody(WHITE_BALANCE);
#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);
#if DOF_QUALITY == 5
#if FOCUS_LASER_COLOR == 0 // Red
vec3 laserColor = vec3(25, 0, 0);
#elif FOCUS_LASER_COLOR == 1 // Green
vec3 laserColor = vec3(0, 25, 0);
#elif FOCUS_LASER_COLOR == 2 // Blue
vec3 laserColor = vec3(0, 0, 25);
#elif FOCUS_LASER_COLOR == 3 // Pink
vec3 laserColor = vec3(25, 10, 15);
#elif FOCUS_LASER_COLOR == 4 // Yellow
vec3 laserColor = vec3(25, 25, 0);
#elif FOCUS_LASER_COLOR == 5 // White
vec3 laserColor = vec3(25);
#endif
float depth = texture(depthtex0, texcoord).r;
#if defined DISTANT_HORIZONS || defined VOXY
float _near = near;
float _far = far*4.0;
if (depth >= 1.0) {
depth = texture(dhVoxyDepthTex, texcoord).x;
_near = dhVoxyNearPlane;
_far = dhVoxyFarPlane;
}
depth = linearizeDepthFast(depth, _near, _far);
#else
depth = linearizeDepthFast(depth, near, far);
#endif
// focus = gl_FragCoord.x * 0.1;
if( hideGUI < 1) gl_FragData[0].rgb += laserColor * pow( clamp( 1.0-abs(focus-abs(depth)) ,0,1),25) ;
#endif
}
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
}
+8 -6
View File
@@ -1,7 +1,5 @@
#include "/lib/settings.glsl"
out vec2 texcoord;
uniform float viewWidth;
uniform float viewHeight;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -10,6 +8,10 @@ out vec2 texcoord;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0));
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}
//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;
}
+337 -160
View File
@@ -1,190 +1,367 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
#include "/lib/SSBOs.glsl"
in vec2 texcoord;
const bool colortex5MipmapEnabled = true;
// uniform sampler2D colortex4;
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 sampler2D colortex7;
uniform sampler2D colortex14;
uniform sampler2D depthtex0;
uniform sampler2D noisetex;
uniform float viewHeight;
uniform ivec2 eyeBrightnessSmooth;
uniform float viewWidth;
uniform float aspectRatio;
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 int hideGUI;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferProjectionInverse;
vec4 Weather_properties = Moon_Weather_properties;
#include "/lib/color_transforms.glsl"
#include "/lib/color_dither.glsl"
#include "/lib/res_params.glsl"
// #include "/lib/biome_specifics.glsl"
#include "/lib/bokeh.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
// 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 += texture(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
result += texture(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
result += texture(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
result += texture(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
result += texture(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
result += texture(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
result += texture(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
result += texture(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
result += texture(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
return result;
}
*/
float lowerCurve(float x) {
float y = 16 * x * (0.5 - x) * 0.1;
return clamp(y, 0.0, 1.0);
}
float upperCurve(float x) {
float y = 16 * (0.5 - x) * (x - 1.0) * 0.1;
return clamp(y, 0.0, 1.0);
}
vec3 luminanceCurve(vec3 color){
color.r += LOWER_CURVE * lowerCurve(color.r) + UPPER_CURVE * upperCurve(color.r);
color.g += LOWER_CURVE * lowerCurve(color.g) + UPPER_CURVE * upperCurve(color.g);
color.b += LOWER_CURVE * lowerCurve(color.b) + UPPER_CURVE * upperCurve(color.b);
return color;
}
vec3 colorGrading(vec3 color) {
float grade_luma = dot(color, vec3(1.0 / 3.0));
float shadows_amount = saturate(-6.0 * grade_luma + 2.75);
float mids_amount = saturate(-abs(6.0 * grade_luma - 3.0) + 1.25);
float highlights_amount = saturate(6.0 * grade_luma - 3.25);
vec3 graded_shadows = color * SHADOWS_TARGET * SHADOWS_GRADE_MUL * 1.7320508076;
vec3 graded_mids = color * MIDS_TARGET * MIDS_GRADE_MUL * 1.7320508076;
vec3 graded_highlights = color * HIGHLIGHTS_TARGET * HIGHLIGHTS_GRADE_MUL * 1.7320508076;
return saturate(graded_shadows * shadows_amount + graded_mids * mids_amount + graded_highlights * highlights_amount);
}
vec3 contrastAdaptiveSharpening(vec3 color, vec2 texcoord){
float sharpen_strength = float(SHARPENING)/100.0;
//Weights : 1 in the center, 0.5 middle, 0.25 corners
vec3 albedoCurrent1 = texture(colortex7, texcoord + vec2(texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent2 = texture(colortex7, texcoord + vec2(texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent3 = texture(colortex7, texcoord + vec2(-texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent4 = texture(colortex7, texcoord + vec2(-texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 m1 = -0.5/3.5*color + albedoCurrent1/3.5 + albedoCurrent2/3.5 + albedoCurrent3/3.5 + albedoCurrent4/3.5;
vec3 std = abs(color - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
float contrast = 1.0 - luma(std)/5.0;
color = color*(1.0+(sharpen_strength+UPSCALING_SHARPNENING)*contrast) -
(sharpen_strength+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*color);
return color;
}
vec3 saturationAndCrosstalk(vec3 color){
float luminance = luma(color);
vec3 lumaColDiff = color - luminance;
color = color + lumaColDiff*(-luminance*CROSSTALK + SATURATION);
return color;
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy;
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
return noise;
float cdist(vec2 coord) {
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
}
float blueNoise(){
return fract(texelFetch(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
}
vec3 chromaticAberration(vec2 UV){
float noise = blueNoise() - 0.5;
// uniform float viewWidth;
// uniform float viewHeight;
vec2 centeredUV = (texcoord - 0.5);
// not stretched by aspect ratio; circular by choice :) it makes most the abberation on the left/right of the screen.
float vignette = 1.0 - clamp(1.0 - length(centeredUV * vec2(aspectRatio,1.0)) / 200.0,0.0,1.0);
// uniform sampler2D depthtex0;
float aberrationStrength = CHROMATIC_ABERRATION_STRENGTH * vignette;
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
#define dhVoxyDepthTex dhDepthTex
#endif
vec3 color = vec3(0.0);
color.r = texture(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r;
color.g = texture(colortex7, texcoord).g;
color.b = texture(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b;
#ifdef VOXY
uniform sampler2D vxDepthTexTrans;
#define dhVoxyDepthTex vxDepthTexTrans
#endif
uniform float dhVoxyNearPlane;
uniform float dhVoxyFarPlane;
return color;
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
float bloomWeight(){
float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 );
// float weights[7] = float[]( 0.7, pow(0.5,2), pow(0.5,3), pow(0.5,4), pow(0.5,5), pow(0.5,6), pow(0.5,7) );
float result = 0.0;
for ( int i = 0; i < 7; i++) {
result += weights[i];
}
return result;
}
vec3 invTonemap(vec3 col){
return col/(1-luma(col));
}
#define linear_to_srgb(x) (pow(x, vec3(1.0/2.2)))
uniform sampler2D colortex6;
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 texture_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 * texture(tex, p0) +
g1x * texture(tex, p1)) +
g1(fuv.y) * (g0x * texture(tex, p2) +
g1x * texture(tex, p3));
}
// vec3 lenseFlare(vec2 UV){
// float noise = blueNoise();
// float vignetteLength = 0.2;
// float vignette = 0.5+length(texcoord-0.5);//min(max(length(texcoord-0.5) - vignetteLength,0.0) / (1.0/(1.0-vignetteLength)),1.0);
// float aberrationStrength = vignette;//clamp(CHROMATIC_ABERRATION_STRENGTH * 0.01 * (1.0 - vignette),0.0,0.9) * vignette * 0.75;
// vec2 centeredUV = texcoord - 0.5;
// vec3 color = vec3(0.0);
// color = texture(colortex7, texcoord).rgb;
// vec2 distortedUV = (centeredUV - (centeredUV ) * aberrationStrength) + 0.5;
// color += texture(colortex7, distortedUV).rgb;
// // color.r = texture(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r;
// // color.g = texture(colortex7, texcoord).g;
// // color.b = texture(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b;
// return color;
// }
vec3 srgbToLinear(vec3 srgb){
return mix(
srgb / 12.92,
pow(.947867 * srgb + .0521327, vec3(2.4) ),
step( .04045, srgb )
);
}
vec3 blackbody(float Temp)
{
float t = pow(Temp, -1.5);
float lt = log(Temp);
vec3 WB_temp = vec3(0.0);
WB_temp.r = 220000.0 * t + 0.58039215686;
WB_temp.g = 0.39231372549 * lt - 2.44549019608;
WB_temp.g = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : WB_temp.g;
WB_temp.b = 0.76078431372 * lt - 5.68078431373;
WB_temp = clamp(WB_temp,0,1);
WB_temp = Temp < 1000. ? WB_temp * Temp * 0.001 : WB_temp;
return srgbToLinear(WB_temp);
}
void main() {
/* RENDERTARGETS:7 */
#ifdef CHROMATIC_ABERRATION
vec3 color = chromaticAberration(texcoord);
#else
vec3 color = texture(colortex7,texcoord).rgb;
#endif
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
vec3 col = texture(colortex5,texcoord).rgb;
#if SHARPENING > 0
color = contrastAdaptiveSharpening(color, texcoord);
vec2 rodExposureDepth = rodExposureDepthSSBO;
rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0);
vec4 exposure = vec4(exposureSSBO);
#if DOF_QUALITY >= 0
/*--------------------------------*/
float z = ld(texture(depthtex1, texcoord*RENDER_SCALE).r)*far;
#if MANUAL_FOCUS == -2
float focus = rodExposureDepth.y*far;
#elif MANUAL_FOCUS == -1
float focus = mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25);
#elif MANUAL_FOCUS > 0
float focus = MANUAL_FOCUS;
#endif
#if DOF_QUALITY < 5
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
#ifdef REMOVE_HAND_BLUR
pcoc *= float(z > 0.56);
#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;
vec2 dispersion = (texcoord - 0.5) * pcoc * 200.0 * DOF_DISPERSION_MULT;
for ( int i = 0; i < BOKEH_SAMPLES; i++) {
// bcolor += textureLod(colortex5, texcoord.xy + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).rgb;
bcolor.r += textureLod(colortex5, texcoord + (bokeh_offsets[i] + dispersion)*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).r;
bcolor.g += textureLod(colortex5, texcoord + bokeh_offsets[i]*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).g;
bcolor.b += textureLod(colortex5, texcoord + (bokeh_offsets[i] - dispersion)*pcoc*vec2(DOF_ANAMORPHIC_RATIO,aspectRatio), dofLodLevel).b;
}
col = bcolor/BOKEH_SAMPLES;
#endif
#endif
color = saturationAndCrosstalk(color);
#ifdef LUMINANCE_CURVE
color = luminanceCurve(color);
#endif
#ifdef COLOR_GRADING_ENABLED
color = colorGrading(color);
#endif
gl_FragData[0] = vec4(clamp(int8Dither(color, texcoord),0.0,1.0), 0.0);
}
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
vec2 resScale = vec2(1920.,1080.)/clampedRes;
vec2 bloomTileUV = (((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0) / clampedRes*vec2(1920.,1080.);
vec3 bloomTile0 = texture_bicubic(colortex3, bloomTileUV/2.).rgb; //1/4 res
vec3 bloomTile1 = texture_bicubic(colortex6, bloomTileUV/4.).rgb; //1/8 res
vec3 bloomTile2 = texture_bicubic(colortex6, bloomTileUV/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res
vec3 bloomTile3 = texture_bicubic(colortex6, bloomTileUV/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res
vec3 bloomTile4 = texture_bicubic(colortex6, bloomTileUV/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb; //1/64 res
vec3 bloomTile5 = texture_bicubic(colortex6, bloomTileUV/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb; //1/128 res
vec3 bloomTile6 = texture_bicubic(colortex6, bloomTileUV/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb; //1/256 res
#ifdef OLD_BLOOM
vec3 bloom = (bloomTile0 + bloomTile1 + bloomTile2 + bloomTile3 + bloomTile4 + bloomTile5 + bloomTile6) / 7.0;
vec3 fogBloom = bloom;
float lightScat = clamp((BLOOM_STRENGTH+3.0) * 0.05 * pow(exposure.a, 0.2) ,0.0,1.0) * vignette;
#else
float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 );
vec3 bloom = (bloomTile0*weights[0] + bloomTile1*weights[1] + bloomTile2*weights[2] + bloomTile3*weights[3] + bloomTile4*weights[4] + bloomTile5*weights[5] + bloomTile6*weights[6]) / bloomWeight();
vec3 fogBloom = (bloomTile0 + bloomTile1 + bloomTile2 + bloomTile3 + bloomTile4 + bloomTile5 + bloomTile6) / 7.0;
float lightScat = clamp(BLOOM_STRENGTH * 0.3,0.0,1.0) * vignette;
#endif
float VL_abs = texture(colortex7, texcoord*RENDER_SCALE).r;
float bloomyFog_Mult = BLOOMY_FOG;
if(isEyeInWater == 1) bloomyFog_Mult = UNDERWATER_BLOOMY_FOG;
#if Purkinje_strength > 0
float pstrength = float(Purkinje_strength) / 100.0;
#ifdef AUTO_EXPOSURE
float purkinje = clamp(exposure.a*exposure.a,0.0,1.0) * clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*pstrength,0,1);
#else
float purkinje = clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*pstrength,0,1);
#endif
VL_abs = clamp((1.0-VL_abs)*bloomyFog_Mult*0.75*(1.0+rainStrength) * (1.0-purkinje*0.3),0.0,1.0)*clamp(1.0-pow(cdist(texcoord),15.0),0.0,1.0);
col = (mix(col, fogBloom, VL_abs) + bloom*lightScat) * exposure.rgb;
float lum = dot(col, vec3(0.15,0.3,0.55));
float lum2 = dot(col, vec3(0.85,0.7,0.45));
float rodLum = lum2*200.0;
float rodCurve = clamp(mix(1.0, rodLum/(2.5+rodLum), purkinje),0.0,1.0);
col = mix(lum * vec3(Purkinje_R, Purkinje_G, Purkinje_B) * Purkinje_Multiplier, col, rodCurve);
#else
VL_abs = clamp((1.0-VL_abs)*bloomyFog_Mult*0.75*(1.0+rainStrength),0.0,1.0)*clamp(1.0-pow(cdist(texcoord),15.0),0.0,1.0);
col = (mix(col, fogBloom, VL_abs) + bloom*lightScat) * exposure.rgb;
#endif
#if WHITE_BALANCE != 6500
col *= blackbody(WHITE_BALANCE);
#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);
#if DOF_QUALITY == 5
#if FOCUS_LASER_COLOR == 0 // Red
vec3 laserColor = vec3(25, 0, 0);
#elif FOCUS_LASER_COLOR == 1 // Green
vec3 laserColor = vec3(0, 25, 0);
#elif FOCUS_LASER_COLOR == 2 // Blue
vec3 laserColor = vec3(0, 0, 25);
#elif FOCUS_LASER_COLOR == 3 // Pink
vec3 laserColor = vec3(25, 10, 15);
#elif FOCUS_LASER_COLOR == 4 // Yellow
vec3 laserColor = vec3(25, 25, 0);
#elif FOCUS_LASER_COLOR == 5 // White
vec3 laserColor = vec3(25);
#endif
float depth = texture(depthtex0, texcoord).r;
#if defined DISTANT_HORIZONS || defined VOXY
float _near = near;
float _far = far*4.0;
if (depth >= 1.0) {
depth = texture(dhVoxyDepthTex, texcoord).x;
_near = dhVoxyNearPlane;
_far = dhVoxyFarPlane;
}
depth = linearizeDepthFast(depth, _near, _far);
#else
depth = linearizeDepthFast(depth, near, far);
#endif
// focus = gl_FragCoord.x * 0.1;
if( hideGUI < 1) gl_FragData[0].rgb += laserColor * pow( clamp( 1.0-abs(focus-abs(depth)) ,0,1),25) ;
#endif
}
+2 -1
View File
@@ -2,6 +2,7 @@
out vec2 texcoord;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -11,4 +12,4 @@ out vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}
}
+190
View File
@@ -0,0 +1,190 @@
#include "/lib/settings.glsl"
in vec2 texcoord;
uniform vec2 texelSize;
uniform sampler2D colortex7;
uniform sampler2D colortex14;
uniform sampler2D depthtex0;
uniform sampler2D noisetex;
uniform float viewHeight;
uniform float viewWidth;
uniform float aspectRatio;
uniform float frameTimeCounter;
uniform int frameCounter;
uniform int hideGUI;
#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
// 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 += texture(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
result += texture(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
result += texture(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
result += texture(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
result += texture(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
result += texture(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
result += texture(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
result += texture(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
result += texture(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
return result;
}
*/
float lowerCurve(float x) {
float y = 16 * x * (0.5 - x) * 0.1;
return clamp(y, 0.0, 1.0);
}
float upperCurve(float x) {
float y = 16 * (0.5 - x) * (x - 1.0) * 0.1;
return clamp(y, 0.0, 1.0);
}
vec3 luminanceCurve(vec3 color){
color.r += LOWER_CURVE * lowerCurve(color.r) + UPPER_CURVE * upperCurve(color.r);
color.g += LOWER_CURVE * lowerCurve(color.g) + UPPER_CURVE * upperCurve(color.g);
color.b += LOWER_CURVE * lowerCurve(color.b) + UPPER_CURVE * upperCurve(color.b);
return color;
}
vec3 colorGrading(vec3 color) {
float grade_luma = dot(color, vec3(1.0 / 3.0));
float shadows_amount = saturate(-6.0 * grade_luma + 2.75);
float mids_amount = saturate(-abs(6.0 * grade_luma - 3.0) + 1.25);
float highlights_amount = saturate(6.0 * grade_luma - 3.25);
vec3 graded_shadows = color * SHADOWS_TARGET * SHADOWS_GRADE_MUL * 1.7320508076;
vec3 graded_mids = color * MIDS_TARGET * MIDS_GRADE_MUL * 1.7320508076;
vec3 graded_highlights = color * HIGHLIGHTS_TARGET * HIGHLIGHTS_GRADE_MUL * 1.7320508076;
return saturate(graded_shadows * shadows_amount + graded_mids * mids_amount + graded_highlights * highlights_amount);
}
vec3 contrastAdaptiveSharpening(vec3 color, vec2 texcoord){
float sharpen_strength = float(SHARPENING)/100.0;
//Weights : 1 in the center, 0.5 middle, 0.25 corners
vec3 albedoCurrent1 = texture(colortex7, texcoord + vec2(texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent2 = texture(colortex7, texcoord + vec2(texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent3 = texture(colortex7, texcoord + vec2(-texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 albedoCurrent4 = texture(colortex7, texcoord + vec2(-texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
vec3 m1 = -0.5/3.5*color + albedoCurrent1/3.5 + albedoCurrent2/3.5 + albedoCurrent3/3.5 + albedoCurrent4/3.5;
vec3 std = abs(color - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
float contrast = 1.0 - luma(std)/5.0;
color = color*(1.0+(sharpen_strength+UPSCALING_SHARPNENING)*contrast) -
(sharpen_strength+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*color);
return color;
}
vec3 saturationAndCrosstalk(vec3 color){
float luminance = luma(color);
vec3 lumaColDiff = color - luminance;
color = color + lumaColDiff*(-luminance*CROSSTALK + SATURATION);
return color;
}
float interleaved_gradientNoise(){
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(texelFetch(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
}
vec3 chromaticAberration(vec2 UV){
float noise = blueNoise() - 0.5;
vec2 centeredUV = (texcoord - 0.5);
// not stretched by aspect ratio; circular by choice :) it makes most the abberation on the left/right of the screen.
float vignette = 1.0 - clamp(1.0 - length(centeredUV * vec2(aspectRatio,1.0)) / 200.0,0.0,1.0);
float aberrationStrength = CHROMATIC_ABERRATION_STRENGTH * vignette;
vec3 color = vec3(0.0);
color.r = texture(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r;
color.g = texture(colortex7, texcoord).g;
color.b = texture(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b;
return color;
}
void main() {
/* RENDERTARGETS:7 */
#ifdef CHROMATIC_ABERRATION
vec3 color = chromaticAberration(texcoord);
#else
vec3 color = texture(colortex7,texcoord).rgb;
#endif
#if SHARPENING > 0
color = contrastAdaptiveSharpening(color, texcoord);
#endif
color = saturationAndCrosstalk(color);
#ifdef LUMINANCE_CURVE
color = luminanceCurve(color);
#endif
#ifdef COLOR_GRADING_ENABLED
color = colorGrading(color);
#endif
gl_FragData[0] = vec4(clamp(int8Dither(color, texcoord),0.0,1.0), 0.0);
}
+14
View File
@@ -0,0 +1,14 @@
#include "/lib/settings.glsl"
out vec2 texcoord;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}
File diff suppressed because it is too large. Load diff
+29 -49
View File
@@ -1,39 +1,31 @@
#include "/lib/settings.glsl"
#include "/lib/util.glsl"
#include "/lib/res_params.glsl"
#if defined CUSTOM_MOON_ROTATION && defined OVERWORLD_SHADER
#include "/lib/SSBOs.glsl"
#include "/lib/SSBOs.glsl"
#if defined BorderFog || (defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS) > 0
uniform sampler2D colortex4;
#include "/lib/scene_controller.glsl"
#endif
#include "/lib/scene_controller.glsl"
out DATA {
#ifdef OVERWORLD_SHADER
out DATA {
flat vec3 WsunVec;
flat vec3 WrealSunVec;
flat vec3 WmoonVec;
};
};
#endif
uniform vec2 texelSize;
uniform float far;
uniform float near;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
uniform sampler2D colortex4;
uniform float sunElevation;
uniform mat4 gbufferModelViewInverse;
uniform vec3 sunPosition;
uniform vec3 moonPosition;
uniform mat4 gbufferModelViewInverse;
uniform int frameCounter;
uniform float sunElevation;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
uniform float frameTimeCounter;
#include "/lib/Shadow_Params.glsl"
#include "/lib/sky_gradient.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -41,11 +33,6 @@ uniform float frameTimeCounter;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_SCALE)*2.0-1.0;
float lightSourceCheck = float(sunElevation > 1e-5)*2.0 - 1.0;
#ifdef OVERWORLD_SHADER
#ifdef SMOOTH_SUN_ROTATION
@@ -53,29 +40,22 @@ void main() {
#else
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
#endif
#ifdef CUSTOM_MOON_ROTATION
#if LIGHTNING_SHADOWS > 0
vec3 moonVec = customMoonVec2SSBO;
#else
vec3 moonVec = customMoonVecSSBO;
#endif
#else
#ifdef SMOOTH_MOON_ROTATION
vec3 moonVec = WmoonVecSmooth;
#if AURORA_LOCATION > 0
#ifdef CUSTOM_MOON_ROTATION
WmoonVec = customMoonVecSSBO;
#else
vec3 moonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
#ifdef SMOOTH_MOON_ROTATION
WmoonVec = WmoonVecSmooth;
#else
WmoonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
#endif
if(dot(-WmoonVec, WsunVec) < 0.9999) WmoonVec = -WmoonVec;
#endif
if(dot(-moonVec, WsunVec) < 0.9999) moonVec = -moonVec;
#endif
WmoonVec = moonVec;
WrealSunVec = WsunVec;
WsunVec = mix(WmoonVec, WsunVec, clamp(lightSourceCheck,0,1));
#else
WmoonVec = vec3(0.0, 1.0, 0.0);
WsunVec = vec3(0.0, 1.0, 0.0);
WrealSunVec = vec3(0.0, 1.0, 0.0);
WsunVec = mix(WmoonVec, WsunVec, clamp(float(sunElevation > 1e-5)*2.0 - 1.0,0,1));
#endif
}
gl_Position = ftransform();
}
File diff suppressed because it is too large. Load diff
+50 -28
View File
@@ -1,31 +1,39 @@
#include "/lib/settings.glsl"
#include "/lib/util.glsl"
#include "/lib/res_params.glsl"
#include "/lib/SSBOs.glsl"
#if defined BorderFog || (defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS) > 0
uniform sampler2D colortex4;
#include "/lib/scene_controller.glsl"
#if defined CUSTOM_MOON_ROTATION && defined OVERWORLD_SHADER
#include "/lib/SSBOs.glsl"
#endif
#ifdef OVERWORLD_SHADER
out DATA {
#include "/lib/scene_controller.glsl"
out DATA {
flat vec3 WsunVec;
flat vec3 WrealSunVec;
flat vec3 WmoonVec;
};
#endif
};
uniform float far;
uniform float near;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
uniform vec2 texelSize;
uniform mat4 gbufferModelViewInverse;
uniform sampler2D colortex4;
uniform float sunElevation;
uniform vec3 sunPosition;
uniform vec3 moonPosition;
uniform float sunElevation;
uniform mat4 gbufferModelViewInverse;
uniform int frameCounter;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
uniform float frameTimeCounter;
#include "/lib/Shadow_Params.glsl"
#include "/lib/sky_gradient.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -33,6 +41,11 @@ uniform int framemod8;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_SCALE)*2.0-1.0;
float lightSourceCheck = float(sunElevation > 1e-5)*2.0 - 1.0;
#ifdef OVERWORLD_SHADER
#ifdef SMOOTH_SUN_ROTATION
@@ -40,20 +53,29 @@ void main() {
#else
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
#endif
#if AURORA_LOCATION > 0
#ifdef CUSTOM_MOON_ROTATION
WmoonVec = customMoonVecSSBO;
#else
#ifdef SMOOTH_MOON_ROTATION
WmoonVec = WmoonVecSmooth;
#else
WmoonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
#endif
if(dot(-WmoonVec, WsunVec) < 0.9999) WmoonVec = -WmoonVec;
#ifdef CUSTOM_MOON_ROTATION
#if LIGHTNING_SHADOWS > 0
vec3 moonVec = customMoonVec2SSBO;
#else
vec3 moonVec = customMoonVecSSBO;
#endif
#else
#ifdef SMOOTH_MOON_ROTATION
vec3 moonVec = WmoonVecSmooth;
#else
vec3 moonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
#endif
if(dot(-moonVec, WsunVec) < 0.9999) moonVec = -moonVec;
#endif
#endif
gl_Position = ftransform();
WmoonVec = moonVec;
WrealSunVec = WsunVec;
WsunVec = mix(WmoonVec, WsunVec, clamp(lightSourceCheck,0,1));
#else
WmoonVec = vec3(0.0, 1.0, 0.0);
WsunVec = vec3(0.0, 1.0, 0.0);
WrealSunVec = vec3(0.0, 1.0, 0.0);
#endif
}
File diff suppressed because it is too large. Load diff
+48 -5
View File
@@ -1,5 +1,30 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
#include "/lib/SSBOs.glsl"
#if defined BorderFog || (defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS) > 0
uniform sampler2D colortex4;
#include "/lib/scene_controller.glsl"
#endif
#ifdef OVERWORLD_SHADER
out DATA {
flat vec3 WsunVec;
flat vec3 WmoonVec;
};
#endif
uniform float far;
uniform float near;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
uniform mat4 gbufferModelViewInverse;
uniform vec3 sunPosition;
uniform vec3 moonPosition;
uniform float sunElevation;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -8,9 +33,27 @@
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
#ifdef TAA_UPSCALING
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
#ifdef OVERWORLD_SHADER
#ifdef SMOOTH_SUN_ROTATION
WsunVec = WsunVecSmooth;
#else
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
#endif
#if AURORA_LOCATION > 0
#ifdef CUSTOM_MOON_ROTATION
WmoonVec = customMoonVecSSBO;
#else
#ifdef SMOOTH_MOON_ROTATION
WmoonVec = WmoonVecSmooth;
#else
WmoonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
#endif
if(dot(-WmoonVec, WsunVec) < 0.9999) WmoonVec = -WmoonVec;
#endif
#endif
#endif
gl_Position = ftransform();
}
+65 -449
View File
@@ -1,461 +1,77 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
#include "/lib/SSBOs.glsl"
/*
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; // additional buffer for bloom (composite3->final)
const int colortex7Format = RGBA8; // Final output, transparencies id (gbuffer->composite4)
const int colortex8Format = RGBA16; // Specular Texture, flat normals, vanilla AO
const int colortex9Format = RGBA16; // rain (encoded rg: gbuffers_weather -> composite3), resource pack sky (rgba: gbuffers_skytextured, gbuffers_skybasic -> deferred1), combined depth quarter res (ba: composite -> wherever)
const int colortex10Format = RGBA16F; // cloud history
const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals
const int colortex12Format = RGBA16F; // empty
const int colortex13Format = RGBA16F; // low res VL (composite5->composite15)
const int colortex14Format = RGBA16; // rg = SSAO and SS-SSS. a = skylightmap for translucents.
const int colortex15Format = R11F_G11F_B10F; // PHOTONICS GI
#ifdef VOXY
const int colortex16Format = RGBA16F; // voxy translucent stuff...
#endif
*/
//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;
const bool colortex8Clear = false;
const bool colortex9Clear = true;
const bool colortex10Clear = false;
const bool colortex11Clear = true;
const bool colortex12Clear = false;
const bool colortex13Clear = false;
const bool colortex14Clear = true;
const bool colortex15Clear = true;
#ifdef VOXY
const bool colortex16Clear = true;
#endif
#ifdef SCREENSHOT_MODE
/*
const int colortex5Format = RGBA32F; //TAA buffer (everything)
*/
#else
/*
const int colortex5Format = RGBA16F; //TAA buffer (everything)
*/
#endif
in DATA {
vec2 texcoord;
flat float tempOffsets;
};
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex3;
uniform sampler2D colortex5;
uniform sampler2D colortex6;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform vec2 texelSize;
uniform float frameTimeCounter;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
// Compute 3x3 min max for TAA
uniform float viewHeight;
uniform float viewWidth;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferPreviousModelView;
uniform mat4 gbufferPreviousModelViewInverse;
uniform int hideGUI;
#ifdef DAMAGE_TAKEN_EFFECT
uniform float CriticalDamageTaken;
#endif
#include "/lib/util.glsl"
#include "/lib/projections.glsl"
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
return fract( a * constant1 ) * constant2 ;
}
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);
}
vec4 fp10Dither(vec4 color ,float dither){
const vec3 mantissaBits = vec3(6.,6.,5.);
vec3 exponent = floor(log2(color.rgb));
return vec4(color.rgb + dither*exp2(-mantissaBits)*exp2(exponent), color.a);
}
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));
}
void convertHandDepth(inout float depth) {
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
depth = ndcDepth * 0.5 + 0.5;
}
float convertHandDepth2( float depth) {
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
return ndcDepth * 0.5 + 0.5;
}
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
#define dhVoxyDepthTex dhDepthTex
#endif
#ifdef VOXY
uniform sampler2D vxDepthTexTrans;
#define dhVoxyDepthTex vxDepthTexTrans
#endif
uniform float near;
uniform float far;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
#include "/lib/DistantHorizons_projections.glsl"
float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near));
}
float DH_ld(float dist) {
return (2.0 * dhVoxyNearPlane) / (dhVoxyFarPlane + dhVoxyNearPlane - dist * (dhVoxyFarPlane - dhVoxyNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhVoxyNearPlane/lindepth)-dhVoxyFarPlane-dhVoxyNearPlane)/(dhVoxyFarPlane-dhVoxyNearPlane);
}
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
float invertlinearDepthFast(const in float depth, const in float near, const in float far) {
return ((2.0*near/depth)-far-near)/(far-near);
}
vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) {
#if defined DISTANT_HORIZONS || defined VOXY
mat4 projectionMatrix = depthCheck ? dhVoxyProjectionPrev : gbufferPreviousProjection;
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#else
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#endif
}
vec3 toScreenSpace_DH_special(vec3 POS, bool depthCheck ) {
vec4 viewPos = vec4(0.0);
vec3 feetPlayerPos = vec3(0.0);
vec4 iProjDiag = vec4(0.0);
#if defined DISTANT_HORIZONS || defined VOXY
if (depthCheck) {
iProjDiag = vec4(dhVoxyProjectionInverse[0].x, dhVoxyProjectionInverse[1].y, dhVoxyProjectionInverse[2].zw);
feetPlayerPos = POS * 2.0 - 1.0;
viewPos = iProjDiag * feetPlayerPos.xyzz + dhVoxyProjectionInverse[3];
viewPos.xyz /= viewPos.w;
} else {
#endif
iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
feetPlayerPos = POS * 2.0 - 1.0;
viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3];
viewPos.xyz /= viewPos.w;
#if defined DISTANT_HORIZONS || defined VOXY
}
#endif
return viewPos.xyz;
}
//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 );
#ifndef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
#endif
#ifdef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
#endif
uv = (uv - 0.5)/textureResolution;
return texture(tex, uv);
}
vec2 smoothfilterUV(in vec2 uv)
{
vec2 textureResolution = vec2(viewWidth,viewHeight);
uv = uv*textureResolution + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
#ifndef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
#endif
#ifdef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
#endif
uv = (uv - 0.5)/textureResolution;
return uv;
}
//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 = texture(colorTex, vec2(tc12.x, tc12.y)).rgb;
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
vec4 color = vec4(texture(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
vec4(texture(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
vec4(centerColor, 1.0) * (w12.x * w12.y) +
vec4(texture(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
vec4(texture(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
return color.rgb/color.a;
}
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, texture(depth, texcoord - dv - du).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture(depth, texcoord - dv + du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture(depth, texcoord).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture(depth, texcoord + dv - du).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture(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;
}
vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth, bool depthCheck)
{
vec2 du = vec2(texelSize.x*2., 0.0);
vec2 dv = vec2(0.0, texelSize.y*2.);
vec3 dtl = vec3(texcoord,0.);
vec3 dtr = vec3(texcoord,0.);
vec3 dmc = vec3(texcoord,0.);
vec3 dbl = vec3(texcoord,0.);
vec3 dbr = vec3(texcoord,0.);
dtl += vec3(-texelSize, depthCheck ? texture(dhDepth, texcoord - dv - du).x : texture(depth, texcoord - dv - du).x);
dtr += vec3( texelSize.x, -texelSize.y, depthCheck ? texture(dhDepth, texcoord - dv + du).x : texture(depth, texcoord - dv + du).x);
dmc += vec3( 0.0, 0.0, depthCheck ? texture(dhDepth, texcoord).x : texture(depth, texcoord).x);
dbl += vec3(-texelSize.x, texelSize.y, depthCheck ? texture(dhDepth, texcoord + dv - du).x : texture(depth, texcoord + dv - du).x);
dbr += vec3( texelSize.x, texelSize.y, depthCheck ? texture(dhDepth, texcoord + dv + du).x : texture(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;
}
vec4 computeTAA(vec2 texcoord, bool hand){
vec2 jitter = offsets[framemod8]*texelSize*0.5;
vec2 adjTC = clamp(texcoord*RENDER_SCALE - texelSize*0.5, vec2(0.0), RENDER_SCALE- texelSize*1.5);
vec2 adjTC_noJitter = adjTC + jitter;
// get previous frames position stuff for UV
//use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion
#if defined DISTANT_HORIZONS || defined VOXY
bool depthCheck = texture(depthtex0,adjTC).x >= 1.0;
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhVoxyDepthTex, depthCheck);
vec3 viewPos = toScreenSpace_DH_special(closestToCamera, depthCheck);
#else
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
vec3 viewPos = toScreenSpace(closestToCamera);
#endif
vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * playerPos + gbufferPreviousModelView[3].xyz;
#if defined DISTANT_HORIZONS || defined VOXY
previousPosition = toClipSpace3Prev_DH(previousPosition, depthCheck);
#else
previousPosition = toClipSpace3Prev(previousPosition);
#endif
vec2 velocity = previousPosition.xy - closestToCamera.xy;
previousPosition.xy = texcoord + (hand ? vec2(0.0) : velocity);
// sample current frame, and make sure it is de-jittered
#ifdef TAA_UPSCALING
vec3 currentFrame = smoothfilter(colortex3, adjTC_noJitter).rgb;
#else
vec3 currentFrame = texelFetch(colortex3, ivec2(adjTC_noJitter/texelSize), 0).rgb;
#endif
//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(currentFrame, 1.0);
#ifdef TAA_UPSCALING
// Interpolating neighboorhood clampling boundaries between pixels
vec3 colMax = texture(colortex0, adjTC).rgb;
vec3 colMin = texture(colortex6, adjTC).rgb;
#else
//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 col0 = currentFrame; // can use this because its the center sample.
vec3 col1 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, texelSize.y)).rgb;
vec3 col2 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, -texelSize.y)).rgb;
vec3 col3 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, -texelSize.y)).rgb;
vec3 col4 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, texelSize.y)).rgb;
vec3 col5 = texture(colortex3, adjTC_noJitter + vec2( 0.0, texelSize.y)).rgb;
vec3 col6 = texture(colortex3, adjTC_noJitter + vec2( 0.0, -texelSize.y)).rgb;
vec3 col7 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, 0.0)).rgb;
vec3 col8 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, 0.0)).rgb;
vec3 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8))))))));
vec3 colMin = min(col0,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8))))))));
colMin = 0.5 * (colMin + min(col0,min(col5,min(col6,min(col7,col8)))));
colMax = 0.5 * (colMax + max(col0,max(col5,max(col6,max(col7,col8)))));
#endif
#ifdef DAMAGE_TAKEN_EFFECT
////// when this triggers, use current frame UV to sample history, for a funny trailing effect.
bool criticalDamageTaken = CriticalDamageTaken > 0.01;
if(criticalDamageTaken) previousPosition.xy = texcoord;
#endif
vec3 frameHistory = max(FastCatmulRom(colortex5, previousPosition.xy, vec4(texelSize, 1.0/texelSize), 0.75).xyz,0.0);
vec3 clampedframeHistory = clamp(frameHistory, colMin, colMax);
float blendingFactor = BLEND_FACTOR;
float cameraMovement = length(velocity/texelSize);
blendingFactor = clamp(cameraMovement, blendingFactor, BLEND_FACTOR_DURING_MOVEMENT);
if(hand) blendingFactor = clamp(cameraMovement, blendingFactor, 1.0);
////// Increases blending factor when far from AABB, reduces ghosting
blendingFactor = clamp(blendingFactor + luma(abs(clampedframeHistory - frameHistory)/clampedframeHistory),0.0,1.0);
////// Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
vec3 finalResult = invTonemap(mix(tonemap(clampedframeHistory), tonemap(currentFrame), blendingFactor));
#ifdef DAMAGE_TAKEN_EFFECT
////// when this triggers, do a funny trailing effect.
if(criticalDamageTaken) finalResult = mix(finalResult, frameHistory, sqrt(CriticalDamageTaken)*0.8);
#endif
#ifdef SCREENSHOT_MODE
// when this is on, do "infinite frame accumulation "
if (hideGUI == 0) return vec4(finalResult, 1.0);
vec4 superSampledHistory = texture(colortex5, previousPosition.xy);
vec3 superSampledResult = superSampledHistory.rgb * superSampledHistory.a + currentFrame;
return vec4(superSampledResult/(superSampledHistory.a+1.0), superSampledHistory.a+1.0);
#endif
return vec4(finalResult, 1.0);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* RENDERTARGETS:5 */
#ifdef TAA
vec2 taauTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0);
float dataUnpacked = decodeVec2(texelFetch(colortex1,ivec2(gl_FragCoord.xy*RENDER_SCALE),0).w).y;
bool hand = abs(dataUnpacked-0.75) < 0.01 && texture(depthtex1,taauTC).x < 1.0;
vec4 color = computeTAA(texcoord, hand);
/* RENDERTARGETS:0,6 */
vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight);
vec2 jitter = offsets[framemod8]*texelSize*0.5;
ivec2 center = ivec2(clamp(gl_FragCoord.xy*texelSize, screenEdges, 1.0-screenEdges)/texelSize);
#ifdef SCREENSHOT_MODE
gl_FragData[0] = clamp(color, 0.0, 65000.0);
#else
gl_FragData[0] = clamp(fp10Dither(color, triangularize(interleaved_gradientNoise())), 0.0, 65000.0);
#endif
#else
vec3 color = clamp(fp10Dither(vec4(texture(colortex3,texcoord).rgb,1.0), triangularize(interleaved_gradientNoise())).rgb,0.0,65000.);
gl_FragData[0].rgb = color;
#endif
}
// vec3 current = texelFetch(colortex3, center, 0).rgb;
// vec3 cMin = current;
// vec3 cMax = current;
// current = texelFetch(colortex3, center + ivec2(-1, -1), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(-1, 0), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(-1, 1), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(0, -1), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(0, 1), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(1, -1), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(colortex3, center + ivec2(1, 0), 0).rgb;
// cMin = min(cMin, current);
// cMax = max(cMax, current);
// current = texelFetch(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;
vec3 col0 = texelFetch(colortex3, center, 0).rgb;
vec3 col1 = texelFetch(colortex3, center + ivec2(1, 1), 0).rgb;
vec3 col2 = texelFetch(colortex3, center + ivec2(1, -1), 0).rgb;
vec3 col3 = texelFetch(colortex3, center + ivec2(-1, -1), 0).rgb;
vec3 col4 = texelFetch(colortex3, center + ivec2(-1, 1), 0).rgb;
vec3 col5 = texelFetch(colortex3, center + ivec2(0, 1), 0).rgb;
vec3 col6 = texelFetch(colortex3, center + ivec2(0, -1), 0).rgb;
vec3 col7 = texelFetch(colortex3, center + ivec2(-1, 0), 0).rgb;
vec3 col8 = texelFetch(colortex3, center + ivec2(1, 0), 0).rgb;
vec3 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8))))))));
vec3 colMin = min(col0,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8))))))));
vec3 colMax5 = max(col0,max(col5,max(col6,max(col7,col8))));
vec3 colMin5 = min(col0,min(col5,min(col6,min(col7,col8))));
colMin = 0.5 * (colMin + colMin5);
colMax = 0.5 * (colMax + colMax5);
gl_FragData[0].rgb = colMax;
gl_FragData[1].rgb = colMin;
}
+7 -17
View File
@@ -1,25 +1,15 @@
#include "/lib/util.glsl"
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
out DATA {
vec2 texcoord;
flat float tempOffsets;
};
uniform sampler2D colortex4;
uniform int frameCounter;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
tempOffsets = HaltonSeq2(frameCounter%10000);
#ifdef TAA_UPSCALING
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
#endif
+437 -32
View File
@@ -1,12 +1,101 @@
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
uniform sampler2D depthtex0;
#include "/lib/SSBOs.glsl"
/*
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; // additional buffer for bloom (composite3->final)
const int colortex7Format = RGBA8; // Final output, transparencies id (gbuffer->composite4)
const int colortex8Format = RGBA16; // Specular Texture, flat normals, vanilla AO
const int colortex9Format = RGBA16; // rain (encoded rg: gbuffers_weather -> composite3), resource pack sky (rgba: gbuffers_skytextured, gbuffers_skybasic -> deferred1), combined depth quarter res (ba: composite -> wherever)
const int colortex10Format = RGBA16F; // cloud history
const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals
const int colortex12Format = RGBA16F; // reflections
const int colortex13Format = RGBA16F; // low res VL (composite5->composite15)
const int colortex14Format = RGBA16; // rg = SSAO and SS-SSS. z = skylightmap for translucents.
const int colortex15Format = R11F_G11F_B10F; // PHOTONICS GI
#ifdef VOXY
const int colortex16Format = RGBA16F; // voxy translucent stuff...
#endif
*/
//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;
const bool colortex8Clear = false;
const bool colortex9Clear = true;
const bool colortex10Clear = false;
const bool colortex11Clear = true;
const bool colortex12Clear = false;
const bool colortex13Clear = false;
const bool colortex14Clear = true;
const bool colortex15Clear = true;
const bool colortex17Clear = false;
const bool colortex18Clear = false;
#ifdef VOXY
const bool colortex16Clear = true;
#endif
#ifdef SCREENSHOT_MODE
/*
const int colortex5Format = RGBA32F; //TAA buffer (everything)
*/
#else
/*
const int colortex5Format = RGBA16F; //TAA buffer (everything)
*/
#endif
in DATA {
vec2 texcoord;
flat float tempOffsets;
};
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex3;
uniform sampler2D colortex5;
uniform sampler2D colortex6;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform vec2 texelSize;
uniform float viewWidth;
uniform float frameTimeCounter;
uniform float viewHeight;
uniform float viewWidth;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferPreviousModelView;
uniform mat4 gbufferPreviousModelViewInverse;
uniform int hideGUI;
#ifdef DAMAGE_TAKEN_EFFECT
uniform float CriticalDamageTaken;
#endif
#include "/lib/util.glsl"
#include "/lib/projections.glsl"
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
@@ -14,45 +103,361 @@ vec2 decodeVec2(float a){
return fract( a * constant1 ) * constant2 ;
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
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);
}
vec4 fp10Dither(vec4 color ,float dither){
const vec3 mantissaBits = vec3(6.,6.,5.);
vec3 exponent = floor(log2(color.rgb));
return vec4(color.rgb + dither*exp2(-mantissaBits)*exp2(exponent), color.a);
}
void main() {
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));
}
void convertHandDepth(inout float depth) {
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
depth = ndcDepth * 0.5 + 0.5;
}
float convertHandDepth2( float depth) {
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
return ndcDepth * 0.5 + 0.5;
}
/* RENDERTARGETS:3 */
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.0*resScale*texelSize;
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
#define dhVoxyDepthTex dhDepthTex
#endif
// vec2 texcoord = (gl_FragCoord.xy*2.0*resScale*texelSize) * RENDER_SCALE;
#ifdef VOXY
uniform sampler2D vxDepthTexTrans;
#define dhVoxyDepthTex vxDepthTexTrans
#endif
// bool hand = abs(decodeVec2(texture(colortex1,texcoord).w).y-0.75) < 0.01 && texture(depthtex0,texcoord).x < 1.0;
uniform float near;
uniform float far;
uniform float dhVoxyFarPlane;
uniform float dhVoxyNearPlane;
//0.5
gl_FragData[0] = texture(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
#include "/lib/DistantHorizons_projections.glsl"
//0.25
gl_FragData[0] += texture(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(0.0,-texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2.*0.125;
//0.125
gl_FragData[0] += texture(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near));
}
float DH_ld(float dist) {
return (2.0 * dhVoxyNearPlane) / (dhVoxyFarPlane + dhVoxyNearPlane - dist * (dhVoxyFarPlane - dhVoxyNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhVoxyNearPlane/lindepth)-dhVoxyFarPlane-dhVoxyNearPlane)/(dhVoxyFarPlane-dhVoxyNearPlane);
}
//0.125
gl_FragData[0] += texture(colortex5,quarterResTC)*0.125;
float linearizeDepthFast(const in float depth, const in float near, const in float far) {
return (near * far) / (depth * (near - far) + far);
}
float invertlinearDepthFast(const in float depth, const in float near, const in float far) {
return ((2.0*near/depth)-far-near)/(far-near);
}
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);
vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) {
#if defined DISTANT_HORIZONS || defined VOXY
mat4 projectionMatrix = depthCheck ? dhVoxyProjectionPrev : gbufferPreviousProjection;
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#else
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#endif
}
vec3 toScreenSpace_DH_special(vec3 POS, bool depthCheck ) {
vec4 viewPos = vec4(0.0);
vec3 feetPlayerPos = vec3(0.0);
vec4 iProjDiag = vec4(0.0);
#if defined DISTANT_HORIZONS || defined VOXY
if (depthCheck) {
iProjDiag = vec4(dhVoxyProjectionInverse[0].x, dhVoxyProjectionInverse[1].y, dhVoxyProjectionInverse[2].zw);
feetPlayerPos = POS * 2.0 - 1.0;
viewPos = iProjDiag * feetPlayerPos.xyzz + dhVoxyProjectionInverse[3];
viewPos.xyz /= viewPos.w;
} else {
#endif
iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
feetPlayerPos = POS * 2.0 - 1.0;
viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3];
viewPos.xyz /= viewPos.w;
#if defined DISTANT_HORIZONS || defined VOXY
}
#endif
return viewPos.xyz;
}
//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 );
#ifndef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
#endif
#ifdef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
#endif
uv = (uv - 0.5)/textureResolution;
return texture(tex, uv);
}
vec2 smoothfilterUV(in vec2 uv)
{
vec2 textureResolution = vec2(viewWidth,viewHeight);
uv = uv*textureResolution + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
#ifndef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
#endif
#ifdef SMOOTHESTSTEP_INTERPOLATION
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
#endif
uv = (uv - 0.5)/textureResolution;
return uv;
}
//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 = texture(colorTex, vec2(tc12.x, tc12.y)).rgb;
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
vec4 color = vec4(texture(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
vec4(texture(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
vec4(centerColor, 1.0) * (w12.x * w12.y) +
vec4(texture(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
vec4(texture(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
return color.rgb/color.a;
}
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, texture(depth, texcoord - dv - du).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture(depth, texcoord - dv + du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture(depth, texcoord).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture(depth, texcoord + dv - du).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture(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;
}
vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth, bool depthCheck)
{
vec2 du = vec2(texelSize.x*2., 0.0);
vec2 dv = vec2(0.0, texelSize.y*2.);
vec3 dtl = vec3(texcoord,0.);
vec3 dtr = vec3(texcoord,0.);
vec3 dmc = vec3(texcoord,0.);
vec3 dbl = vec3(texcoord,0.);
vec3 dbr = vec3(texcoord,0.);
dtl += vec3(-texelSize, depthCheck ? texture(dhDepth, texcoord - dv - du).x : texture(depth, texcoord - dv - du).x);
dtr += vec3( texelSize.x, -texelSize.y, depthCheck ? texture(dhDepth, texcoord - dv + du).x : texture(depth, texcoord - dv + du).x);
dmc += vec3( 0.0, 0.0, depthCheck ? texture(dhDepth, texcoord).x : texture(depth, texcoord).x);
dbl += vec3(-texelSize.x, texelSize.y, depthCheck ? texture(dhDepth, texcoord + dv - du).x : texture(depth, texcoord + dv - du).x);
dbr += vec3( texelSize.x, texelSize.y, depthCheck ? texture(dhDepth, texcoord + dv + du).x : texture(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;
}
vec4 computeTAA(vec2 texcoord, bool hand){
vec2 jitter = offsets[framemod8]*texelSize*0.5;
vec2 adjTC = clamp(texcoord*RENDER_SCALE - texelSize*0.5, vec2(0.0), RENDER_SCALE- texelSize*1.5);
vec2 adjTC_noJitter = adjTC + jitter;
// get previous frames position stuff for UV
//use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion
#if defined DISTANT_HORIZONS || defined VOXY
bool depthCheck = texture(depthtex0,adjTC).x >= 1.0;
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhVoxyDepthTex, depthCheck);
vec3 viewPos = toScreenSpace_DH_special(closestToCamera, depthCheck);
#else
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
vec3 viewPos = toScreenSpace(closestToCamera);
#endif
vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * playerPos + gbufferPreviousModelView[3].xyz;
#if defined DISTANT_HORIZONS || defined VOXY
previousPosition = toClipSpace3Prev_DH(previousPosition, depthCheck);
#else
previousPosition = toClipSpace3Prev(previousPosition);
#endif
vec2 velocity = previousPosition.xy - closestToCamera.xy;
previousPosition.xy = texcoord + (hand ? vec2(0.0) : velocity);
// sample current frame, and make sure it is de-jittered
#ifdef TAA_UPSCALING
vec3 currentFrame = smoothfilter(colortex3, adjTC_noJitter).rgb;
#else
vec3 currentFrame = texelFetch(colortex3, ivec2(adjTC_noJitter/texelSize), 0).rgb;
#endif
//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(currentFrame, 1.0);
#ifdef TAA_UPSCALING
// Interpolating neighboorhood clampling boundaries between pixels
vec3 colMax = texture(colortex0, adjTC).rgb;
vec3 colMin = texture(colortex6, adjTC).rgb;
#else
//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 col0 = currentFrame; // can use this because its the center sample.
vec3 col1 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, texelSize.y)).rgb;
vec3 col2 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, -texelSize.y)).rgb;
vec3 col3 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, -texelSize.y)).rgb;
vec3 col4 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, texelSize.y)).rgb;
vec3 col5 = texture(colortex3, adjTC_noJitter + vec2( 0.0, texelSize.y)).rgb;
vec3 col6 = texture(colortex3, adjTC_noJitter + vec2( 0.0, -texelSize.y)).rgb;
vec3 col7 = texture(colortex3, adjTC_noJitter + vec2(-texelSize.x, 0.0)).rgb;
vec3 col8 = texture(colortex3, adjTC_noJitter + vec2( texelSize.x, 0.0)).rgb;
vec3 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8))))))));
vec3 colMin = min(col0,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8))))))));
colMin = 0.5 * (colMin + min(col0,min(col5,min(col6,min(col7,col8)))));
colMax = 0.5 * (colMax + max(col0,max(col5,max(col6,max(col7,col8)))));
#endif
#ifdef DAMAGE_TAKEN_EFFECT
////// when this triggers, use current frame UV to sample history, for a funny trailing effect.
bool criticalDamageTaken = CriticalDamageTaken > 0.01;
if(criticalDamageTaken) previousPosition.xy = texcoord;
#endif
vec3 frameHistory = max(FastCatmulRom(colortex5, previousPosition.xy, vec4(texelSize, 1.0/texelSize), 0.75).xyz,0.0);
vec3 clampedframeHistory = clamp(frameHistory, colMin, colMax);
float blendingFactor = BLEND_FACTOR;
float cameraMovement = length(velocity/texelSize);
blendingFactor = clamp(cameraMovement, blendingFactor, BLEND_FACTOR_DURING_MOVEMENT);
if(hand) blendingFactor = clamp(cameraMovement, blendingFactor, 1.0);
////// Increases blending factor when far from AABB, reduces ghosting
blendingFactor = clamp(blendingFactor + luma(abs(clampedframeHistory - frameHistory)/clampedframeHistory),0.0,1.0);
////// Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
vec3 finalResult = invTonemap(mix(tonemap(clampedframeHistory), tonemap(currentFrame), blendingFactor));
#ifdef DAMAGE_TAKEN_EFFECT
////// when this triggers, do a funny trailing effect.
if(criticalDamageTaken) finalResult = mix(finalResult, frameHistory, sqrt(CriticalDamageTaken)*0.8);
#endif
#ifdef SCREENSHOT_MODE
// when this is on, do "infinite frame accumulation "
if (hideGUI == 0) return vec4(finalResult, 1.0);
vec4 superSampledHistory = texture(colortex5, previousPosition.xy);
vec3 superSampledResult = superSampledHistory.rgb * superSampledHistory.a + currentFrame;
return vec4(superSampledResult/(superSampledHistory.a+1.0), superSampledHistory.a+1.0);
#endif
return vec4(finalResult, 1.0);
}
void main() {
/* RENDERTARGETS:5 */
#ifdef TAA
vec2 taauTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0);
float dataUnpacked = decodeVec2(texelFetch(colortex1,ivec2(gl_FragCoord.xy*RENDER_SCALE),0).w).y;
bool hand = abs(dataUnpacked-0.75) < 0.01 && texture(depthtex1,taauTC).x < 1.0;
vec4 color = computeTAA(texcoord, hand);
#ifdef SCREENSHOT_MODE
gl_FragData[0] = clamp(color, 0.0, 65000.0);
#else
gl_FragData[0] = clamp(fp10Dither(color, triangularize(interleaved_gradientNoise())), 0.0, 65000.0);
#endif
#else
vec3 color = clamp(fp10Dither(vec4(texture(colortex3,texcoord).rgb,1.0), triangularize(interleaved_gradientNoise())).rgb,0.0,65000.);
gl_FragData[0].rgb = color;
#endif
}
+22 -11
View File
@@ -1,15 +1,26 @@
uniform float viewWidth;
uniform float viewHeight;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
#include "/lib/util.glsl"
#include "/lib/res_params.glsl"
out DATA {
vec2 texcoord;
flat float tempOffsets;
};
uniform sampler2D colortex4;
uniform int frameCounter;
uniform int framemod8;
#include "/lib/TAA_jitter.glsl"
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/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
texcoord = gl_MultiTexCoord0.xy;
tempOffsets = HaltonSeq2(frameCounter%10000);
#ifdef TAA_UPSCALING
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
#endif
}
+34 -18
View File
@@ -1,7 +1,19 @@
uniform sampler2D colortex3;
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
uniform sampler2D depthtex0;
uniform sampler2D colortex1;
uniform sampler2D colortex5;
uniform vec2 texelSize;
uniform float viewWidth;
uniform float viewHeight;
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
return fract( a * constant1 ) * constant2 ;
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -10,33 +22,37 @@ uniform float viewHeight;
void main() {
/* RENDERTARGETS:6 */
/* RENDERTARGETS:3 */
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.*texelSize;
vec2 quarterResTC = gl_FragCoord.xy*2.0*resScale*texelSize;
// vec2 texcoord = (gl_FragCoord.xy*2.0*resScale*texelSize) * RENDER_SCALE;
// bool hand = abs(decodeVec2(texture(colortex1,texcoord).w).y-0.75) < 0.01 && texture(depthtex0,texcoord).x < 1.0;
//0.5
gl_FragData[0] = texture(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
gl_FragData[0] = texture(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
//0.25
gl_FragData[0] += texture(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(0.0,-texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(0.0,-texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2.*0.125;
//0.125
gl_FragData[0] += texture(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
//0.125
gl_FragData[0] += texture(colortex3,quarterResTC)*0.125;
gl_FragData[0] += texture(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);
}
+1 -1
View File
@@ -11,5 +11,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/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
}
+23 -37
View File
@@ -1,21 +1,7 @@
uniform sampler2D colortex6;
uniform sampler2D colortex3;
uniform vec2 texelSize;
uniform float viewWidth;
uniform float viewHeight;
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
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 = exp(-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(texture(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.x > minTC && spCoord.x < maxTC);
}
return tot.rgb/max(1.0,tot.a);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -23,34 +9,34 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* RENDERTARGETS:6 */
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.*texelSize;
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);
//0.5
gl_FragData[0] = texture(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5;
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);
//0.25
gl_FragData[0] += texture(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(0.0,-texelSize.y))/2.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2.*0.125;
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);
//0.125
gl_FragData[0] += texture(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125;
gl_FragData[0] += texture(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125;
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);
//0.125
gl_FragData[0] += texture(colortex3,quarterResTC)*0.125;
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
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);
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].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
}
+4 -6
View File
@@ -1,6 +1,5 @@
uniform float viewWidth;
uniform float viewHeight;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -8,10 +7,9 @@ uniform float viewHeight;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0));
//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-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;
//*0.51 to avoid errors when sampling outside since clearing is disabled
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26/clampedRes*vec2(1920.0,1080.)*2.0-1.0;
}
+18 -17
View File
@@ -5,14 +5,15 @@ uniform float viewHeight;
vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.));
vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
vec4 tot = vec4(0.);
float maxTC = 0.25*resScale.y;
float maxTC = 0.25*resScale.x;
float minTC = 0.;
for (int i = -maxIT;i<maxIT+1;i++){
float weight = exp(-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(texture(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.y > minTC && spCoord.y < maxTC);
tot += vec4(texture(colortex6,spCoord).rgb,1.0)*weight*float(spCoord.x > minTC && spCoord.x < maxTC);
}
return tot.rgb/max(1.0,tot.a);
return tot.rgb/max(1.0,tot.a);
}
//////////////////////////////VOID MAIN//////////////////////////////
@@ -23,33 +24,33 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
void main() {
/* RENDERTARGETS:6 */
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
vec2 gaussDir = vec2(0.0,1.0);
vec2 gaussDir = vec2(1.0,0.0);
gl_FragData[0].rgb = vec3(0.0);
vec2 tc2 = texcoord*vec2(2.0,1.);
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(texcoord/vec2(2.0,4.0),gaussDir,0.16,0);
gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0);
vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0;
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(texcoord/vec2(2.0,2.0),gaussDir,0.16,3);
gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3);
vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0;
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(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6);
gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6);
vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.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(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12);
gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12);
vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0;
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(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30);
gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28);
vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.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(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60);
gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60);
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
}
+2 -3
View File
@@ -150,14 +150,13 @@ float invLinZ (float lindepth){
// uniform sampler2D colortex4;
// uniform sampler2D colortex12;
// const bool shadowHardwareFiltering = true;
uniform sampler2DShadow shadow;
uniform sampler2DShadow shadowtex0HW;
// #undef TRANSLUCENT_COLORED_SHADOWS
#ifdef TRANSLUCENT_COLORED_SHADOWS
uniform sampler2D shadowcolor0;
uniform sampler2DShadow shadowtex0;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex1HW;
#endif
// #define TEST
+130 -130
View File
@@ -36,7 +36,6 @@ in DATA {
#endif
vec3 block_normal;
flat int blockID;
} data_in;
const float mincoord = 1.0/4096.0;
@@ -354,11 +353,6 @@ void main() {
float saveDepth = 0.0;
if(!ifPOM) adjustedTexCoord = data_in.lmtexcoord.xy;
float opaqueMasks = 1.0;
// if(data_in.blockID == BLOCK_GROUND_WAVING_VERTICAL || data_in.blockID == BLOCK_GRASS_SHORT || data_in.blockID == BLOCK_GRASS_TALL_LOWER || data_in.blockID == BLOCK_GRASS_TALL_UPPER ) opaqueMasks = 0.60;
// else if(data_in.blockID == BLOCK_AIR_WAVING) opaqueMasks = 0.55;
//////////////////////////////// ////////////////////////////////
@@ -387,6 +381,7 @@ void main() {
if (!ray.result_hit) discard;
if (ray.result_normal == vec3(0.0)) ray.result_normal = data_in.block_normal;
int blockID = result_block_id;
playerpos = ray.result_position + world_offset - cameraPosition;
vec3 viewPos = (gbufferModelView * vec4(playerpos, 1.0f)).xyz;
@@ -407,35 +402,40 @@ void main() {
Albedo.rgb = vec3(0.5);
#endif
float opaqueMasks = 1.0;
if(blockID == BLOCK_GROUND_WAVING_VERTICAL || blockID == BLOCK_GRASS_SHORT || blockID == BLOCK_GRASS_TALL_LOWER || blockID == BLOCK_GRASS_TALL_UPPER ) opaqueMasks = 0.60;
else if(blockID == BLOCK_AIR_WAVING) opaqueMasks = 0.55;
// #ifdef AEROCHROME_MODE
// float gray = dot(Albedo.rgb, vec3(0.2, 1.0, 0.07));
// if (
// data_in.blockID == BLOCK_AMETHYST_BUD_MEDIUM || data_in.blockID == BLOCK_AMETHYST_BUD_LARGE || data_in.blockID == BLOCK_AMETHYST_CLUSTER
// || data_in.blockID == BLOCK_SSS_STRONG || data_in.blockID == BLOCK_SSS_STRONG3 || data_in.blockID == BLOCK_SSS_WEAK || data_in.blockID == BLOCK_CACTUS
// || data_in.blockID == BLOCK_CELESTIUM || data_in.blockID == BLOCK_SNOW_LAYERS
// || data_in.blockID >= 10 && data_in.blockID < 80
// ) {
// // IR Reflective (Pink-red)
// Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7);
// }
// else if(data_in.blockID == BLOCK_GRASS) {
// // Special handling for grass block
// float strength = 1.0 - Color.b;
// Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength);
// }
// #ifdef AEROCHROME_WOOL_ENABLED
// else if (data_in.blockID == BLOCK_SSS_WEAK_2 || data_in.blockID == BLOCK_CARPET) {
// // Wool
// Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3);
// }
// #endif
// else if(data_in.blockID == BLOCK_WATER || (data_in.blockID >= 300 && data_in.blockID < 400))
// {
// // IR Absorbsive? Dark.
// Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5);
// }
// #endif
#ifdef AEROCHROME_MODE
float gray = dot(Albedo.rgb, vec3(0.2, 1.0, 0.07));
if (
blockID == BLOCK_AMETHYST_BUD_MEDIUM || blockID == BLOCK_AMETHYST_BUD_LARGE || blockID == BLOCK_AMETHYST_CLUSTER
|| blockID == BLOCK_SSS_STRONG || blockID == BLOCK_SSS_STRONG3 || blockID == BLOCK_SSS_WEAK || blockID == BLOCK_CACTUS
|| blockID == BLOCK_CELESTIUM || blockID == BLOCK_SNOW_LAYERS
|| blockID >= 10 && blockID < 80
) {
// IR Reflective (Pink-red)
Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7);
}
else if(blockID == BLOCK_GRASS) {
// Special handling for grass block
float strength = 1.0 - Color.b;
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength);
}
#ifdef AEROCHROME_WOOL_ENABLED
else if (blockID == BLOCK_SSS_WEAK_2 || blockID == BLOCK_CARPET) {
// Wool
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3);
}
#endif
else if(blockID == BLOCK_WATER || (blockID >= 300 && blockID < 400))
{
// IR Absorbsive? Dark.
Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5);
}
#endif
Albedo.a = opaqueMasks;
@@ -446,96 +446,96 @@ void main() {
normal = viewToWorld(normal);
float SSSAMOUNT = 0.0;
// #if (SSS_TYPE == 1 || SSS_TYPE == 2) && !defined HAND
// #ifdef ENTITIES
// #ifdef MOB_SSS
// /////// ----- SSS ON MOBS----- ///////
// // strong
// if(data_in.blockID == ENTITY_SSS_MEDIUM) SSSAMOUNT = 0.75;
//
// // medium
//
// // low
// else if(data_in.blockID == ENTITY_SSS_WEAK || data_in.blockID == ENTITY_PLAYER || data_in.blockID == ENTITY_CURRENT_PLAYER) SSSAMOUNT = 0.4;
// #endif
// #else
// #if defined SHADER_GRASS && !defined CUTOUT
// if (ShaderGrass) SSSAMOUNT = 0.65;
// else
// #endif
//
// /////// ----- SSS ON BLOCKS ----- ///////
// // strong
// if (
// data_in.blockID == BLOCK_SSS_STRONG || data_in.blockID == BLOCK_SSS_STRONG3 || data_in.blockID == BLOCK_AIR_WAVING || data_in.blockID == BLOCK_SSS_STRONG_2
// ) {
// SSSAMOUNT = 1.0;
// }
// // medium
// else if (
// data_in.blockID == BLOCK_GROUND_WAVING || data_in.blockID == BLOCK_GROUND_WAVING_VERTICAL ||
// data_in.blockID == BLOCK_GRASS_SHORT || data_in.blockID == BLOCK_GRASS_TALL_UPPER || data_in.blockID == BLOCK_GRASS_TALL_LOWER ||
// data_in.blockID == BLOCK_SSS_WEAK || data_in.blockID == BLOCK_CACTUS || data_in.blockID == BLOCK_SSS_WEAK_2 ||
// data_in.blockID == BLOCK_CELESTIUM || (data_in.blockID >= 269 && data_in.blockID <= 274) || data_in.blockID == BLOCK_SNOW_LAYERS || data_in.blockID == BLOCK_CARPET ||
// data_in.blockID == BLOCK_AMETHYST_BUD_MEDIUM || data_in.blockID == BLOCK_AMETHYST_BUD_LARGE || data_in.blockID == BLOCK_AMETHYST_CLUSTER ||
// data_in.blockID == BLOCK_BAMBOO || data_in.blockID == BLOCK_SAPLING || (data_in.blockID >= BLOCK_VINE_NORTH && data_in.blockID <= BLOCK_VINE_UP) || data_in.blockID == BLOCK_VINE_OTHER
// #ifdef MISC_BLOCK_SSS
// || data_in.blockID == BLOCK_SSS_WEIRD || data_in.blockID == BLOCK_GRASS
// #endif
// ) {
// SSSAMOUNT = 0.5;
// }
// #endif
//
// #ifdef BLOCKENTITIES
// /////// ----- SSS ON BLOCK ENTITIES----- ///////
// // strong
//
// // medium
// if(data_in.blockID == BLOCK_SSS_WEAK_3) SSSAMOUNT = 0.4;
//
// // low
//
// #endif
// #endif
#if (SSS_TYPE == 1 || SSS_TYPE == 2) && !defined HAND
#ifdef ENTITIES
#ifdef MOB_SSS
/////// ----- SSS ON MOBS----- ///////
// strong
if(blockID == ENTITY_SSS_MEDIUM) SSSAMOUNT = 0.75;
// medium
// low
else if(blockID == ENTITY_SSS_WEAK || blockID == ENTITY_PLAYER || blockID == ENTITY_CURRENT_PLAYER) SSSAMOUNT = 0.4;
#endif
#else
#if defined SHADER_GRASS && !defined CUTOUT
if (ShaderGrass) SSSAMOUNT = 0.65;
else
#endif
/////// ----- SSS ON BLOCKS ----- ///////
// strong
if (
blockID == BLOCK_SSS_STRONG || blockID == BLOCK_SSS_STRONG3 || blockID == BLOCK_AIR_WAVING || blockID == BLOCK_SSS_STRONG_2
) {
SSSAMOUNT = 1.0;
}
// medium
else if (
blockID == BLOCK_GROUND_WAVING || blockID == BLOCK_GROUND_WAVING_VERTICAL ||
blockID == BLOCK_GRASS_SHORT || blockID == BLOCK_GRASS_TALL_UPPER || blockID == BLOCK_GRASS_TALL_LOWER ||
blockID == BLOCK_SSS_WEAK || blockID == BLOCK_CACTUS || blockID == BLOCK_SSS_WEAK_2 ||
blockID == BLOCK_CELESTIUM || (blockID >= 269 && blockID <= 274) || blockID == BLOCK_SNOW_LAYERS || blockID == BLOCK_CARPET ||
blockID == BLOCK_AMETHYST_BUD_MEDIUM || blockID == BLOCK_AMETHYST_BUD_LARGE || blockID == BLOCK_AMETHYST_CLUSTER ||
blockID == BLOCK_BAMBOO || blockID == BLOCK_SAPLING || blockID == BLOCK_VINE || blockID == BLOCK_VINE_OTHER
#ifdef MISC_BLOCK_SSS
|| blockID == BLOCK_SSS_WEIRD || blockID == BLOCK_GRASS
#endif
) {
SSSAMOUNT = 0.5;
}
#endif
#ifdef BLOCKENTITIES
/////// ----- SSS ON BLOCK ENTITIES----- ///////
// strong
// medium
if(blockID == BLOCK_SSS_WEAK_3) SSSAMOUNT = 0.4;
// low
#endif
#endif
float EMISSIVE = 0.0;
// #if EMISSIVE_TYPE == 1 || EMISSIVE_TYPE == 2
// /////// ----- EMISSIVE STUFF ----- ///////
//
// // if(vNameTags > 0) EMISSIVE = 0.9;
//
// // normal block lightsources
// if(data_in.blockID >= 100 && data_in.blockID < 282) {
// EMISSIVE = 0.5;
//
// if(data_in.blockID == 266 || (data_in.blockID >= 276 && data_in.blockID <= 281)) EMISSIVE = 0.2; // sculk stuff
//
// else if(data_in.blockID == 195) EMISSIVE = 2.3; // glow lichen
//
// else if(data_in.blockID == 185) EMISSIVE = 1.5; // crying obsidian
//
// else if(data_in.blockID == 105) EMISSIVE = 2.0; // brewing stand
//
// else if(data_in.blockID == 236) EMISSIVE = 1.0; // respawn anchor
//
// else if(data_in.blockID == 101) EMISSIVE = 0.7; // large amethyst bud
//
// else if(data_in.blockID == 103) EMISSIVE = 1.0; // amethyst cluster
//
// else if(data_in.blockID == 244) EMISSIVE = 1.5; // soul fire
// }
//
// #if EMISSIVE_ORES > 0
// if(data_in.blockID == 502) {
// EMISSIVE = EMISSIVE_ORES_STRENGTH;
//
// #ifndef HARDCODED_EMISSIVES_APPROX
// EMISSIVE *= getEmission(Albedo.rgb);
// #endif
// }
// #endif
// #endif
#if EMISSIVE_TYPE == 1 || EMISSIVE_TYPE == 2
/////// ----- EMISSIVE STUFF ----- ///////
// if(vNameTags > 0) EMISSIVE = 0.9;
// normal block lightsources
if(blockID >= 100 && blockID < 282) {
EMISSIVE = 0.5;
if(blockID == 266 || (blockID >= 276 && blockID <= 281)) EMISSIVE = 0.2; // sculk stuff
else if(blockID == 195) EMISSIVE = 2.3; // glow lichen
else if(blockID == 185) EMISSIVE = 1.5; // crying obsidian
else if(blockID == 105) EMISSIVE = 2.0; // brewing stand
else if(blockID == 236) EMISSIVE = 1.0; // respawn anchor
else if(blockID == 101) EMISSIVE = 0.7; // large amethyst bud
else if(blockID == 103) EMISSIVE = 1.0; // amethyst cluster
else if(blockID == 244) EMISSIVE = 1.5; // soul fire
}
#if EMISSIVE_ORES > 0
if(blockID == 502) {
EMISSIVE = EMISSIVE_ORES_STRENGTH;
#ifndef HARDCODED_EMISSIVES_APPROX
EMISSIVE *= getEmission(Albedo.rgb);
#endif
}
#endif
#endif
vec4 SpecularTex = vec4(0.0);
@@ -545,13 +545,13 @@ void main() {
OutSpecular = vec4(0.0,0.0,0.0,0.0);
OutSpecular.rg = SpecularTex.rg;
// #if EMISSIVE_ORES > 1 && EMISSIVE_TYPE > 1
// if(data_in.blockID == 502) {
// SpecularTex.a = EMISSIVE_ORES_STRENGTH;
//
// SpecularTex.a *= getEmission(Albedo.rgb);
// }
// #endif
#if EMISSIVE_ORES > 1 && EMISSIVE_TYPE > 1
if(blockID == 502) {
SpecularTex.a = EMISSIVE_ORES_STRENGTH;
SpecularTex.a *= getEmission(Albedo.rgb);
}
#endif
#if EMISSIVE_TYPE == 2
@@ -559,7 +559,7 @@ void main() {
#endif
// #ifdef MIRROR_IRON
// if(data_in.blockID == 504 || currentRenderedItemId == 504) {
// if(blockID == 504 || currentRenderedItemId == 504) {
// OutSpecular.rg = vec2(1.0, 1.0);
// Albedo.rgb = vec3(1.0);
// }
-2
View File
@@ -34,7 +34,6 @@ out DATA {
#endif
vec3 block_normal;
flat int blockID;
} data_out;
#ifdef MC_NORMAL_MAP
@@ -224,7 +223,6 @@ void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
data_out.blockID = int(mc_Entity.x);
/////// ----- COLOR STUFF ----- ///////
data_out.color = gl_Color;
+36 -2
View File
@@ -1,4 +1,5 @@
#include "/lib/settings.glsl"
#include "/lib/SSBOs.glsl"
in vec3 worldPos;
in vec3 cageNormal;
@@ -22,7 +23,13 @@ void main() {
#else
RayJob ray = RayJob(vec3(0), vec3(0), vec3(0), vec3(0), vec3(0), false);
ray.origin = worldPos + cameraPosition - world_offset - 0.01f * cageNormal;
ray.direction = mat3(shadowModelViewInverse) * vec3(0.0f, 0.0f, -1.0f);
#ifdef CUSTOM_MOON_ROTATION
ray.direction = mat3(customShadowMatrixInverseSSBO) * vec3(0.0f, 0.0f, -1.0f);
#else
ray.direction = mat3(shadowModelViewInverse) * vec3(0.0f, 0.0f, -1.0f);
#endif
ray_constraint = ivec3(ray.origin);
trace_ray(ray);
@@ -32,6 +39,33 @@ void main() {
vec4 shadowColor = vec4(ray.result_color, 1.0f);
vec3 playerpos = ray.result_position - (cameraPosition - world_offset);
#ifdef OVERWORLD_SHADER
#ifdef CUSTOM_MOON_ROTATION
vec3 viewPos = mat3(customShadowMatrixSSBO) * playerpos + customShadowMatrixSSBO[3].xyz;
#else
vec3 viewPos = mat3(shadowModelView) * playerpos + shadowModelView[3].xyz;
#endif
vec4 ndc4 = shadowProjection * vec4(viewPos, 1.0f);
ndc4.z /= 6.0;
vec3 screenPos = ndc4.xyz / ndc4.w * 0.5f + 0.5f;
#endif
#if defined END_ISLAND_LIGHT && defined END_SHADER
vec4 ndc4 = customShadowPerspectiveSSBO * customShadowMatrixSSBO * vec4(playerpos, 1.0);
ndc4.z /= 6.0;
vec3 screenPos = ndc4.xyz / ndc4.w * 0.5f + 0.5f;
#endif
#if defined END_ISLAND_LIGHT && defined END_SHADER || defined OVERWORLD_SHADER
gl_FragDepth = screenPos.z;
#endif
gl_FragData[0] = shadowColor;
#endif
}
}
+18 -7
View File
@@ -52,14 +52,12 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
void main() {
color = gl_Color.rgb;
#ifdef NETHER_SHADER
worldPos = vec3(0.0);
cageNormal = vec3(0.0);
gl_Position = vec4(-1.0);
#else
cageNormal = gl_Normal;
worldPos = vec3(0.0);
cageNormal = gl_Normal;
gl_Position = vec4(-1.0);
#if defined OVERWORLD_SHADER
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
worldPos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz;
@@ -76,6 +74,19 @@ void main() {
gl_Position = toClipSpace3(position);
#endif
gl_Position.z /= 6.0;
#elif defined END_SHADER && defined END_ISLAND_LIGHT
vec3 shadowViewPos = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
worldPos = mat3(shadowModelViewInverse) * shadowViewPos + shadowModelViewInverse[3].xyz;
#ifdef PLANET_CURVATURE
float curvature = length(worldPos.xz) / (16*8);
worldPos.y -= curvature*curvature * CURVATURE_AMOUNT;
#endif
gl_Position = customShadowPerspectiveSSBO * customShadowMatrixSSBO * vec4(worldPos, 1.0);
gl_Position.z /= 6.0;
#endif
}
+4
View File
@@ -25,6 +25,10 @@
"ssbos": {4:"{
mat4 customShadowMatrixSSBO;
#ifdef PHOTONICS
mat4 customShadowMatrixInverseSSBO;
#endif
vec3 customMoonVecSSBO;
vec3 customMoonVec2SSBO;
+17 -4
View File
@@ -1,6 +1,6 @@
option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - A Bliss Edit
prefix.SHADER_VERSION_LABEL = V
value.SHADER_VERSION_LABEL.482 = 7.0.2
value.SHADER_VERSION_LABEL.482 = 8.0.0
iris_extension.keybind.key0.name=Flashlight
@@ -242,7 +242,7 @@ screen.Direct_Light = Direct Light
option.LPV_REDSTONE_LIGHTS = Redstone Lights
option.LPV_COLORED_CANDLES = Colored Candles
option.LPV_NOSHADOW_HACK = Iris <= 1.7.0 Fix
option.LPV_VL_FOG_ILLUMINATION = Fog Light Propagation
option.LPV_VL_FOG_ILLUMINATION = Floodfill Fog Light Propagation
value.LPV_VL_FOG_ILLUMINATION.0 = Off
value.LPV_VL_FOG_ILLUMINATION.1 = Only Indoors
value.LPV_VL_FOG_ILLUMINATION.2 = On
@@ -821,6 +821,7 @@ screen.Resource_Pack_Support = Materials / Resource Pack Support
suffix.DEFERRED_SSR_QUALITY = §§ samples
option.DEFERRED_BACKGROUND_REFLECTION =^ Background reflections
option.DEFERRED_ROUGH_REFLECTION =^ Rough reflections
option.DENOISED_REFLECTIONS =^ Denoised rough reflections
option.FORWARD_SPECULAR = Reflections on water, glass
option.FORWARD_SSR_QUALITY =^ Environment reflections
value.FORWARD_SSR_QUALITY.0 =§c OFF
@@ -1194,7 +1195,7 @@ screen.Post_Processing.comment = Configure settings for all post processing effe
screen.TAA_OPTIONS.comment = Configure settings related to anti-aliasing.
option.SCREENSHOT_MODE.comment = §aTHIS DOES NOT CHANGE GRAPHICS QUALITY IN ANY WAY§r. Toggle frame accumulation to get a low noise image. §bWhat is this?§r It stacks frames that happend onto the next frame that is generated, so it is like a long exposure photo.
option.TAA.comment = Toggle temporal anti-aliasing. This removes all jagged edges on things, softens the image, and helps remove noise for many effects. This will cause ghosting or trailing because it uses past frames for extra information on the world. §aPERFORMANCE COST:§r low
option.BLEND_FACTOR.comment = Configure how much of frame history is used. high numbers means it relies less on frame history, so it may look flickery and noisy. low numbers rely more on frame history, so it may look less moisy, but more smudged with more trailing.
option.BLEND_FACTOR.comment = Configure how much of frame history is used. high numbers means it relies less on frame history, so it may look flickery and noisy. low numbers rely more on frame history, so it may look less noisy, but more smudged with more trailing.
option.TAA_UPSCALING.comment = Toggle temporal upscaling. This retains a good amount of quality from a lower resolution image when it upscales. so you can still have a high looking resolution compared to typical upsampling and still have better performance.
option.SCALE_FACTOR.comment = Configure from what fraction of your resolution to upscale from - §abelow 0.50x is not recommended, it is only allowed for fun!§r
@@ -1275,9 +1276,21 @@ screen.VOXY_SETTINGS = Voxy Settings
screen.PHOTONICS_SETTINGS = Photonics Settings
option.PHOTONICS_ACTIVE = Enable Photonics
option.ENABLE_PHOTONICS_HANDHELD = Photonics Handheld Lighting
option.ENABLE_PHOTONICS_GI = Photonics Global Illumination
option.ENABLE_PHOTONICS_BLOCKLIGHT = Photonics Blocklight
option.PHOTONICS_INDIRECT_BRIGHTNESS = GI Brightness
option.PHOTONICS_GI_ONLY = GI Only
option.PHOTONICS_FLOODFILL_FOG_LIGHT_PROPAGATION = Fog Light Propagation (Floodfill!)
option.PHOTONICS_LIGHTING_MODE = Lighting Mode
option.PHOTONICS_ALPHA_MODE = Alpha Mode
option.PHOTONICS_MAX_SAMPLES = Max Samples
option.PHOTONICS_MAX_LIGHTS = Max Lights
option.VOXEL_REFLECTIONS_SOLID = World Space Reflections (Terrain)
option.VOXEL_REFLECTIONS_TRANSLUCENT = World Space Reflections (Water)
option.TRANSLUCENT_IN_REFLECTIONS = Translucents in Reflections
option.MIRROR_IRON = Iron Block Mirror
option.VOXEL_REFLECTIONS_FOG = Fog in Reflections
option.VOXEL_REFLECTIONS_LPV_FOG = Floodfill Fog Light Propagation in Reflections
option.TRANSLUCENT_COLORED_SHADOWS.comment = §bWhat is this?§r This effect allows translucent things like stained glass to color the sunlight as it passes through it. §aPERFORMANCE COST:§r medium
+1 -1
View File
@@ -1,6 +1,6 @@
option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - Bliss 编辑版
prefix.SHADER_VERSION_LABEL = 版本
value.SHADER_VERSION_LABEL.482 = 7.0.1
value.SHADER_VERSION_LABEL.482 = 8.0.0
# 如果你是来翻译的,这不是玩笑,这些选项的功能正如其名
profile.POTATO=§4土豆 (极低配置)
+4
View File
@@ -1,6 +1,10 @@
layout(std430, binding = 4) buffer SSBO1 {
mat4 customShadowMatrixSSBO; // 64 bytes
#ifdef PHOTONICS
mat4 customShadowMatrixInverseSSBO;
#endif
vec3 customMoonVecSSBO; // 12 bytes
vec3 customMoonVec2SSBO; // 12 bytes
+1
View File
@@ -31,6 +31,7 @@
#define BLOCK_GRASS 85
#define BLOCK_SSS_STRONG3 87
#define BLOCK_CACTUS 89
#define GRASS_BLOCK_SNOWY 90
#define BLOCK_AMETHYST_BUD_LARGE 101
#define BLOCK_AMETHYST_BUD_MEDIUM 102
#define BLOCK_AMETHYST_CLUSTER 103
+71 -36
View File
@@ -7,7 +7,7 @@
if(hand) return 1.0;
vec3 WlightDir = normalize((gbufferModelViewInverse*vec4(lightDir, 1.0)) .xyz);
vec3 WlightDir = normalize((gbufferModelViewInverse*vec4(lightDir, 1.0)).xyz);
float NdotL = dot(normals, WlightDir);
NdotL = smoothstep(0.0, 0.2, abs(NdotL));
@@ -73,14 +73,13 @@
#if (defined IS_LPV_ENABLED || defined PHOTONICS && defined PHOTONICS && !defined PH_ENABLE_HANDHELD_LIGHT) && !defined VOXY_PROGRAM
vec3 GetHandLight(const in int itemId, const in vec3 playerPos, inout float lightRange) {
vec3 lightFinal = vec3(0.0);
vec3 lightColor = vec3(0.0);
uint blockData = imageLoad(imgBlockData, itemId).r;
vec4 lightColorRange = unpackUnorm4x8(blockData);
lightColor = srgbToLinear(lightColorRange.rgb);
lightRange = lightColorRange.a * 255.0;
if (lightRange > 0.0) {
vec3 lightColor = srgbToLinear(lightColorRange.rgb);
float lightDist = length(playerPos+relativeEyePosition);
// vec3 lightDir = playerPos / lightDist;
const float NoL = 1.0;//max(dot(normal, lightDir), 0.0);
@@ -98,6 +97,10 @@
uniform sampler2D radiosity_handheld;
#endif
#ifdef BELTBORNE_LANTERNS
uniform int IEXT_beltborne_lanterns_Id;
#endif
vec3 doBlockLightLighting(
vec3 lightColor, float lightmap,
vec3 playerPos, vec3 lpvPos
@@ -136,41 +139,58 @@ vec3 doBlockLightLighting(
#ifdef Hand_Held_lights
// create handheld lightsources
#if !defined ENABLE_PHOTONICS_HANDHELD || !defined PHOTONICS_LIGHT_PASS
if (heldItemId > 0){
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(heldItemId, playerPos, lightRange);
#if !defined PH_ENABLE_HANDHELD_LIGHT || !defined PHOTONICS_LIGHT_PASS
if (heldItemId > 0){
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(heldItemId, playerPos, lightRange);
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange > 0.0 && firstPersonCamera) handLightCol *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(-0.25, 0.2, 0.0)), noise, normals, hand);
#endif
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange > 0.0 && firstPersonCamera) handLightCol *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(-0.25, 0.2, 0.0)), noise, normals, hand);
#endif
#ifdef WEATHER
handLightCol *= 0.5;
#endif
#ifdef WEATHER
handLightCol *= 0.5;
#endif
blockLight += handLightCol;
}
blockLight += handLightCol;
}
if (heldItemId2 > 0){
float lightRange2 = 0.0;
vec3 handLightCol2 = GetHandLight(heldItemId2, playerPos, lightRange2);
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange2 > 0.0 && firstPersonCamera) handLightCol2 *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(0.25, 0.2, 0.0)), noise, normals, hand);
#endif
if (heldItemId2 > 0){
float lightRange2 = 0.0;
vec3 handLightCol2 = GetHandLight(heldItemId2, playerPos, lightRange2);
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange2 > 0.0 && firstPersonCamera) handLightCol2 *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(0.25, 0.2, 0.0)), noise, normals, hand);
#endif
#ifdef WEATHER
handLightCol2 *= 0.5;
#endif
#ifdef WEATHER
handLightCol2 *= 0.5;
#endif
blockLight += handLightCol2;
}
blockLight += handLightCol2;
}
#ifdef BELTBORNE_LANTERNS
if (IEXT_beltborne_lanterns_Id > 0){
float lightRange2 = 0.0;
vec3 handLightCol2 = GetHandLight(IEXT_beltborne_lanterns_Id, playerPos, lightRange2);
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange2 > 0.0 && firstPersonCamera) handLightCol2 *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(0.125, 0.2, 0.0)), noise, normals, hand);
#endif
#ifdef WEATHER
handLightCol2 *= 0.5;
#endif
blockLight += handLightCol2;
}
#endif
#endif
#if defined PH_ENABLE_HANDHELD_LIGHT && !defined PH_ENABLE_BLOCKLIGHT && !defined PHOTONICS_LIGHT_PASS
vec3 ph_direct_hand = texture(radiosity_handheld, gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
#if defined PH_ENABLE_HANDHELD_LIGHT && !defined PH_ENABLE_BLOCKLIGHT && defined PHOTONICS_INCLUDED
vec3 ph_direct_hand = sample_photonics_handheld(gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
blockLight += ph_direct_hand * 1.35;
#endif
#endif
@@ -182,13 +202,13 @@ vec3 doBlockLightLighting(
#endif
{
vec3 photonicsLight = vec3(0.0);
vec3 handLight = vec3(0.0);
#if defined PH_ENABLE_HANDHELD_LIGHT
vec3 ph_direct_hand = texture(radiosity_handheld, gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
vec3 handLight = ph_direct_hand * 1.35;
vec3 ph_direct_hand = sample_photonics_handheld(gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
handLight = ph_direct_hand * 1.35;
#else
#ifdef Hand_Held_lights
vec3 handLight = vec3(0.0);
if (heldItemId > 0){
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(heldItemId, playerPos, lightRange);
@@ -219,14 +239,29 @@ vec3 doBlockLightLighting(
handLight += handLightCol2;
}
#ifdef BELTBORNE_LANTERNS
if (IEXT_beltborne_lanterns_Id > 0){
float lightRange2 = 0.0;
vec3 handLightCol3 = GetHandLight(IEXT_beltborne_lanterns_Id, playerPos, lightRange2);
#if defined MAIN_SHADOW_PASS && defined LPV_HANDHELD_SHADOWS
if (lightRange2 > 0.0 && firstPersonCamera) handLightCol3 *= SSRT_Handlight_Shadows(viewPos, depthCheck, -(viewPos + vec3(0.125, 0.2, 0.0)), noise, normals, hand);
#endif
#ifdef WEATHER
handLightCol3 *= 0.5;
#endif
handLight += handLightCol3;
}
#endif
#endif
#endif
#ifdef PH_ENABLE_BLOCKLIGHT
vec3 ph_direct = texture(radiosity_direct, gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
vec4 ph_direct_soft = texture(radiosity_direct_soft, gl_FragCoord.xy*texelSize/RENDER_SCALE);
vec3 ph_direct = sample_photonics_direct(gl_FragCoord.xy*texelSize/RENDER_SCALE).xyz;
photonicsLight += ph_direct;
photonicsLight += (ph_direct_soft.xyz / max(ph_direct_soft.w, 1.0f));
photonicsLight += lightColor * 2.5 * min(max(lightmap-0.999,0.0)/(1.0-0.999),1.0);
#endif
-29
View File
@@ -99,35 +99,6 @@ float physics_waveHeight(vec2 position, int iterations, float factor, float time
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(const in vec2 position, const in vec2 direction, const in float factor, const in float time) {
float oceanHeightFactor = physics_oceanHeight / 13.0;
float totalFactor = oceanHeightFactor * factor;
+4 -4
View File
@@ -13,7 +13,7 @@ float densityAtPosFog(in vec3 pos){
}
float cloudVol(in vec3 pos, float maxDistance ){
float cloudVol(in vec3 pos, float maxDistance){
float fogYstart = FOG_START_HEIGHT + 3.0;
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
@@ -200,14 +200,14 @@ vec4 GetVolumetricFog(
shadowPos = shadowPos*vec3(0.5,0.5,0.5/6.0)+0.5;
#ifdef TRANSLUCENT_COLORED_SHADOWS
sh = vec3(texture(shadowtex0, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
if(texture(shadowtex1, shadowPos).x > shadowPos.z && sh.x < 1.0){
if(texture(shadowtex1HW, shadowPos).x > shadowPos.z && sh.x < 1.0){
vec4 translucentShadow = texture(shadowcolor0, shadowPos.xy);
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
}
#else
sh = vec3(texture(shadow, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
#endif
}
+18 -12
View File
@@ -1174,11 +1174,17 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
// ----- PHOTONICS SETTINGS ----- //
//////////////////////////////////
#define VOXEL_REFLECTIONS
#define VOXEL_REFLECTIONS_TRANSLUCENT
#define VOXEL_REFLECTIONS_SOLID
#define DENOISED_REFLECTIONS
#ifdef DENOISED_REFLECTIONS
#endif
#define PHOTONICS_ACTIVE
#if defined VOXEL_REFLECTIONS && defined PHOTONICS && defined PHOTONICS_ACTIVE
#if defined VOXEL_REFLECTIONS_TRANSLUCENT || defined VOXEL_REFLECTIONS_SOLID && defined PHOTONICS && defined PHOTONICS_ACTIVE
#define LPV_ENABLED
#define IS_LPV_ENABLED
#endif
@@ -1192,15 +1198,10 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#undef PHOTONICS_ACTIVE
#endif
// #define PHOTONICS_FLOODFILL_FOG_LIGHT_PROPAGATION
#ifdef PHOTONICS_FLOODFILL_FOG_LIGHT_PROPAGATION
#endif
// TODO: THIS IS HORRENDOUS
#define ENABLE_PHOTONICS_GI
#define ENABLE_PHOTONICS_BLOCKLIGHT
#define ENABLE_PHOTONICS_HANDHELD
// #define ENABLE_PHOTONICS_HANDHELD
#ifdef ENABLE_PHOTONICS_GI
#endif
@@ -1229,14 +1230,16 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#endif
#if defined PHOTONICS && defined PHOTONICS_ACTIVE
#undef DEPTH_WRITE_POM
#undef VOXELIZE
#if !defined PHOTONICS_FLOODFILL_FOG_LIGHT_PROPAGATION && !defined VOXEL_REFLECTIONS && defined PH_ENABLE_BLOCKLIGHT
#if !defined LPV_VL_FOG_ILLUMINATION && !defined VOXEL_REFLECTIONS_TRANSLUCENT && !defined VOXEL_REFLECTIONS_SOLID && (defined PH_ENABLE_BLOCKLIGHT || defined ENABLE_PHOTONICS_HANDHELD)
#undef IS_LPV_ENABLED
#undef LPV_ENABLED
#endif
#else
#undef VOXEL_REFLECTIONS
#undef VOXEL_REFLECTIONS_TRANSLUCENT
#undef VOXEL_REFLECTIONS_SOLID
#endif
#define PHOTONICS_ALPHA_MODE BLOCK // [NONE BLOCK VOXEL]
@@ -1245,12 +1248,15 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define PHOTONICS_INDIRECT_BRIGHTNESS 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.5 3.0 3.5 4.0 4.5 5.0]
#define VOXEL_REFLECTIONS_FOG
#define VOXEL_REFLECTIONS_LPV_FOG
// #define VOXEL_REFLECTIONS_FOG
// #define VOXEL_REFLECTIONS_LPV_FOG
#ifdef VOXEL_REFLECTIONS_FOG
#endif
#define PHOTONICS_LIGHTING_MODE RESTIR // [BASIC RESTIR]
// #define TRANSLUCENT_IN_REFLECTIONS
////////////////////////////////
// ----- DEBUG SETTINGS ----- //
////////////////////////////////
+140 -64
View File
@@ -391,10 +391,10 @@ float ComputeVoxelShadowMap(inout vec3 directLightColor, vec3 playerPos, float m
#ifdef TRANSLUCENT_COLORED_SHADOWS
// determine when opaque shadows are overlapping translucent shadows by getting the difference of opaque depth and translucent depth
float shadowDepthDiff = pow(clamp((texture(shadowtex1, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
float shadowDepthDiff = pow(clamp((texture(shadowtex1HW, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
// get opaque shadow data to get opaque data from translucent shadows.
float opaqueShadow = texture(shadowtex0, projectedShadowPosition).x;
float opaqueShadow = texture(shadowtex0HW, projectedShadowPosition).x;
shadowmap += max(opaqueShadow, shadowDepthDiff);
// get translucent shadow data
@@ -411,7 +411,7 @@ float ComputeVoxelShadowMap(inout vec3 directLightColor, vec3 playerPos, float m
translucentTint += mix(translucentShadow.rgb, vec3(1.0), opaqueShadow*shadowDepthDiff);
#else
shadowmap += texture(shadow, projectedShadowPosition).x;
shadowmap += texture(shadowtex0HW, projectedShadowPosition.xy).x;
#endif
#ifdef BASIC_SHADOW_FILTER
@@ -1162,10 +1162,10 @@ float ComputePhotonicsShadowMap(inout vec3 directLightColor, vec3 playerPos, flo
#ifdef TRANSLUCENT_COLORED_SHADOWS
// determine when opaque shadows are overlapping translucent shadows by getting the difference of opaque depth and translucent depth
float shadowDepthDiff = pow(clamp((texture(shadowtex1, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
float shadowDepthDiff = pow(clamp((texture(shadowtex1HW, projectedShadowPosition).x - projectedShadowPosition.z) * 2.0,0.0,1.0),2.0);
// get opaque shadow data to get opaque data from translucent shadows.
float opaqueShadow = texture(shadowtex0, projectedShadowPosition).x;
float opaqueShadow = texture(shadowtex0HW, projectedShadowPosition).x;
shadowmap += max(opaqueShadow, shadowDepthDiff);
// get translucent shadow data
@@ -1182,7 +1182,7 @@ float ComputePhotonicsShadowMap(inout vec3 directLightColor, vec3 playerPos, flo
translucentTint += mix(translucentShadow.rgb, vec3(1.0), opaqueShadow*shadowDepthDiff);
#else
shadowmap += texture(shadow, projectedShadowPosition).x;
shadowmap += texture(shadowtex0HW, projectedShadowPosition).x;
#endif
#ifdef BASIC_SHADOW_FILTER
@@ -1223,7 +1223,7 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
job.direction = normalize(job.direction);
vec3 direction_inv = 1.0f / job.direction;
float t0 = intersects_world(direction_inv, 16.0f * job.origin);
float t0 = ph_intersects_world(direction_inv, 16.0f * job.origin);
if (t0 == -1.0f) {
job.result_position = vec3(47823934.0f) - world_offset;
return;
@@ -1260,7 +1260,7 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
ivec3 w = ivec3(position); // TODO: maybe use uvec3, no negative check neccessary
// ivec3 block_position = w >> 4;
if (!is_inside(position)) // outside of world?
if (!ph_is_inside(position)) // outside of world?
return;
// if ((job.result_hit = block_position == ray_target)) { // ray target reached?
@@ -1273,14 +1273,14 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
int scale = 0;
int entry = 0;
new_index.x = get_world_index((w >> 8) & 31);
new_index.x = ph_get_world_index((w >> 8) & 31);
if (new_index.x != old_index.x) { // TODO: CRITICAL! UBOs are too tiny for 32x32x32
entries.x = root_array[new_index.x];
}
if (entries.x < 0) { // found chunk?
ivec3 block_pos = (w >> 4) & 15;
new_index.y = -entries.x + get_index(block_pos);
new_index.y = -entries.x + ph_get_index(block_pos);
if (new_index.y != old_index.y) {
entries.y = cb_array[new_index.y];
@@ -1290,7 +1290,7 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
block_index = block_data & 0xfff;
block_index = block_index * (ph_byte_size / 4);
ph_result_sky_brightness = block_data >> 12;
ph_result_sky_brightness = block_data >> 13;
block_id = cb_array[block_index];
voxel_index = block_index + 2;
} else {
@@ -1300,7 +1300,7 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
if (block_index != -1) { // found block
ivec3 voxel_pos = w & 15;
new_index.z = voxel_index + get_index(voxel_pos);
new_index.z = voxel_index + ph_get_index(voxel_pos);
if (new_index.z != old_index.z) {
entries.z = cb_array[new_index.z];
@@ -1328,13 +1328,17 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
intersection_offset = max(ivec3(ray_direction_sign), 0);
} else
#endif
{
if ((-entries.z & 0x7f000000) == 0 || block_id == 85 || block_id == 13) {
{
#ifdef TRANSLUCENT_IN_REFLECTIONS
if ((-entries.z & 0x7f000000) == 0)
#endif
{
job.result_hit = true;
break;
}
vec4 color = unpack_color(-entries.z);
#ifdef TRANSLUCENT_IN_REFLECTIONS
vec4 color = ph_unpack_color(-entries.z);
if (previous_block_id != block_id) {
if (color.a > 0.01 && translucentHits < 10u) {
@@ -1352,10 +1356,11 @@ void trace_wsr(inout RayJob job, bool transparency, inout translucentHit[10] tra
previous_block_id = block_id;
}
#endif
}
scale = 4;
entry = to_fake_air_entry(block_pos);
entry = ph_to_fake_air_entry(block_pos);
} else { scale = 0; entry = entries.z; }
} else { scale = 4; entry = entries.y; previous_block_id = -1;}
@@ -1712,14 +1717,14 @@ vec3 doBlockLightLightingVoxel(
shadowPos = shadowPos*vec3(0.5,0.5,0.5/6.0)+0.5;
#ifdef TRANSLUCENT_COLORED_SHADOWS
sh = vec3(texture(shadowtex0, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
if(texture(shadowtex1, shadowPos).x > shadowPos.z && sh.x < 1.0){
if(texture(shadowtex1HW, shadowPos).x > shadowPos.z && sh.x < 1.0){
vec4 translucentShadow = texture(shadowcolor0, shadowPos.xy);
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
}
#else
sh = vec3(texture(shadow, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
#endif
}
@@ -1851,17 +1856,17 @@ vec3 doBlockLightLightingVoxel(
vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
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 = texture( shadow, pos).x;
// sh = texture( shadowtex0HW, pos).x;
#ifdef TRANSLUCENT_COLORED_SHADOWS
sh = vec3(texture(shadowtex0, pos).x);
sh = vec3(texture(shadowtex0HW, pos).x);
if(texture(shadowtex1, pos).x > pos.z && sh.x < 1.0){
if(texture(shadowtex1HW, pos).x > pos.z && sh.x < 1.0){
vec4 translucentShadow = texture(shadowcolor0, pos.xy);
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
}
#else
sh = vec3(texture(shadow, pos).x);
sh = vec3(texture(shadowtex0HW, pos).x);
#endif
}
@@ -2021,7 +2026,7 @@ vec4 photonicsReflection(
);
translucentHit[10] translucentHitRays;
uint translucentHits;
uint translucentHits = 0u;
int blockID = 0;
translucentHitRays[0].hitColor = vec4(0.0);
@@ -2054,6 +2059,7 @@ vec4 photonicsReflection(
vec3 endPos = ray.result_position - rt_camera_position;
vec3 endPosW = endPos + cameraPosition;
#ifdef TRANSLUCENT_IN_REFLECTIONS
for (uint i = 0; i < translucentHits; i++) {
vec4 sampleColor = translucentHitRays[i].hitColor;
// return vec4(sampleColor.rgb, 1.0);
@@ -2069,14 +2075,15 @@ vec4 photonicsReflection(
if(color.a > 0.995) return color;
}
backgroundTint = mix(normalize(translucentHitRays[0].hitColor.rgb+1e-7), vec3(1.0), min(max(0.1-translucentHitRays[0].hitColor.a,0.0) * 10.0,1.0));
if(hitTranslucent) backgroundTint = mix(normalize(translucentHitRays[0].hitColor.rgb+1e-7), vec3(1.0), min(max(0.1-translucentHitRays[0].hitColor.a,0.0) * 10.0,1.0));
#endif
if (ray.result_hit) {
vec4 sampleColor = vec4(toLinear(ray.result_color), 1.0);
photonicsReflectionShading(sampleColor, ray.result_normal, endPosW, noise.y, DirectLightColor, AmbientLightColor, blockID, skylightmap);
#if defined VOXEL_REFLECTIONS_FOG && defined OVERWORLD_SHADER
#if defined VOXEL_REFLECTIONS_FOG && defined OVERWORLD_SHADER && defined TRANSLUCENT_IN_REFLECTIONS
if(hitTranslucent && isEyeInWater != 1) {
vec4 fog = raymarchWSRfog(translucentHitRays[0].hitPos + world_offset - cameraPosition, endPos, noise, DirectLightColor, indirectLight_fog, indirectLight, 3);
@@ -2093,7 +2100,9 @@ vec4 photonicsReflection(
}
#if defined VOXEL_REFLECTIONS_FOG && defined OVERWORLD_SHADER
#ifdef TRANSLUCENT_IN_REFLECTIONS
if(hitTranslucent && isEyeInWater != 1) endPos = translucentHitRays[0].hitPos + world_offset - cameraPosition;
#endif
#ifdef VOXEL_REFLECTIONS_LPV_FOG
vec4 LPVfog = raymarchWSR_LPV(origin, endPos, noise.x);
@@ -2260,7 +2269,7 @@ float getReflectionVisibility(float f0, float roughness){
// derived from N and K from labPBR wiki https://shaderlabs.org/wiki/LabPBR_Material_Standard
// using ((1.0 - N)^2 + K^2) / ((1.0 + N)^2 + K^2)
const vec3 HCM_F0 [8] = vec3[](
const vec3 HCM_F0 [8] = vec3[8](
vec3(0.531228825312, 0.51235724246, 0.495828545714),// iron
vec3(0.944229966045, 0.77610211732, 0.373402004593),// gold
vec3(0.912298031535, 0.91385063144, 0.919680580954),// Aluminum
@@ -2294,6 +2303,10 @@ vec3 specularReflections(
, bool isWater
, inout float reflectanceForAlpha
#endif
#ifdef DEFERRED_SPECULAR
, inout vec4 specularOut
, inout float SunReflectionAlpha
#endif
,in vec4 flashLight_stuff
@@ -2326,30 +2339,32 @@ vec3 specularReflections(
vec3 reflectedVector_L = reflect(NplayerPos, normal);
#endif
float VdotN = dot(-normalize(viewDir), vec3(0.0,0.0,1.0));
float shlickFresnel = shlickFresnelRoughness(VdotN, roughness);
#if defined FORWARD_SPECULAR || defined DEFERRED_SPECULAR && !defined DENOISED_REFLECTIONS
float VdotN = dot(-normalize(viewDir), vec3(0.0,0.0,1.0));
float shlickFresnel = shlickFresnelRoughness(VdotN, roughness);
// F0 < 230 dialectrics
// F0 >= 230 hardcoded metal f0
// F0 == 255 use albedo for f0
albedo = f0 == 1.0 ? sqrt(albedo) : albedo;
vec3 metalAlbedoTint = isMetal ? albedo : vec3(1.0);
// get F0 values for hardcoded metals.
vec3 hardCodedMetalsF0 = f0 == 1.0 ? albedo : HCM_F0[int(clamp(f0*255.0 - 229.5,0.0,7.0))];
vec3 reflectance = isMetal ? hardCodedMetalsF0 : vec3(f0);
vec3 F0 = (reflectance + (1.0-reflectance) * shlickFresnel) * metalAlbedoTint;
// F0 < 230 dialectrics
// F0 >= 230 hardcoded metal f0
// F0 == 255 use albedo for f0
albedo = f0 == 1.0 ? sqrt(albedo) : albedo;
vec3 metalAlbedoTint = isMetal ? albedo : vec3(1.0);
// get F0 values for hardcoded metals.
vec3 hardCodedMetalsF0 = f0 == 1.0 ? albedo : HCM_F0[int(clamp(f0*255.0 - 229.5,0.0,7.0))];
vec3 reflectance = isMetal ? hardCodedMetalsF0 : vec3(f0);
vec3 F0 = (reflectance + (1.0-reflectance) * shlickFresnel) * metalAlbedoTint;
#if defined FORWARD_SPECULAR
reflectanceForAlpha = clamp(dot(F0, vec3(0.3333333)), 0.0,1.0);
#if defined SNELLS_WINDOW
if(isEyeInWater == 1 && isWater){
// emulate how mojang did snells window in vibrant visuals because it works nicely tbh
float snellsWindow = min(max(0.54 - clamp(1.0 + VdotN,0,1),0.)/0.1,1.);
snellsWindow = 1.0-snellsWindow*snellsWindow;
snellsWindow *= snellsWindow*snellsWindow;
reflectanceForAlpha = f0 + (1.0-f0) * snellsWindow;
}
#if defined FORWARD_SPECULAR
reflectanceForAlpha = clamp(dot(F0, vec3(0.3333333)), 0.0,1.0);
#if defined SNELLS_WINDOW
if(isEyeInWater == 1 && isWater){
// emulate how mojang did snells window in vibrant visuals because it works nicely tbh
float snellsWindow = min(max(0.54 - clamp(1.0 + VdotN,0,1),0.)/0.1,1.);
snellsWindow = 1.0-snellsWindow*snellsWindow;
snellsWindow *= snellsWindow*snellsWindow;
reflectanceForAlpha = f0 + (1.0-f0) * snellsWindow;
}
#endif
#endif
#endif
@@ -2360,6 +2375,10 @@ vec3 specularReflections(
vec4 enviornmentReflection = vec4(0.0);
float backgroundReflectMask = lightmap;
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
SunReflectionAlpha = backgroundReflectMask;
#endif
#if (defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION) || (DEFERRED_SSR_QUALITY > 0 || FORWARD_SSR_QUALITY > 0)
if(reflectionVisibilty < 1.0){
#if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION
@@ -2388,6 +2407,10 @@ vec3 specularReflections(
#endif
// darkening for metals.
vec3 DarkenedDiffuseLighting = isMetal ? diffuseLighting * (1.0-enviornmentReflection.a) * (1.0-lightmap) : diffuseLighting;
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
vec3 DarkenedDiffuseLighting2 = isMetal ? vec3(0.0) : diffuseLighting;
#endif
#else
// darkening for metals.
vec3 DarkenedDiffuseLighting = isMetal ? diffuseLighting * (1.0-lightmap) : diffuseLighting;
@@ -2402,25 +2425,78 @@ vec3 specularReflections(
specularReflections = mix(specularReflections, enviornmentReflection.rgb, enviornmentReflection.a);
#endif
specularReflections = mix(DarkenedDiffuseLighting, specularReflections, F0);
#if defined DEFERRED_SPECULAR && defined DENOISED_REFLECTIONS
specularOut.rgb = specularReflections;
SunReflectionAlpha *= 1.0 - enviornmentReflection.a;
// specularOut.a = 1.0 - enviornmentReflection.a;
return DarkenedDiffuseLighting2;
#endif
#if defined FORWARD_SPECULAR || defined DEFERRED_SPECULAR && !defined DENOISED_REFLECTIONS
specularReflections = mix(DarkenedDiffuseLighting, specularReflections, F0);
// lerp back to diffuse lighting if the reflection has not been deemed visible enough
specularReflections = mix(specularReflections, diffuseLighting, reflectionVisibilty);
// lerp back to diffuse lighting if the reflection has not been deemed visible enough
specularReflections = mix(specularReflections, DarkenedDiffuseLighting, reflectionVisibilty);
#endif
}
#endif
#if defined OVERWORLD_SHADER && SUN_SPECULAR_MULT > 0
vec3 lightSourceReflection = backgroundReflectMask*SUN_SPECULAR_MULT * lightColor * GGX(normal, -NplayerPos, lightVec, roughness, reflectance, metalAlbedoTint);
#if DEFERRED_SSR_QUALITY > 0 || FORWARD_SSR_QUALITY > 0
specularReflections += mix(lightSourceReflection, vec3(0.0), enviornmentReflection.a);
#else
specularReflections += lightSourceReflection*backgroundReflectMask;
#if defined FORWARD_SPECULAR || defined DEFERRED_SPECULAR && !defined DENOISED_REFLECTIONS
#if defined OVERWORLD_SHADER && SUN_SPECULAR_MULT > 0
vec3 lightSourceReflection = backgroundReflectMask*SUN_SPECULAR_MULT * lightColor * GGX(normal, -NplayerPos, lightVec, roughness, reflectance, metalAlbedoTint);
#if DEFERRED_SSR_QUALITY > 0 || FORWARD_SSR_QUALITY > 0
specularReflections += lightSourceReflection * (1.0 - enviornmentReflection.a);
#else
specularReflections += lightSourceReflection;
#endif
#endif
#endif
#if defined FLASHLIGHT_SPECULAR && (defined DEFERRED_SPECULAR || defined FORWARD_SPECULAR)
vec3 flashLightReflection = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * flashLight_stuff.a * GGX(normal, -flashLight_stuff.xyz, -flashLight_stuff.xyz, roughness, reflectance, metalAlbedoTint);
specularReflections += flashLightReflection;
#if defined FLASHLIGHT_SPECULAR && (defined DEFERRED_SPECULAR || defined FORWARD_SPECULAR)
vec3 flashLightReflection = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * flashLight_stuff.a * GGX(normal, -flashLight_stuff.xyz, -flashLight_stuff.xyz, roughness, reflectance, metalAlbedoTint);
specularReflections += flashLightReflection;
#endif
if(!isHand && firstPersonCamera) {
if (heldItemId > 0){
vec3 shiftedViewPos = viewPos + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(heldItemId, shiftedPlayerPos, lightRange);
if(lightRange > 0.0) {
vec3 handheldReflection1 = handLightCol * GGX(normal, -shiftedPlayerPos, -shiftedPlayerPos, roughness, reflectance, metalAlbedoTint);
specularReflections += handheldReflection1;
}
}
if (heldItemId2 > 0){
vec3 shiftedViewPos = viewPos + vec3(0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(heldItemId2, shiftedPlayerPos, lightRange);
if(lightRange > 0.0) {
vec3 handheldReflection1 = handLightCol * GGX(normal, -shiftedPlayerPos, -shiftedPlayerPos, roughness, reflectance, metalAlbedoTint);
specularReflections += handheldReflection1;
}
}
#ifdef BELTBORNE_LANTERNS
if (IEXT_beltborne_lanterns_Id > 0){
vec3 shiftedViewPos = viewPos + vec3(0.15, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
float lightRange = 0.0;
vec3 handLightCol = GetHandLight(IEXT_beltborne_lanterns_Id, shiftedPlayerPos, lightRange);
if(lightRange > 0.0) {
vec3 handheldReflection1 = handLightCol * GGX(normal, -shiftedPlayerPos, -shiftedPlayerPos, roughness, reflectance, metalAlbedoTint);
specularReflections += handheldReflection1;
}
}
#endif
}
#endif
return specularReflections;
+3 -3
View File
@@ -842,14 +842,14 @@ vec4 raymarchCloud(
shadowPos = shadowPos*vec3(0.5,0.5,0.5/6.0)+0.5;
#ifdef TRANSLUCENT_COLORED_SHADOWS
sh = vec3(texture(shadowtex0, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
if(texture(shadowtex1, shadowPos).x > shadowPos.z && sh.x < 1.0){
if(texture(shadowtex1HW, shadowPos).x > shadowPos.z && sh.x < 1.0){
vec4 translucentShadow = texture(shadowcolor0, shadowPos.xy);
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
}
#else
sh = vec3(texture(shadow, shadowPos).x);
sh = vec3(texture(shadowtex0HW, shadowPos).x);
#endif
}
#else
+99
View File
@@ -0,0 +1,99 @@
#version 430
/*
-- INPUT VARIABLES --
*/
in vec4 direction_vert_out;
/*
-- OUTPUT VARIABLES --
*/
layout(location = 2) out vec4 reservoir_frag_out;
layout(location = 3) out vec4 lighting_frag_out;
#ifdef PH_ENABLE_HANDHELD_LIGHT
layout(location = 5) out vec4 handheld_frag_out;
#endif
#include "/photonics/common/header.glsl"
const float ph_spatial_reuse_radius = PH_RESTIR_SPATIAL_REUSE_RADIUS * PH_RENDER_SCALE;
vec3 ph_sun_direction = ph_signed_nudge(sun_direction);
#include "/photonics/restir/restir.glsl"
#include "/photonics/common/ph_lighting_common.glsl"
void main() {
if (!is_in_world()) {
lighting_frag_out = vec4(0f);
#ifdef PH_ENABLE_HANDHELD_LIGHT
handheld_frag_out = vec4(0f);
#endif
return;
}
load_fragment_variables(albedo, world_pos, block_normal, normal);
rt_pos = world_pos - world_offset;
bad_angle = is_bad_angle(world_pos, block_normal);
ph_frag_is_hand = ph_is_hand();
#ifdef PH_ENABLE_HANDHELD_LIGHT
sample_handheld(handheld_frag_out);
#endif
#ifdef PH_ENABLE_GI
RAY_ITERATION_COUNT = 20;
// Detect edge
// TODO: we probably should do fract(2.0f * base_position)
ivec3 inside = ivec3(lessThan(abs(fract(rt_pos) - 0.5f), vec3(0.48f)));
bool onEdge = inside.x + inside.y + inside.z <= 1;
if (!onEdge) sample_indirect();
RAY_ITERATION_COUNT = 100;
#endif
if (ph_light_count == 0) {
lighting_frag_out = vec4(0f);
return;
}
Reservoir reservoir = reservoir_new();
vec4 frag = texelFetch(radiosity_reservoirs, tex_coord, 0);
reservoir_decode(reservoir, frag, rt_pos, false);
Reservoir temp_reservoir = reservoir_new();
for (int i = 0; i < PH_RESTIR_SPATIAL_REUSE_SAMPLES; i++) {
vec2 offset = 2.0 * vec2(rand_next_float(), rand_next_float()) - 1f;
ivec2 uv = ivec2(tex_coord + offset * ph_spatial_reuse_radius);
if (!reservoir_reuse(temp_reservoir, uv)) continue;
reservoir_update(
reservoir,
temp_reservoir.light,
temp_reservoir.light.weight * temp_reservoir.weight * temp_reservoir.samples,
temp_reservoir.samples
);
}
if (reservoir_is_valid(reservoir)) {
#ifdef PH_RESTIR_SOFT_SHADOWS
light_sample_trace_hit(reservoir.light, true);
#else
light_sample_trace_hit(reservoir.light, false);
#endif
reservoir_compute_weight(reservoir);
reservoir_frag_out = reservoir_encode(reservoir);
lighting_frag_out = vec4(reservoir.light.color * reservoir.weight * result_tint_color, 1f);
} else {
reservoir_frag_out = reservoir_encode(reservoir);
lighting_frag_out = vec4(0f);
}
}
+2
View File
@@ -18,6 +18,8 @@ uniform float skyLightLevelSmooth;
uniform int framemod8;
uniform float sunElevation;
#include "/photonics/photonics.glsl"
#include "/lib/res_params.glsl"
#include "/lib/util.glsl"
+22 -12
View File
@@ -30,7 +30,7 @@ sky = false
iris.features.required = SSBO COMPUTE_SHADERS
iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING CUSTOM_IMAGES BLOCK_EMISSION_ATTRIBUTE TESSELLATION_SHADERS FADE_VARIABLE TEXTURE_FILTERING
iris.features.optional = SEPARATE_HARDWARE_SAMPLERS ENTITY_TRANSLUCENT REVERSED_CULLING CUSTOM_IMAGES BLOCK_EMISSION_ATTRIBUTE TESSELLATION_SHADERS FADE_VARIABLE TEXTURE_FILTERING
#ifdef FLASHLIGHT
iext_key.0 = TOGGLE
@@ -58,7 +58,7 @@ iext.geometry.gbuffers_terrain=false
#else
photonics.enableBlockLight=false
#endif
#ifdef ENABLE_PHOTONICS_HANDHELD
#if defined ENABLE_PHOTONICS_HANDHELD && !defined FLASHLIGHT
photonics.enableHandheldLight=true
#else
photonics.enableHandheldLight=false
@@ -66,6 +66,12 @@ iext.geometry.gbuffers_terrain=false
photonics.maxLights = PHOTONICS_MAX_LIGHTS
photonics.maxSamples = PHOTONICS_MAX_SAMPLES
photonics.alphaMode = PHOTONICS_ALPHA_MODE
#if !defined ENABLE_PHOTONICS_GI && !defined ENABLE_PHOTONICS_BLOCKLIGHT && !defined ENABLE_PHOTONICS_HANDHELD
photonics.lightingMode = OFF
#else
photonics.lightingMode = PHOTONICS_LIGHTING_MODE
#endif
#endif
#ifdef REALMOON
@@ -185,9 +191,13 @@ program.world1/gbuffers_block_translucent.enabled = TRANSLUCENT_ENTITIES && IS_I
program.world-1/dh_terrain.enabled = false
program.world-1/dh_water.enabled = false
#endif
program.world0/composite4.enabled = TAA_UPSCALING
program.world1/composite4.enabled = TAA_UPSCALING
program.world-1/composite4.enabled = TAA_UPSCALING
program.world0/composite5.enabled = TAA_UPSCALING
program.world1/composite5.enabled = TAA_UPSCALING
program.world-1/composite5.enabled = TAA_UPSCALING
program.world0/composite2.enabled = DENOISED_REFLECTIONS && DEFERRED_SPECULAR && DEFERRED_ROUGH_REFLECTION
program.world1/composite2.enabled = DENOISED_REFLECTIONS && DEFERRED_SPECULAR && DEFERRED_ROUGH_REFLECTION
program.world-1/composite2.enabled = DENOISED_REFLECTIONS && DEFERRED_SPECULAR && DEFERRED_ROUGH_REFLECTION
#if RESOURCEPACK_SKY == 0 && !defined VOXY
program.world0/deferred2.enabled = false
@@ -234,10 +244,10 @@ blend.gbuffers_entities_translucent.colortex11 = off
# blend.colortex4 = off
blend.composite.colortex5 = off
blend.deferred1.colortex9 = off
blend.composite.colortex9 = off
blend.composite3.colortex9 = off
blend.composite.colortex13 = off
blend.composite.colortex14 = off
blend.composite1.colortex9 = off
blend.composite4.colortex9 = off
blend.composite1.colortex13 = off
blend.composite1.colortex14 = off
# Alpha test
alphaTest.gbuffers_weather = off
@@ -332,7 +342,7 @@ SHADER_VERSION_LABEL <profile> \
screen.SPECULAR.columns=1
screen.SPECULAR = \
QUARTER_RES_SSR SUN_SPECULAR_MULT ROUGHNESS_THRESHOLD <empty> DEFERRED_SPECULAR DEFERRED_SSR_QUALITY DEFERRED_BACKGROUND_REFLECTION DEFERRED_ROUGH_REFLECTION <empty> FORWARD_SPECULAR FORWARD_SSR_QUALITY FORWARD_BACKGROUND_REFLECTION FORWARD_ROUGH_REFLECTION
QUARTER_RES_SSR SUN_SPECULAR_MULT ROUGHNESS_THRESHOLD <empty> DEFERRED_SPECULAR DEFERRED_SSR_QUALITY DEFERRED_BACKGROUND_REFLECTION DEFERRED_ROUGH_REFLECTION DENOISED_REFLECTIONS <empty> FORWARD_SPECULAR FORWARD_SSR_QUALITY FORWARD_BACKGROUND_REFLECTION FORWARD_ROUGH_REFLECTION
screen.Subsurface_Scattering.columns=1
screen.Subsurface_Scattering = SSS_TYPE_SETTING sss_density_multiplier sss_absorbance_multiplier LabSSS_Curve <empty> MISC_BLOCK_SSS MOB_SSS <empty> Ambient_SSS ambientsss_brightness SCREENSPACE_DIRECT_SSS_BLENDING
@@ -560,8 +570,8 @@ SHADER_VERSION_LABEL <profile> \
######## MOD SUPPORT SETTINGS
screen.Mod_support = [DISTANT_HORIZONS_SETTINGS] [PHYSICS_MOD_OCEAN] [VOXY_SETTINGS] CAELUM_SUPPORT [PHOTONICS_SETTINGS]
screen.PHOTONICS_SETTINGS.columns = 1
screen.PHOTONICS_SETTINGS = PHOTONICS_ACTIVE PHOTONICS_MAX_SAMPLES PHOTONICS_MAX_LIGHTS PHOTONICS_INDIRECT_BRIGHTNESS PHOTONICS_ALPHA_MODE PHOTONICS_FLOODFILL_FOG_LIGHT_PROPAGATION VOXEL_REFLECTIONS MIRROR_IRON VOXEL_REFLECTIONS_FOG VOXEL_REFLECTIONS_LPV_FOG
screen.PHOTONICS_SETTINGS.columns = 2
screen.PHOTONICS_SETTINGS = PHOTONICS_ACTIVE PHOTONICS_LIGHTING_MODE PHOTONICS_ALPHA_MODE ENABLE_PHOTONICS_HANDHELD ENABLE_PHOTONICS_GI ENABLE_PHOTONICS_BLOCKLIGHT PHOTONICS_INDIRECT_BRIGHTNESS PHOTONICS_MAX_SAMPLES PHOTONICS_MAX_LIGHTS LPV_VL_FOG_ILLUMINATION <empty> <empty> VOXEL_REFLECTIONS_SOLID VOXEL_REFLECTIONS_TRANSLUCENT TRANSLUCENT_IN_REFLECTIONS MIRROR_IRON VOXEL_REFLECTIONS_FOG VOXEL_REFLECTIONS_LPV_FOG
screen.DISTANT_HORIZONS_SETTINGS.columns = 1
screen.DISTANT_HORIZONS_SETTINGS = DH_OVERDRAW_PREVENTION OVERDRAW_MAX_DISTANCE DH_CHUNK_FADING <empty> DH_AMBIENT_OCCLUSION DH_SUBSURFACE_SCATTERING DH_SCREENSPACE_REFLECTIONS DH_TAA_JITTER DH_NOISE_TEXTURE NOISE_RESOLUTION NOISE_INTENSITY NOISE_DROPOFF <empty> DISTANT_HORIZONS_SHADOWMAP shadowDistance shadowMapResolution <empty> TOGGLE_VL_FOG VOLUMETRIC_CLOUDS
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define NETHER_SHADER
#include "/dimensions/composite12.fsh"
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define NETHER_SHADER
#include "/dimensions/composite12.vsh"
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#include "/dimensions/composite12.fsh"
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#include "/dimensions/composite12.vsh"
+20 -7
View File
@@ -10,6 +10,9 @@
#define RENDER_SHADOW
uniform float alphaTestRef;
uniform vec3 previousCameraPosition;
// #define SAVE_VOXEL_STUFF
/*
!! DO NOT REMOVE !!
@@ -58,6 +61,23 @@ uniform float shadowMaxProj;
uniform int blockEntityId;
uniform int entityId;
//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 viewPos) {
vec4 pos;
pos.xyz = viewPos;
pos.w = 0.0;
pos = shadowModelViewInverse * pos;
return pos.xyz;
}
#include "/lib/Shadow_Params.glsl"
#include "/lib/bokeh.glsl"
#include "/lib/blocks.glsl"
@@ -142,13 +162,6 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),1.0);
}
vec3 viewToWorld(vec3 viewPos) {
vec4 pos;
pos.xyz = viewPos;
pos.w = 0.0;
pos = shadowModelViewInverse * pos;
return pos.xyz;
}
// uniform int renderStage;
@@ -0,0 +1,6 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#define AETHER_FLAG
#include "/dimensions/composite12.fsh"
@@ -0,0 +1,6 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#define AETHER_FLAG
#include "/dimensions/composite12.vsh"
@@ -0,0 +1,6 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#define TWILIGHT_FOREST_FLAG
#include "/dimensions/composite12.fsh"
@@ -0,0 +1,6 @@
#version 430 compatibility
#define OVERWORLD_SHADER
#define TWILIGHT_FOREST_FLAG
#include "/dimensions/composite12.vsh"
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define END_SHADER
#include "/dimensions/composite12.fsh"
+5
View File
@@ -0,0 +1,5 @@
#version 430 compatibility
#define END_SHADER
#include "/dimensions/composite12.vsh"