mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-27 02:32:39 +08:00
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:
@ -130,7 +130,7 @@ vec4 applyNoise(in vec4 fragColor, const in vec3 viewPos, const in float viewDis
|
||||
// ideally, close = higher steps and far = lower steps
|
||||
float highestSteps = NOISE_RESOLUTION;
|
||||
float lowestSteps = 2.0;
|
||||
float transitionLength = 16.0 * 8.0; // distance it takes to reach the lowest steps from the highest. measured in meters/blocks.
|
||||
float transitionLength = 16.0 * 16.0; // distance it takes to reach the lowest steps from the highest. measured in meters/blocks.
|
||||
|
||||
float transitionGradient = clamp((length(viewPos - cameraPosition) - (far+32.0)) / transitionLength,0.0,1.0);
|
||||
transitionGradient = sqrt(transitionGradient);// make the gradient appear smoother and less sudden when approaching low steps.
|
||||
|
@ -300,7 +300,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
vec3 bump = normalize(getWaveNormal(waterPos, playerPos, true));
|
||||
|
||||
float bumpmult = 10.0 * WATER_WAVE_STRENGTH;
|
||||
float bumpmult = WATER_WAVE_STRENGTH;
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
flat varying float exposure;
|
||||
|
||||
#ifdef LINES
|
||||
flat varying int SELECTION_BOX;
|
||||
@ -460,7 +459,7 @@ void main() {
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos);
|
||||
Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos);
|
||||
|
||||
#ifdef LINES
|
||||
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * toLinear(color.rgb);
|
||||
|
@ -78,6 +78,13 @@ uniform float rainStrength;
|
||||
uniform sampler2D noisetex;//depth
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
#if defined VIVECRAFT
|
||||
uniform bool vivecraftIsVR;
|
||||
uniform vec3 vivecraftRelativeMainHandPos;
|
||||
uniform vec3 vivecraftRelativeOffHandPos;
|
||||
uniform mat4 vivecraftRelativeMainHandRot;
|
||||
uniform mat4 vivecraftRelativeOffHandRot;
|
||||
#endif
|
||||
|
||||
uniform vec4 entityColor;
|
||||
|
||||
@ -350,13 +357,22 @@ void main() {
|
||||
vec3 playerCamPos = cameraPosition;
|
||||
#endif
|
||||
|
||||
#ifdef VIVECRAFT
|
||||
if (vivecraftIsVR) {
|
||||
playerCamPos = cameraPosition - vivecraftRelativeMainHandPos;
|
||||
}
|
||||
#endif
|
||||
|
||||
// if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
if(HELD_ITEM_BRIGHTNESS > 0.0){
|
||||
float pointLight = clamp(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0,1.0);
|
||||
torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, pointLight*pointLight);
|
||||
|
||||
float pointLight = 1-clamp(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,-0.999,1.0);
|
||||
|
||||
torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, pointLight);
|
||||
}
|
||||
|
||||
#ifdef HAND
|
||||
torchlightmap *= 0.9;
|
||||
// torchlightmap *= 0.9;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -428,6 +444,7 @@ void main() {
|
||||
//////////////////////////////// ////////////////////////////////
|
||||
float textureLOD = bias();
|
||||
vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color;
|
||||
|
||||
#if defined HAND
|
||||
if (Albedo.a < 0.1) discard;
|
||||
#endif
|
||||
|
@ -75,10 +75,6 @@ varying vec3 flatnormal;
|
||||
varying vec3 shitnormal;
|
||||
#endif
|
||||
|
||||
|
||||
flat varying float exposure;
|
||||
|
||||
|
||||
uniform vec3 sunVec;
|
||||
uniform float near;
|
||||
// uniform float far;
|
||||
@ -150,6 +146,7 @@ uniform float waterEnteredAltitude;
|
||||
#define FORWARD_BACKGROUND_REFLECTION
|
||||
#define FORWARD_ROUGH_REFLECTION
|
||||
|
||||
|
||||
#ifdef FORWARD_SPECULAR
|
||||
#endif
|
||||
#ifdef FORWARD_ENVIORNMENT_REFLECTION
|
||||
@ -200,14 +197,16 @@ float blueNoise(){
|
||||
varying vec3 viewVector;
|
||||
vec3 getParallaxDisplacement(vec3 waterPos, vec3 playerPos) {
|
||||
|
||||
float waterHeight = getWaterHeightmap(waterPos.xy) ;
|
||||
waterHeight = exp(-20*sqrt(waterHeight));
|
||||
// waterHeight *= 5.0;
|
||||
float largeWaves = texture2D(noisetex, waterPos.xy / 600.0 ).b;
|
||||
float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5);
|
||||
|
||||
float waterHeight = getWaterHeightmap(waterPos.xy, largeWaves, largeWavesCurved);
|
||||
// waterHeight = exp(-20.0*sqrt(waterHeight));
|
||||
waterHeight = exp(-7.0*exp(-7.0*waterHeight)) * 0.25;
|
||||
|
||||
vec3 parallaxPos = waterPos;
|
||||
|
||||
parallaxPos.xy += (viewVector.xy / -viewVector.z) * waterHeight;
|
||||
// parallaxPos.xz -= (viewVector.xy / viewVector.z) * waterHeight;
|
||||
|
||||
return parallaxPos;
|
||||
}
|
||||
@ -375,14 +374,13 @@ void convertHandDepth(inout float depth) {
|
||||
ndcDepth /= MC_HAND_DEPTH;
|
||||
depth = ndcDepth * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
void Emission(
|
||||
inout vec3 Lighting,
|
||||
vec3 Albedo,
|
||||
float Emission,
|
||||
float exposure
|
||||
float Emission
|
||||
){
|
||||
// float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0));
|
||||
if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why
|
||||
if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve));
|
||||
}
|
||||
|
||||
uniform vec3 eyePosition;
|
||||
@ -406,7 +404,6 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
vec3 viewPos = toScreenSpace(FragCoord*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5, 0.0));
|
||||
|
||||
|
||||
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// MATERIAL MASKS ////////////////////////////////
|
||||
@ -438,8 +435,6 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
float UnchangedAlpha = gl_FragData[0].a;
|
||||
|
||||
// gl_FragData[0].a = pow(gl_FragData[0].a,3);
|
||||
|
||||
#ifdef WhiteWorld
|
||||
gl_FragData[0].rgb = vec3(0.5);
|
||||
gl_FragData[0].a = 1.0;
|
||||
@ -501,19 +496,16 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
vec3 flowDir = normalize(worldSpaceNormal*10.0) * frameTimeCounter * 2.0 * WATER_WAVE_SPEED;
|
||||
|
||||
vec2 newPos = playerPos.xy + cameraPosition.xy + abs(flowDir.xz);
|
||||
newPos = mix(newPos, playerPos.zy + cameraPosition.zy + abs(flowDir.zx), clamp(abs(worldSpaceNormal.x),0,1));
|
||||
newPos = mix(newPos, playerPos.xz + cameraPosition.xz, clamp(abs(worldSpaceNormal.y),0,1));
|
||||
vec2 newPos = playerPos.xy + cameraPosition.xy + abs(flowDir.xz);
|
||||
newPos = mix(newPos, playerPos.zy + cameraPosition.zy + abs(flowDir.zx), clamp(abs(worldSpaceNormal.x),0.0,1.0));
|
||||
newPos = mix(newPos, playerPos.xz + cameraPosition.xz, clamp(abs(worldSpaceNormal.y),0.0,1.0));
|
||||
waterPos.xy = newPos;
|
||||
|
||||
// make the waves flow in the direction the water faces, except for perfectly up facing parts.
|
||||
// if(abs(worldSpaceNormal.y) < 0.9995) posxz.xz -= posxz.y + normalize(worldSpaceNormal.xz*10.0) * frameTimeCounter * 3.0 * WATER_WAVE_SPEED;
|
||||
|
||||
waterPos.xyz = getParallaxDisplacement(waterPos, playerPos);
|
||||
|
||||
vec3 bump = normalize(getWaveNormal(waterPos, playerPos, false));
|
||||
|
||||
float bumpmult = 10.0 * WATER_WAVE_STRENGTH;
|
||||
float bumpmult = WATER_WAVE_STRENGTH;
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
|
||||
NormalTex.xyz = bump;
|
||||
@ -656,7 +648,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos);
|
||||
Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos);
|
||||
|
||||
vec4 flashLightSpecularData = vec4(0.0);
|
||||
#ifdef FLASHLIGHT
|
||||
@ -666,7 +658,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
|
||||
|
||||
#if EMISSIVE_TYPE == 2 || EMISSIVE_TYPE == 3
|
||||
Emission(FinalColor, Albedo, SpecularTex.b, exposure);
|
||||
Emission(FinalColor, Albedo, SpecularTex.b);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -698,7 +690,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
isHand = true;
|
||||
f0 = max(specularValues.g, harcodedF0);
|
||||
#endif
|
||||
|
||||
|
||||
float roughness = specularValues.r;
|
||||
|
||||
if(UnchangedAlpha <= 0.0 && !isReflective) f0 = 0.0;
|
||||
|
@ -18,7 +18,6 @@ varying vec4 color;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
uniform sampler2D noisetex;
|
||||
flat varying float exposure;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
flat varying vec3 averageSkyCol_Clouds;
|
||||
@ -200,7 +199,6 @@ void main() {
|
||||
|
||||
|
||||
color = vec4(gl_Color.rgb, 1.0);
|
||||
exposure = texelFetch2D(colortex4,ivec2(10,37),0).r;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
|
@ -460,12 +460,9 @@ float SSRT_FlashLight_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, floa
|
||||
void Emission(
|
||||
inout vec3 Lighting,
|
||||
vec3 Albedo,
|
||||
float Emission,
|
||||
float exposure
|
||||
float Emission
|
||||
){
|
||||
// float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0));
|
||||
if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why
|
||||
// if( Emission < 254.5/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve);
|
||||
if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve));
|
||||
}
|
||||
|
||||
#include "/lib/indirect_lighting_effects.glsl"
|
||||
@ -940,6 +937,7 @@ void main() {
|
||||
#else
|
||||
float minimumAbsorbance = (1.0 - lightLeakFix);
|
||||
#endif
|
||||
|
||||
Absorbtion = exp(-totEpsilon * max(Vdiff, minimumAbsorbance));
|
||||
|
||||
|
||||
@ -1186,7 +1184,7 @@ void main() {
|
||||
#else
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
vec3 blockLightColor = doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos);
|
||||
vec3 blockLightColor = doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos);
|
||||
Indirect_lighting += blockLightColor;
|
||||
|
||||
vec4 flashLightSpecularData = vec4(0.0);
|
||||
@ -1305,7 +1303,7 @@ void main() {
|
||||
|
||||
vec3 FINAL_COLOR = (Indirect_lighting + Direct_lighting) * albedo;
|
||||
|
||||
Emission(FINAL_COLOR, albedo, SpecularTex.a, exposure);
|
||||
Emission(FINAL_COLOR, albedo, SpecularTex.a);
|
||||
|
||||
if(lightningBolt) FINAL_COLOR = vec3(77.0, 153.0, 255.0);
|
||||
|
||||
|
@ -33,15 +33,17 @@ uniform float near;
|
||||
uniform float dhFarPlane;
|
||||
uniform float dhNearPlane;
|
||||
|
||||
// uniform mat4 gbufferModelViewInverse;
|
||||
// uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
// uniform mat4 gbufferProjectionInverse;
|
||||
// uniform mat4 gbufferProjection;
|
||||
// uniform mat4 gbufferPreviousProjection;
|
||||
// uniform vec3 cameraPosition;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
#if defined VIVECRAFT
|
||||
uniform bool vivecraftIsVR;
|
||||
uniform vec3 vivecraftRelativeMainHandPos;
|
||||
uniform vec3 vivecraftRelativeOffHandPos;
|
||||
uniform mat4 vivecraftRelativeMainHandRot;
|
||||
uniform mat4 vivecraftRelativeOffHandRot;
|
||||
#endif
|
||||
|
||||
uniform int frameCounter;
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
@ -275,16 +277,6 @@ vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither,
|
||||
|
||||
vec3 absorbance = vec3(1.0);
|
||||
vec3 vL = vec3(0.0);
|
||||
|
||||
// float distanceFromWaterSurface = -(normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/(waterEnteredAltitude/2)) * 0.5 + 0.5;
|
||||
// distanceFromWaterSurface = clamp(distanceFromWaterSurface, 0.0,1.0);
|
||||
// distanceFromWaterSurface = exp(-7.0*distanceFromWaterSurface*distanceFromWaterSurface);
|
||||
|
||||
// float distanceFromWaterSurface2 = normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/waterEnteredAltitude;
|
||||
// distanceFromWaterSurface2 = clamp(-distanceFromWaterSurface2,0.0,1.0);
|
||||
|
||||
// distanceFromWaterSurface2 = exp(-7*pow(distanceFromWaterSurface2,1.5));
|
||||
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.1,1.0);
|
||||
@ -294,6 +286,18 @@ vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither,
|
||||
float phase = 0.0;
|
||||
#endif
|
||||
|
||||
// float thing = -normalize(dVWorld + (cameraPosition - vec3(cameraPosition.x, waterEnteredAltitude-1.0,cameraPosition.z))).y;
|
||||
float thing = -normalize(dVWorld).y;
|
||||
thing = clamp(thing + 0.333,0.0,1.0);
|
||||
thing = pow(1.0-pow(1.0-thing,2.0),2.0);
|
||||
|
||||
// thing = 1.0;
|
||||
|
||||
// thing = max(exp(-3.0*exp(-3.0*thing)),0.0);
|
||||
thing *= 15.0;
|
||||
|
||||
thing = 0.0;
|
||||
|
||||
float expFactor = 11.0;
|
||||
for (int i=0;i<spCount;i++) {
|
||||
float d = (pow(expFactor, float(i+dither.x)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); // exponential step position (0-1)
|
||||
@ -344,7 +348,7 @@ vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither,
|
||||
|
||||
|
||||
vec3 sunAbsorbance = exp(-waterCoefs * (distanceFromWaterSurface/abs(WsunVec.y)));
|
||||
vec3 WaterAbsorbance = exp(-waterCoefs * distanceFromWaterSurface);
|
||||
vec3 WaterAbsorbance = exp(-waterCoefs * (distanceFromWaterSurface + thing));
|
||||
|
||||
vec3 Directlight = lightSource * sh * phase * caustics * sunAbsorbance;
|
||||
vec3 Indirectlight = ambient * WaterAbsorbance;
|
||||
|
@ -549,7 +549,7 @@ void main() {
|
||||
vec3 transmittance = exp(-totEpsilon * linearDistance);
|
||||
color.rgb *= transmittance;
|
||||
|
||||
vec3 transmittance2 = exp(-totEpsilon * 25.0);
|
||||
vec3 transmittance2 = exp(-totEpsilon * 50.0);
|
||||
float fogfade = 1.0 - max((1.0 - linearDistance / min(far, 16.0*7.0) ),0);
|
||||
color.rgb += (transmittance2 * scatterCoef) * fogfade;
|
||||
|
||||
|
@ -99,6 +99,7 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0);
|
||||
#endif
|
||||
|
||||
#include "/lib/diffuse_lighting.glsl"
|
||||
|
||||
#define TIMEOFDAYFOG
|
||||
#include "/lib/lightning_stuff.glsl"
|
||||
@ -128,7 +129,6 @@ uniform sampler2D colortex4;
|
||||
#include "/lib/end_fog.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/diffuse_lighting.glsl"
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
|
||||
|
Reference in New Issue
Block a user