mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-27 02:32:39 +08:00
more setup for scene controller, replace old weather stuff with it. fix vignette when entering/exitings water. added a water enter effect
This commit is contained in:
@ -217,12 +217,6 @@
|
||||
vec4 CloudyDensity = TOD_Fog_mult * vec4(Morning_Cloudy_Fog, Noon_Cloudy_Fog, Evening_Cloudy_Fog, Night_Cloudy_Fog);
|
||||
|
||||
Rainy = Rainy*RainFog_amount;
|
||||
|
||||
#ifdef Daily_Weather
|
||||
// let daily weather influence fog densities.
|
||||
UniformDensity = max(UniformDensity, DailyWeather_UniformFogDensity);
|
||||
CloudyDensity = max(CloudyDensity, DailyWeather_CloudyFogDensity);
|
||||
#endif
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
BiomeFogDensity(UniformDensity, CloudyDensity, maxDistance); // let biome fog hijack to control densities, and overrride any other density controller...
|
||||
|
@ -11,6 +11,7 @@
|
||||
#endif
|
||||
|
||||
uniform float exitWater;
|
||||
uniform float enterWater;
|
||||
// uniform float exitPowderSnow;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
@ -32,7 +33,6 @@ uniform int isEyeInWater;
|
||||
// uniform bool is_on_ground;
|
||||
// uniform bool isSpectator;
|
||||
|
||||
|
||||
void applyGameplayEffects(inout vec3 color, in vec2 texcoord, float noise){
|
||||
|
||||
// detect when health is zero
|
||||
@ -74,6 +74,12 @@ void applyGameplayEffects(inout vec3 color, in vec2 texcoord, float noise){
|
||||
// apply distortion effects for exiting water and under water
|
||||
distortmask = max(distortmask, waterDrops);
|
||||
}
|
||||
if(enterWater > 0.0){
|
||||
vec2 zoomTC = 0.5 + (texcoord - 0.5) * (1.0 - (1.0-sqrt(1.0-enterWater)));
|
||||
float waterSplash = texture2D(noisetex, zoomTC * vec2(aspectRatio,1.0)).r * (1.0-enterWater);
|
||||
|
||||
distortmask = max(distortmask, waterSplash);
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////// APPLY DISTORTION /////////////////////
|
||||
@ -86,6 +92,7 @@ void applyGameplayEffects(inout vec3 color, in vec2 texcoord, float noise){
|
||||
if(exitWater > 0.01) color = distortedColor;
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////// APPLY COLOR EFFECTS /////////////////////
|
||||
#if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT
|
||||
vec3 distortedColorLuma = vec3(1.0, 0.0, 0.0) * dot(distortedColor, vec3(0.21, 0.72, 0.07));
|
||||
|
@ -42,7 +42,7 @@ float cloudVol(in vec3 pos, float maxDistance ){
|
||||
medium_gradientFog = 1.0;
|
||||
}
|
||||
|
||||
FogDensities(medium_gradientFog, cloudyFog, rainyFog, maxDistance, dailyWeatherParams0.a, dailyWeatherParams1.a);
|
||||
FogDensities(medium_gradientFog, cloudyFog, rainyFog, maxDistance, 1.0, 1.0);
|
||||
|
||||
return uniformFog + medium_gradientFog + cloudyFog;
|
||||
}
|
||||
|
76
shaders/lib/scene_controller.glsl
Normal file
76
shaders/lib/scene_controller.glsl
Normal file
@ -0,0 +1,76 @@
|
||||
// write various parameters within singular pixels of a texture, which is a non-clearing buffer reprojecting the previous frame of itself, onto itself.
|
||||
// this allows smooth interpolation over time from any old parameter value, to any new parameter value.
|
||||
|
||||
// read in vertex stage of post processing passes (deferred, composite), so it only runs on 4 vertices
|
||||
// pass to fragment stage for use.
|
||||
|
||||
// the parameters are stored as such:
|
||||
// smallCumulus = (coverage, density)
|
||||
// largeCumulus = (coverage, density)
|
||||
// altostratus = (coverage, density)
|
||||
// fog = (uniform fog density, cloudy fog density)
|
||||
// ... and more, eventually
|
||||
|
||||
flat varying struct sceneController {
|
||||
vec2 smallCumulus;
|
||||
vec2 largeCumulus;
|
||||
vec2 altostratus;
|
||||
vec2 fog;
|
||||
} parameters;
|
||||
|
||||
vec3 writeSceneControllerParameters(
|
||||
vec2 uv,
|
||||
vec2 smallCumulus,
|
||||
vec2 largeCumulus,
|
||||
vec2 altostratus,
|
||||
vec2 fog
|
||||
){
|
||||
|
||||
// in colortex4, data is written in a 3x3 pixel area from (1,1) to (3,3)
|
||||
// avoiding use of any variation of (0,0) to avoid weird textture wrapping issues
|
||||
// 4th compnent/alpha is storing 1/4 res depth so i cant store there lol
|
||||
|
||||
/* (1,3) */ bool topLeft = uv.x > 1 && uv.x < 2 && uv.y > 3 && uv.y < 4;
|
||||
/* (2,3) */ bool topMiddle = uv.x > 2 && uv.x < 3 && uv.y > 3 && uv.y < 4;
|
||||
// /* (3,3) */ bool topRight = uv.x > 3 && uv.x < 5 && uv.y > 3 && uv.y < 4;
|
||||
// /* (1,2) */ bool middleLeft = uv.x > 1 && uv.x < 2 && uv.y > 2 && uv.y < 3;
|
||||
// /* (2,2) */ bool middleMiddle = uv.x > 2 && uv.x < 3 && uv.y > 2 && uv.y < 3;
|
||||
// /* (3,2) */ bool middleRight = uv.x > 3 && uv.x < 5 && uv.y > 2 && uv.y < 3;
|
||||
// /* (1,1) */ bool bottomLeft = uv.x > 1 && uv.x < 2 && uv.y > 1 && uv.y < 2;
|
||||
// /* (2,1) */ bool bottomMiddle = uv.x > 2 && uv.x < 3 && uv.y > 1 && uv.y < 2;
|
||||
// /* (3,1) */ bool bottomRight = uv.x > 3 && uv.x < 5 && uv.y > 1 && uv.y < 2;
|
||||
|
||||
vec3 data = vec3(0.0,0.0,0.0);
|
||||
|
||||
if(topLeft) data = vec3(smallCumulus.xy, largeCumulus.x);
|
||||
if(topMiddle) data = vec3(largeCumulus.y, altostratus.xy);
|
||||
|
||||
// if(topRight) data = vec4(groundSunColor,fogSunColor.r);
|
||||
// if(middleLeft) data = vec4(groundAmbientColor,fogSunColor.g);
|
||||
// if(middleMiddle) data = vec4(fogAmbientColor,fogSunColor.b);
|
||||
// if(middleRight) data = vec4(cloudSunColor,cloudAmbientColor.r);
|
||||
// if(bottomLeft) data = vec4(cloudAmbientColor.gb,0.0,0.0);
|
||||
// if(bottomMiddle) data = vec4(0.0);
|
||||
// if(bottomRight) data = vec4(0.0);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void readSceneControllerParameters(
|
||||
sampler2D colortex,
|
||||
out vec2 smallCumulus,
|
||||
out vec2 largeCumulus,
|
||||
out vec2 altostratus,
|
||||
out vec2 fog
|
||||
){
|
||||
|
||||
// in colortex4, read the data stored within the 3 components of the sampled pixels, and pass it to the fragment stage
|
||||
// 4th compnent/alpha is storing 1/4 res depth so i cant store there lol
|
||||
vec3 data1 = texelFetch2D(colortex,ivec2(1,3),0).rgb/150.0;
|
||||
vec3 data2 = texelFetch2D(colortex,ivec2(2,3),0).rgb/150.0;
|
||||
|
||||
smallCumulus = vec2(data1.x,data1.y);
|
||||
largeCumulus = vec2(data1.z,data2.x);
|
||||
altostratus = vec2(data2.y,data2.z);
|
||||
fog = vec2(0.0);
|
||||
}
|
@ -31,7 +31,7 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
|
||||
|
||||
if(LayerIndex == ALTOSTRATUS_LAYER){
|
||||
|
||||
coverage = dailyWeatherParams0.z;
|
||||
coverage = parameters.altostratus.x;
|
||||
|
||||
largeCloud = texture2D(noisetex, (position.xz + cloud_movement)/100000. * CloudLayer2_scale).b;
|
||||
smallCloud = 1.0 - texture2D(noisetex, ((position.xz - cloud_movement)/7500. - vec2(1.0-largeCloud, -largeCloud)/5.0) * CloudLayer2_scale).b;
|
||||
@ -45,7 +45,7 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
|
||||
return shape;
|
||||
}
|
||||
if(LayerIndex == LARGECUMULUS_LAYER){
|
||||
coverage = dailyWeatherParams0.y;
|
||||
coverage = parameters.largeCumulus.x;
|
||||
|
||||
largeCloud = texture2D(noisetex, (samplePos.zx + cloud_movement*2.0)/10000.0 * CloudLayer1_scale).b;
|
||||
smallCloud = texture2D(noisetex, (samplePos.zx - cloud_movement*2.0)/2500.0 * CloudLayer1_scale).b;
|
||||
@ -58,7 +58,7 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
|
||||
|
||||
}
|
||||
if(LayerIndex == SMALLCUMULUS_LAYER){
|
||||
coverage = dailyWeatherParams0.x;
|
||||
coverage = parameters.smallCumulus.x;
|
||||
|
||||
largeCloud = texture2D(noisetex, (samplePos.xz + cloud_movement)/5000.0 * CloudLayer0_scale).b;
|
||||
smallCloud = 1.0-texture2D(noisetex, (samplePos.xz - cloud_movement)/500.0 * CloudLayer0_scale).r;
|
||||
@ -139,15 +139,15 @@ float GetCloudShadow(vec3 playerPos, vec3 sunVector){
|
||||
|
||||
#ifdef CloudLayer0
|
||||
startPosition = playerPos + sunVector / abs(sunVector.y) * max((CloudLayer0_height + 20.0) - playerPos.y, 0.0);
|
||||
cloudShadows = getCloudShape(SMALLCUMULUS_LAYER, 0, startPosition, CloudLayer0_height, CloudLayer0_height+90.0)*dailyWeatherParams1.x;
|
||||
cloudShadows = getCloudShape(SMALLCUMULUS_LAYER, 0, startPosition, CloudLayer0_height, CloudLayer0_height+90.0)*parameters.smallCumulus.y;
|
||||
#endif
|
||||
#ifdef CloudLayer1
|
||||
startPosition = playerPos + sunVector / abs(sunVector.y) * max((CloudLayer1_height + 20.0) - playerPos.y, 0.0);
|
||||
cloudShadows += getCloudShape(LARGECUMULUS_LAYER, 0, startPosition, CloudLayer1_height, CloudLayer1_height+90.0)*dailyWeatherParams1.y;
|
||||
cloudShadows += getCloudShape(LARGECUMULUS_LAYER, 0, startPosition, CloudLayer1_height, CloudLayer1_height+90.0)*parameters.largeCumulus.y;
|
||||
#endif
|
||||
#ifdef CloudLayer2
|
||||
startPosition = playerPos + sunVector / abs(sunVector.y) * max(CloudLayer2_height - playerPos.y, 0.0);
|
||||
cloudShadows += getCloudShape(ALTOSTRATUS_LAYER, 0, startPosition, CloudLayer2_height, CloudLayer2_height)*dailyWeatherParams1.z * (1.0-abs(WsunVec.y));
|
||||
cloudShadows += getCloudShape(ALTOSTRATUS_LAYER, 0, startPosition, CloudLayer2_height, CloudLayer2_height)*parameters.altostratus.y * (1.0-abs(WsunVec.y));
|
||||
#endif
|
||||
|
||||
cloudShadows *= CLOUD_SHADOW_STRENGTH;
|
||||
@ -265,7 +265,7 @@ vec4 raymarchCloud(
|
||||
densityTresholdCheck = mix(1e-5, densityTresholdCheck, dither);
|
||||
|
||||
if(LayerIndex == ALTOSTRATUS_LAYER){
|
||||
float density = dailyWeatherParams1.z;
|
||||
float density = parameters.altostratus.y;
|
||||
|
||||
bool ifAboveOrBelowPlane = max(mix(-1.0, 1.0, clamp(cameraPosition.y - minHeight,0.0,1.0)) * normalize(rayDirection).y,0.0) > 0.0;
|
||||
|
||||
@ -312,15 +312,15 @@ vec4 raymarchCloud(
|
||||
if(LayerIndex < ALTOSTRATUS_LAYER){
|
||||
|
||||
|
||||
float density = dailyWeatherParams1.x;
|
||||
float density = parameters.smallCumulus.y;
|
||||
|
||||
if(LayerIndex == LARGECUMULUS_LAYER) density = dailyWeatherParams1.y;
|
||||
if(LayerIndex == LARGECUMULUS_LAYER) density = parameters.largeCumulus.y;
|
||||
|
||||
float skylightOcclusion = 1.0;
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(LayerIndex == SMALLCUMULUS_LAYER) {
|
||||
float upperLayerOcclusion = getCloudShape(LARGECUMULUS_LAYER, 0, rayPosition + vec3(0.0,1.0,0.0) * max((CloudLayer1_height+20) - rayPosition.y,0.0), CloudLayer1_height, CloudLayer1_height+100.0);
|
||||
skylightOcclusion = mix(mix(0.0,0.2,dailyWeatherParams1.y), 1.0, pow(1.0 - upperLayerOcclusion*dailyWeatherParams1.y,2));
|
||||
skylightOcclusion = mix(mix(0.0,0.2,parameters.largeCumulus.y), 1.0, pow(1.0 - upperLayerOcclusion*parameters.largeCumulus.y,2));
|
||||
}
|
||||
|
||||
skylightOcclusion = mix(1.0, skylightOcclusion, distanceFade);
|
||||
@ -359,13 +359,13 @@ vec4 raymarchCloud(
|
||||
#if defined CloudLayer0 && defined CloudLayer1
|
||||
if(LayerIndex == SMALLCUMULUS_LAYER){
|
||||
vec3 shadowStartPos = rayPosition + sunVector / abs(sunVector.y) * max((CloudLayer1_height + 20.0) - rayPosition.y, 0.0);
|
||||
sunShadowMask += 3.0 * getCloudShape(LARGECUMULUS_LAYER, 0, shadowStartPos, CloudLayer1_height, CloudLayer1_height+100.0)*dailyWeatherParams1.y;
|
||||
sunShadowMask += 3.0 * getCloudShape(LARGECUMULUS_LAYER, 0, shadowStartPos, CloudLayer1_height, CloudLayer1_height+100.0)*parameters.largeCumulus.y;
|
||||
}
|
||||
#endif
|
||||
// altostratus layer -> all cumulus layers
|
||||
#if defined CloudLayer2
|
||||
vec3 shadowStartPos = rayPosition + sunVector / abs(sunVector.y) * max(CloudLayer2_height - rayPosition.y, 0.0);
|
||||
sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * dailyWeatherParams1.z * (1.0-abs(sunVector.y));
|
||||
sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * parameters.altostratus.y * (1.0-abs(sunVector.y));
|
||||
#endif
|
||||
|
||||
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion, distanceFade);
|
||||
|
Reference in New Issue
Block a user