improve water waves and underwater fog colors. add support for viveCraft hand with the flashlight/handheld light (more vivecraft support is planned for the future). tweak time of day fog labels. clean a little code.

This commit is contained in:
Xonk
2025-03-09 22:36:51 -04:00
parent b7c276b015
commit c2d97ec045
18 changed files with 169 additions and 130 deletions

View File

@ -1,5 +1,5 @@
// swap out jitter pattern to be a 4 frame pattern instead of an 8 frame halton sequence
#if defined RESPONSIVE_TAA || defined DH_TAA_OVERRIDE
#if (defined RESPONSIVE_TAA || defined DH_TAA_OVERRIDE) && !defined TAA_UPSCALING
const vec2[4] offsets = vec2[4](
vec2(-0.125, -0.875),
vec2( 0.875, -0.125),

View File

@ -22,7 +22,7 @@
#endif
vec3 doBlockLightLighting(
vec3 lightColor, float lightmap, float exposureValue,
vec3 lightColor, float lightmap,
vec3 playerPos, vec3 lpvPos
){
lightmap = clamp(lightmap,0.0,1.0);
@ -65,10 +65,6 @@ vec3 doBlockLightLighting(
#endif
#endif
// try to make blocklight have consistent visiblity in different light levels.
// float autoBrightness = mix(0.5, 1.0, clamp(exp(-10.0*exposureValue),0.0,1.0));
// blockLight *= autoBrightness;
return blockLight * TORCH_AMOUNT;
}
@ -89,12 +85,41 @@ vec3 doIndirectLighting(
}
uniform float centerDepthSmooth;
#if defined VIVECRAFT
uniform bool vivecraftIsVR;
uniform vec3 vivecraftRelativeMainHandPos;
uniform vec3 vivecraftRelativeOffHandPos;
uniform mat4 vivecraftRelativeMainHandRot;
uniform mat4 vivecraftRelativeOffHandRot;
#endif
vec3 calculateFlashlight(in vec2 texcoord, in vec3 viewPos, in vec3 albedo, in vec3 normal, out vec4 flashLightSpecularData, bool hand){
vec3 shiftedViewPos = viewPos + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition) * 3.0;
shiftedViewPos = mat3(gbufferPreviousModelView) * shiftedPlayerPos + gbufferPreviousModelView[3].xyz;
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - 0.5, 1e-7);
// vec3 shiftedViewPos = viewPos + vec3(-0.25, 0.2, 0.0);
// vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition) * 3.0;
// shiftedViewPos = mat3(gbufferPreviousModelView) * shiftedPlayerPos + gbufferPreviousModelView[3].xyz;
vec3 shiftedViewPos;
vec3 shiftedPlayerPos;
float forwardOffset;
#ifdef VIVECRAFT
if (vivecraftIsVR) {
forwardOffset = 0.0;
shiftedPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + vivecraftRelativeMainHandPos;
shiftedViewPos = shiftedPlayerPos * mat3(vivecraftRelativeMainHandRot);
} else
#endif
{
forwardOffset = 0.5;
shiftedViewPos = viewPos + vec3(-0.25, 0.2, 0.0);
shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition) * 3.0;
shiftedViewPos = mat3(gbufferPreviousModelView) * shiftedPlayerPos + gbufferPreviousModelView[3].xyz;
}
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - forwardOffset, 1e-7);
float linearDistance = length(shiftedPlayerPos);
float shiftedLinearDistance = length(scaledViewPos);

View File

