improve end lightning flashes. tweak end fog lighting slightly.

This commit is contained in:
Xonk
2026-08-17 22:02:33 -04:00
parent f4fd54a7f9
commit c765540542
5 changed files with 86 additions and 77 deletions
+2 -3
View File
@@ -676,9 +676,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
float vortexBounds = 1.0;
#endif
vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds);
float lightningflash = texelFetch(colortex4,ivec2(1,1),0).x/150.0;
float lightningflash = 0.0;
vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds,lightningflash);
vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
float end_NdotL = clamp(dot(worldSpaceNormal, normalize(-lightPos))*0.5+0.5,0.0,1.0);
+2 -3
View File
@@ -1104,9 +1104,8 @@ void main() {
float vortexBounds = 1.0;
#endif
vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds);
float lightningflash = texelFetch(colortex4,ivec2(1,1),0).x/150.0;
float lightningflash = 0.0;
vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds, lightningflash);
vec3 lightColors = pow(lightmap.y,8) * LightSourceColors(vortexBounds, lightningflash);
float end_NdotL = clamp(dot(slopednormal, normalize(-lightPos))*0.5+0.5,0.0,1.0);
+25 -55
View File
@@ -421,62 +421,32 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
}
#endif
#ifdef END_SHADER
/* ---------------------- TIMER ---------------------- */
float flash = 0.0;
float maxWaitTime = 5;
float Timer = texelFetch(colortex4, ivec2(3,1), 0).x/150.0;
Timer -= frameTime;
if(Timer <= 0.0){
flash = 1.0;
Timer = pow(hash11(frameCounter), 5) * maxWaitTime;
}
vec2 pixelPos0 = vec2(3,1);
if (gl_FragCoord.x > pixelPos0.x && gl_FragCoord.x < pixelPos0.x + 1 && gl_FragCoord.y > pixelPos0.y && gl_FragCoord.y < pixelPos0.y + 1){
mixhistory = 1.0;
gl_FragData[0] = vec4(Timer, 0.0, 0.0, 1.0);
}
/* ---------------------- FLASHING ---------------------- */
vec2 pixelPos1 = vec2(1,1);
if (gl_FragCoord.x > pixelPos1.x && gl_FragCoord.x < pixelPos1.x + 1 && gl_FragCoord.y > pixelPos1.y && gl_FragCoord.y < pixelPos1.y + 1){
mixhistory = clamp(4.0 * frameTime,0.0,1.0);
gl_FragData[0] = vec4(flash, 0.0, 0.0, 1.0);
}
/* ---------------------- POSITION ---------------------- */
vec2 pixelPos2 = vec2(2,1);
if (gl_FragCoord.x > pixelPos2.x && gl_FragCoord.x < pixelPos2.x + 1 && gl_FragCoord.y > pixelPos2.y && gl_FragCoord.y < pixelPos2.y + 1){
mixhistory = clamp(500.0 * frameTime,0.0,1.0);
vec3 LastPos = (texelFetch(colortex4,ivec2(2,1),0).xyz/150.0) * 2.0 - 1.0;
LastPos += (hash31(frameCounter / 50) * 2.0 - 1.0);
LastPos = LastPos * 0.5 + 0.5;
if(Timer > maxWaitTime * 0.7 ){
LastPos = vec3(0.0);
}
gl_FragData[0] = vec4(LastPos, 1.0);
}
#endif
vec3 currentFrame = gl_FragData[0].rgb*150.0;
gl_FragData[0].rgb = clamp(mix(frameHistory, currentFrame, clamp(mixhistory,0.0,1.0)),0.0,65000.0);
//Exposure values
if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
gl_FragData[0] = vec4(exposure, avgBrightness, avgL2,1.0);
if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
gl_FragData[0] = vec4(rodExposure, centerDepth,0.0, 1.0);
#ifdef END_SHADER
/* ---------------------- POSITION ---------------------- */
vec2 pixelPos2 = vec2(2,1);
if (gl_FragCoord.x > pixelPos2.x && gl_FragCoord.x < pixelPos2.x + 1 && gl_FragCoord.y > pixelPos2.y && gl_FragCoord.y < pixelPos2.y + 1){
vec3 PrevPos = frameHistory*2.0-1.0;
float travelledDist = length(PrevPos.xyz);
vec3 randomDir = normalize(randomPosXYZ.xyz);
// guide the bolt back to the origin with randomized jagged movement.
float heuristic = clamp(dot(-randomDir,PrevPos),-1.0,1.0) * (1.0-clamp(10.0-travelledDist,0.0,1.0));
float rate = frameTime*500.0;
vec3 CurrPos = PrevPos + randomDir * rate * heuristic;
if(travelledDist > 384.0 || (travelledDist < 10.0 && randomPosXYZ.w > 0.8) ) CurrPos = randomDir*384.0;
gl_FragData[0] = vec4(CurrPos*0.5+0.5, 1.0);
}
#endif
//Exposure values
if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
gl_FragData[0] = vec4(exposure, avgBrightness, avgL2, 1.0);
if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
gl_FragData[0] = vec4(rodExposure, centerDepth, 0.0, 1.0);
}
+49 -16
View File
@@ -62,6 +62,8 @@ SOFTWARE.*/
//----------------------------------------------------------------------------------------
uniform vec4 randomPosXYZ;
// vec3 RandomPosition = hash31(frameTimeCounter);
float vortexBoundRange = 300.0;
#ifdef THE_ORB
@@ -70,7 +72,11 @@ float vortexBoundRange = 300.0;
vec3 ManualLightPos = vec3(0.0);
#endif
vec3 LightSourcePosition(vec3 worldPos, vec3 cameraPos, float vortexBounds){
float DoEndFlashEffect(in vec3 lightningBoltPos){
return randomPosXYZ.w * pow(min(max(length(lightningBoltPos.xyz)-5.0,0.0)/200.0,1.0),3.0);
}
vec3 LightSourcePosition(vec3 worldPos, vec3 cameraPos, float vortexBounds, out float lightningflash){
// this is static so it can just sit in one place
vec3 vortexPos = worldPos - vec3(0.0,200.0,0.0);
@@ -82,12 +88,38 @@ vec3 LightSourcePosition(vec3 worldPos, vec3 cameraPos, float vortexBounds){
lightningPos += fract(cameraPos/cellSize)*cellSize - cellSize*0.5;
// make the position offset to random places (RNG.xyz from non-clearing buffer).
vec3 randomOffset = (texelFetch(colortex4,ivec2(2,1),0).xyz / 150.0) * 2.0 - 1.0;
lightningPos -= randomOffset * 2.5;
vec3 lightningBoltPos = texelFetch(colortex4,ivec2(2,1),0).xyz * 2.0 - 1.0;
lightningflash = DoEndFlashEffect(lightningBoltPos.xyz);
lightningPos -= lightningBoltPos;
#ifdef THE_ORB
cellSize = 200.0;
vec3 orbpos = (worldPos - cameraPos - ManualLightPos) - lightningBoltPos;
orbpos += fract(cameraPos/cellSize)*cellSize - cellSize*0.5;
return orbpos;
#else
return mix(lightningPos, vortexPos, vortexBounds);
#endif
}
vec3 LightSourcePosition_VL(vec3 worldPos, vec3 cameraPos, vec3 lightningBoltPos, float vortexBounds){
// this is static so it can just sit in one place
vec3 vortexPos = worldPos - vec3(0.0,200.0,0.0);
vec3 lightningPos = worldPos - cameraPos - ManualLightPos;
// snap-to coordinates in worldspace.
float cellSize = 200.0;
lightningPos += fract(cameraPos/cellSize)*cellSize - cellSize*0.5;
lightningPos -= lightningBoltPos;
#ifdef THE_ORB
cellSize = 200.0;
vec3 orbpos = worldPos - cameraPos - ManualLightPos;// - vec3(sin(frameTimeCounter), cos(frameTimeCounter), cos(frameTimeCounter))*100;
// vec3 orbpos = worldPos - cameraPos - ManualLightPos;// - vec3(sin(frameTimeCounter), cos(frameTimeCounter), cos(frameTimeCounter))*100;
vec3 orbpos = (worldPos - cameraPos - ManualLightPos) - lightningBoltPos;// - vec3(sin(frameTimeCounter), cos(frameTimeCounter), cos(frameTimeCounter))*100;
orbpos += fract(cameraPos/cellSize)*cellSize - cellSize*0.5;
return orbpos;
@@ -113,7 +145,7 @@ float densityAtPosFog(in vec3 pos){
// Create a rising swirl centered around some origin.
void SwirlAroundOrigin(inout vec3 alteredOrigin, vec3 origin){
float radiance = 2.39996 + alteredOrigin.y/1.5 + frameTimeCounter/50;
float radiance = 2.39996 + alteredOrigin.y/1.5 + frameTimeCounter/50*0;
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
// make the swirl only happen within a radius
@@ -158,7 +190,7 @@ float fogShape(in vec3 pos){
SwirlAroundOrigin(samplePos, pos);
float noise = densityAtPosFog(samplePos * 12.0);
float erosion = 1.0-densityAtPosFog((samplePos - frameTimeCounter/20) * (124 + (1-noise)*7));
float erosion = 1.0-densityAtPosFog((samplePos - frameTimeCounter/20*0) * (124 + (1-noise)*7));
float clumpyFog = max(exp(noise * -mix(10,4,vortexBounds))*mix(2,1,vortexBounds) - erosion*0.3, 0.0);
@@ -183,6 +215,7 @@ float endFogPhase(vec3 LightPos){
return (mie*10.0)*(mie*10.0);
}
vec3 LightSourceColors(float vortexBounds, float lightningflash){
// vec3 vortexColor = vec3(0.7,0.88,1.0);
@@ -192,7 +225,7 @@ vec3 LightSourceColors(float vortexBounds, float lightningflash){
vec3 lightningColor = vec3(END_LIGHTNING_COL_R,END_LIGHTNING_COL_G,END_LIGHTNING_COL_B) * lightningflash;
#ifdef THE_ORB
return vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult;
return vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult * lightningflash;
#else
return mix(lightningColor, vortexColor, vortexBounds);
#endif
@@ -228,14 +261,13 @@ vec4 GetVolumetricFog(
return vec4(0.0,0.0,0.0,1.0);
#endif
/// ------------- RAYMARCHING STUFF ------------- \\\
vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz;
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
vec3 progressW = vec3(0.0);
float maxLength = min(length(dVWorld),32.0 * 12.0)/length(dVWorld);
float maxLength = min(length(dVWorld),384.0)/length(dVWorld);
dVWorld *= maxLength;
@@ -251,17 +283,18 @@ vec4 GetVolumetricFog(
float CenterdotV = dot(normalize(vec3(0,100,0)-cameraPosition), normalize(wpos + cameraPosition));
// float phsething = phaseEND(CenterdotV, 0.35) + phaseEND(CenterdotV, 0.85) ;
float skyPhase = (0.5 + pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0) * 0.1;
vec3 hazeColor = normalize(gl_Fog.color.rgb + 1e-6) * 0.1;
float lightningflash = texelFetch(colortex4,ivec2(1,1),0).x/150.0;
// float lightningflash = texelFetch(colortex4,ivec2(1,1),0).x/150.0;
// make the position offset to random places (RNG.xyz from non-clearing buffer).
vec3 lightningBoltPos = texelFetch(colortex4,ivec2(2,1),0).xyz * 2.0 - 1.0;
float lightningflash = DoEndFlashEffect(lightningBoltPos.xyz);
for (int i = 0; i < SAMPLECOUNT; i++) {
float d = (pow(expFactor, float(i+dither)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither2)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
float dd = pow(expFactor, float(i+dither)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
@@ -275,8 +308,8 @@ vec4 GetVolumetricFog(
float vortexBounds = 1.0;
#endif
vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds);
vec3 lightColors = LightSourceColors(vortexBounds, lightningflash) * 0.25;
vec3 lightPosition = LightSourcePosition_VL(progressW, cameraPosition, lightningBoltPos, vortexBounds);
vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
float volumeDensity = fogShape(progressW);
@@ -290,7 +323,7 @@ vec4 GetVolumetricFog(
float volumeCoeff = exp(-stormDensity*dd*dL);
vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither, volumeDensity, lightColors, vortexBounds);
vec3 indirect = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1) * 0.1;
vec3 indirect = vec3(0.5,0.75,1.0) * 0.1 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1) * 0.1;
vec3 stormLighting = indirect + lightsources;
+8
View File
@@ -700,6 +700,14 @@ uniform.float.waterEnteredAltitude = smooth(waterEnteredLowLight, freezeTranstio
#endif
#endif
# extremely funny stuff
variable.float.randomness = random()
variable.float.transitionTrig = if(randomness > 0.4, 0.0, 100000000000000.0)
variable.float.randomValX = smooth(random()*2.0-1.0,transitionTrig,transitionTrig)
variable.float.randomValY = smooth(random()*2.0-1.0,transitionTrig,transitionTrig)
variable.float.randomValZ = smooth(random()*2.0-1.0,transitionTrig,transitionTrig)
uniform.vec4.randomPosXYZ = vec4(randomValX,randomValY,randomValZ, smooth(if(randomness > 0.4, 0.0,1.0),0.5,1.0) )
# photon stuff
uniform.vec2.view_res = vec2(viewWidth, viewHeight)
uniform.vec2.view_pixel_size = vec2(1.0 / viewWidth, 1.0 / viewHeight)