mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 08:42:50 +08:00
add max distance for biome effects. make border fog cylindrical. Fix compile error on optifine.
This commit is contained in:
@ -75,6 +75,22 @@ float R2_dither(){
|
||||
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
|
||||
}
|
||||
|
||||
//3D noise from 2d texture
|
||||
float densityAtPos(in vec3 pos){
|
||||
pos /= 18.;
|
||||
pos.xz *= 0.5;
|
||||
vec3 p = floor(pos);
|
||||
vec3 f = fract(pos);
|
||||
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
|
||||
vec2 coord = uv / 512.0;
|
||||
|
||||
//The y channel has an offset to avoid using two textures fetches
|
||||
vec2 xy = texture2D(noisetex, coord).yx;
|
||||
|
||||
return mix(xy.r,xy.g, f.y);
|
||||
}
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
/* RENDERTARGETS:1,7,8 */
|
||||
void main() {
|
||||
// overdraw prevention
|
||||
@ -90,7 +106,16 @@ void main() {
|
||||
|
||||
// alpha is material masks, set it to 0.65 to make a DH LODs mask.
|
||||
vec4 Albedo = vec4(gcolor.rgb, 1.0);
|
||||
|
||||
|
||||
// vec3 worldPos = mat3(gbufferModelViewInverse)*pos.xyz + cameraPosition;
|
||||
// worldPos = (worldPos*vec3(1.0,1./48.,1.0)/4) ;
|
||||
// worldPos = floor(worldPos * 4.0 + 0.001) / 32.0;
|
||||
// float noiseTexture = densityAtPos(worldPos* 5000 ) +0.5;
|
||||
|
||||
// float noiseFactor = max(1.0 - 0.3 * dot(Albedo.rgb, Albedo.rgb),0.0);
|
||||
// Albedo.rgb *= pow(noiseTexture, 0.6 * noiseFactor);
|
||||
// Albedo.rgb *= (noiseTexture*noiseTexture)*0.5 + 0.5;
|
||||
|
||||
#ifdef WhiteWorld
|
||||
Albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
@ -754,12 +754,18 @@ void main() {
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
DirectLightColor = lightCol.rgb/80.0;
|
||||
AmbientLightColor = averageSkyCol_Clouds;
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
BiomeSunlightColor(DirectLightColor);
|
||||
// BiomeSunlightColor(DirectLightColor);
|
||||
vec3 biomeDirect = DirectLightColor;
|
||||
vec3 biomeIndirect = AmbientLightColor;
|
||||
float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect);
|
||||
|
||||
float maxDistance = inBiome * min(max(1.0 - length(feetPlayerPos)/(32*8),0.0)*2.0,1.0);
|
||||
DirectLightColor = mix(DirectLightColor, biomeDirect, maxDistance);
|
||||
#endif
|
||||
|
||||
AmbientLightColor = averageSkyCol_Clouds;
|
||||
|
||||
|
||||
vec3 filteredShadow = vec3(1.412,1.0,0.0);
|
||||
if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb;
|
||||
@ -845,7 +851,7 @@ void main() {
|
||||
|
||||
|
||||
vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||
|
||||
|
||||
if(!hand || !entities) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
|
||||
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
|
||||
|
@ -248,6 +248,7 @@ void main() {
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
float linearDistance = length(p3);
|
||||
float linearDistance_cylinder = length(p3.xz);
|
||||
|
||||
float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
|
||||
float lightleakfixfast = clamp(eyeBrightness.y/240.,0.0,1.0);
|
||||
@ -292,9 +293,9 @@ void main() {
|
||||
#if defined BorderFog
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance / dhFarPlane,0.0)*3.0,1.0),2.0),2.0);
|
||||
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance_cylinder / dhFarPlane,0.0)*3.0,1.0),2.0),2.0);
|
||||
#else
|
||||
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance / far,0.0)*5.0,1.0),2.0),2.0);
|
||||
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance_cylinder / far,0.0)*5.0,1.0),2.0),2.0);
|
||||
#endif
|
||||
|
||||
fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0));
|
||||
|
@ -229,6 +229,7 @@ vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth,
|
||||
|
||||
|
||||
uniform sampler2D dhDepthTex;
|
||||
uniform float far;
|
||||
uniform float dhFarPlane;
|
||||
uniform float dhNearPlane;
|
||||
|
||||
@ -250,9 +251,12 @@ float invertlinearDepthFast(const in float depth, const in float near, const in
|
||||
|
||||
vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) {
|
||||
|
||||
mat4 projectionMatrix = depthCheck ? dhPreviousProjection : gbufferPreviousProjection;
|
||||
|
||||
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
#ifdef DISTANT_HORIZONS
|
||||
mat4 projectionMatrix = depthCheck ? dhPreviousProjection : 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 ) {
|
||||
@ -309,7 +313,7 @@ vec4 TAA_hq(){
|
||||
#ifdef DISTANT_HORIZONS
|
||||
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhDepthTex, depthCheck);
|
||||
#else
|
||||
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0);
|
||||
vec3 closestToCamera = closestToCamera5taps(adjTC,depthtex0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -77,8 +77,8 @@ float blueNoise(){
|
||||
}
|
||||
|
||||
#define DHVLFOG
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
// #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);
|
||||
|
@ -43,6 +43,7 @@ vec3 toScreenSpace(vec3 p) {
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
|
||||
float R2_dither(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
@ -76,32 +77,6 @@ vec3 normVec (vec3 vec){
|
||||
return vec*inversesqrt(dot(vec,vec));
|
||||
}
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
uniform mat4 dhPreviousProjection;
|
||||
uniform mat4 dhProjectionInverse;
|
||||
uniform mat4 dhProjection;
|
||||
|
||||
vec3 DH_toScreenSpace(vec3 p) {
|
||||
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
|
||||
vec3 feetPlayerPos = p * 2. - 1.;
|
||||
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
|
||||
return viewPos.xyz / viewPos.w;
|
||||
}
|
||||
|
||||
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
|
||||
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
uniform float dhFarPlane;
|
||||
uniform float dhNearPlane;
|
||||
float DH_ld(float dist) {
|
||||
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
|
||||
}
|
||||
float DH_inv_ld (float lindepth){
|
||||
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
|
||||
}
|
||||
|
||||
#include "/lib/lightning_stuff.glsl"
|
||||
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
|
Reference in New Issue
Block a user