@ -314,7 +314,7 @@ vec3 ApplySSRT(
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.y < 1.0){
bouncedLight = texture2D(colortex5, previousPosition.xy).rgb * GI_Strength * CURVE;
radiance += bouncedLight;

View File

@ -67,6 +67,7 @@ float phaseCloudFog(float x, float g){
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14;
}
uniform ivec2 eyeBrightness;
vec4 GetVolumetricFog(
in vec3 viewPosition,
in vec3 sunVector,
@ -227,14 +228,31 @@ vec4 GetVolumetricFog(
#endif
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz);
vec3 lighting = DirectLight + indirectLight;// * (lightLevelZero*0.99 + 0.01) + Lightning;
vec3 lighting = DirectLight + indirectLight;
color += (lighting - lighting * fogVolumeCoeff) * totalAbsorbance;
#if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION
vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - 0.5, 1e-7);
#if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION && !defined VL_CLOUDS_DEFERRED
// vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
// vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
vec3 shiftedViewPos;
vec3 shiftedPlayerPos;
float forwardOffset;
#ifdef VIVECRAFT
if (vivecraftIsVR) {
forwardOffset = 0.0;
shiftedPlayerPos = (progressW - cameraPosition) + ( vivecraftRelativeMainHandPos);
shiftedViewPos = shiftedPlayerPos * mat3(vivecraftRelativeMainHandRot);
} else
#endif
{
forwardOffset = 0.5;
shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
}
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - forwardOffset, 1e-7);
float linearDistance = length(shiftedPlayerPos);
float shiftedLinearDistance = length(scaledViewPos);

View File

@ -636,7 +636,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define FLASHLIGHT_SPECULAR
#define FLASHLIGHT_BOUNCED_INDIRECT
// #define FLASHLIGHT_FOG_ILLUMINATION
#define FLASHLIGHT_RANGE 32 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 60.0 70.0 80.0 90.0 100.0] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 60 70 80 90 100 ]
#define FLASHLIGHT_RANGE 32 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 60.0 70.0 80.0 90.0 100.0 120.0 130.0 140.0 150.0 16.0 170.0 180.0 190.0 200.0 250.0 300.0 350.0 400.0 450.0 500.0 600.0 700.0 800.0 900.0 1000.0 ]
#define FLASHLIGHT_SIZE 2.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 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0]
#define FLASHLIGHT_BRIGHTNESS_MULT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 60.0 70.0 80.0 90.0 100.0 ]
#define FLASHLIGHT_BRIGHTNESS_FALLOFF_MULT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 60.0 70.0 80.0 90.0 100.0 ]
@ -772,7 +772,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define DH_SCREENSPACE_REFLECTIONS
#define DH_TAA_JITTER
#define DH_NOISE_TEXTURE
#define NOISE_RESOLUTION 12 // [1 2 3 4 5 6 7 8 12 14 16 24 32 48 64]
#define NOISE_RESOLUTION 16 // [1 2 3 4 5 6 7 8 12 14 16 24 32 48 64]
#define NOISE_INTENSITY 12.0 // [1.0 2.0 3.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0 18.0 20.0 22.0 24.0 32.0 48.0 64.0]
#define NOISE_DROPOFF 1024 // [128 256 512 768 1024 1536 2048 3072 4096 8192]
@ -827,6 +827,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#undef TAA
#endif
// fix settings
#ifdef RESPONSIVE_TAA
#endif
#ifdef DH_TAA_JITTER
#endif
#ifdef DH_SCREENSPACE_REFLECTIONS

View File

@ -184,7 +184,7 @@ vec4 screenSpaceReflections(
// fix UV pos dragging behind due to hand not having a good previous frame position.
previousPosition.xy = isHand ? raytracePos.xy : previousPosition.xy;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) {
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.y < 1.0) {
reflection.a = 1.0;
#ifdef FORWARD_RENDERED_SPECULAR
@ -305,7 +305,7 @@ vec3 specularReflections(
// if(isHand){
// f0 = 0.9;
// roughness = 0.0;
// roughness = 0.25;
// }
bool isMetal = f0 > 229.5/255.0;

View File

@ -3,93 +3,79 @@ float waterCaustics(vec3 worldPos, vec3 sunVec) {
vec3 projectedPos = worldPos - (sunVec/sunVec.y*worldPos.y);
vec2 pos = projectedPos.xz;
float heightSum = 0.0;
float movement = frameTimeCounter*0.035 * WATER_WAVE_SPEED;
// movement = 0.0;
float movement = frameTimeCounter * 0.035 * WATER_WAVE_SPEED;
float radiance = 2.39996;
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
vec2 wave_size[3] = vec2[](
vec2 wave_size[3] = vec2[](
vec2(48.,12.),
vec2(12.,48.),
vec2(32.,32.)
);
float WavesLarge = max(texture2D(noisetex, pos / 600.0 ).b,0.1);
float largeWaves = texture2D(noisetex, pos / 600.0 ).b;
float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5);
float heightSum = 0.0;
for (int i = 0; i < 3; i++){
pos = rotationMatrix * pos;
heightSum += pow(abs(abs(texture2D(noisetex, pos / wave_size[i] + WavesLarge*0.5 + movement).b * 2.0 - 1.0) * 2.0 - 1.0), 2.0) ;
heightSum += pow(abs(abs(texture2D(noisetex, pos / wave_size[i] + largeWavesCurved * 0.5 + movement).b * 2.0 - 1.0) * 2.0 - 1.0), 1.0+largeWavesCurved) ;
}
float FinalCaustics = exp((1.0 + 5.0 * pow(WavesLarge,0.5)) * (heightSum / 3.0 - 0.5));
return exp((1.0 + 5.0 * sqrt(largeWavesCurved)) * (heightSum / 3.0 - 0.5));
return FinalCaustics;
}
float getWaterHeightmap(vec2 posxz) {
float getWaterHeightmap(vec2 posxz, in float largeWaves, in float largeWavesCurved) {
vec2 pos = posxz;
float heightSum = 0.0;
float movement = frameTimeCounter*0.035 * WATER_WAVE_SPEED;
// movement = 0.0;
float movement = frameTimeCounter * 0.035 * WATER_WAVE_SPEED;
float radiance = 2.39996;
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
vec2 wave_size[3] = vec2[](
vec2 wave_size[3] = vec2[](
vec2(48.,12.),
vec2(12.,48.),
vec2(32.,32.)
);
float WavesLarge = max(texture2D(noisetex, pos / 600.0 ).b,0.1);
float heightSum = 0.0;
for (int i = 0; i < 3; i++){
pos = rotationMatrix * pos;
heightSum += texture2D(noisetex, pos / wave_size[i] + WavesLarge*0.5 + movement).b;
heightSum += texture2D(noisetex, pos / wave_size[i] + largeWavesCurved * 0.5 + movement).b;
}
return (heightSum / 60.0) * WavesLarge;
return (heightSum/4.5) * max(largeWavesCurved,0.3);
}
vec3 getWaveNormal(vec3 waterPos, vec3 playerpos, bool isLOD){
// vary the normal's "smooth" factor as distance changes, to avoid noise from too much details.
// float range = pow(clamp(1.0 - length(posxz - cameraPosition)/(32*4),0.0,1.0),2.0);
// float deltaPos = mix(0.5, 0.1, range);
float range = min(length(playerpos) / (16*12.0), 3.0) ;
float deltaPos = range + 0.15;
// float range = 1-max(1.0-length(playerpos) / (16.0*16.0) ,0.0) ;
// range = (1.0-pow(1.0-pow(range,2.0),2.0)) * 3.0;
// float deltaPos = range + 0.15;
// float normalMult = 1.0 * WATER_WAVE_STRENGTH;
// if(isLOD){
// deltaPos = mix(0.9, deltaPos, range);
// }
// added detail for snells window
// if(isEyeInWater == 1) deltaPos = 0.025;
float largeWaves = texture2D(noisetex, waterPos.xy / 600.0 ).b;
float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5);
#ifdef HYPER_DETAILED_WAVES
deltaPos = 0.025;
float deltaPos = mix(1.0, 0.05, largeWavesCurved);
#else
float deltaPos = mix(1.0, 0.15, largeWavesCurved);
// reduce high frequency detail as distance increases. reduces noise on waves. why have more details than pixels?
float range = min(length(playerpos) / (16.0*24.0), 3.0);
deltaPos += range;
#endif
vec2 coord = waterPos.xy;
float h0 = getWaterHeightmap(coord);
float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0));
float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos));
float h0 = getWaterHeightmap(coord, largeWaves, largeWavesCurved);
float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0), largeWaves,largeWavesCurved);
float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos), largeWaves,largeWavesCurved);
float xDelta = (h1-h0)/deltaPos;
float yDelta = (h3-h0)/deltaPos;
vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0)));
vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0)));
return wave;
}
}