mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-20 07:57:55 +08:00
add end portal effect. fix TAAU scaling problem with reprojected volumetrics
This commit is contained in:
parent
a58cdfb9e9
commit
8a62fff7a2
@ -292,6 +292,12 @@ vec4 texture2D_POMSwitch(
|
||||
|
||||
uniform vec3 eyePosition;
|
||||
|
||||
void convertHandDepth(inout float depth) {
|
||||
float ndcDepth = depth * 2.0 - 1.0;
|
||||
ndcDepth /= MC_HAND_DEPTH;
|
||||
depth = ndcDepth * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -305,6 +311,12 @@ uniform vec3 eyePosition;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 FragCoord = gl_FragCoord.xyz;
|
||||
|
||||
#ifdef HAND
|
||||
convertHandDepth(FragCoord.z);
|
||||
#endif
|
||||
|
||||
bool ifPOM = false;
|
||||
|
||||
@ -317,15 +329,15 @@ void main() {
|
||||
vec3 normal = normalMat.xyz;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x,
|
||||
tangent.y, tangent2.y, normal.y,
|
||||
tangent.z, tangent2.z, normal.z);
|
||||
vec3 binormal = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
#endif
|
||||
|
||||
vec2 tempOffset = offsets[framemod8];
|
||||
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
vec3 fragpos = toScreenSpace(FragCoord*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5, 0.0));
|
||||
vec3 playerpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 worldpos = playerpos + cameraPosition;
|
||||
|
||||
@ -350,19 +362,6 @@ void main() {
|
||||
|
||||
float lightmap = clamp( (lmtexcoord.w-0.9) * 10.0,0.,1.);
|
||||
|
||||
// float rainfall = 1.0;
|
||||
// float Puddle_shape = 0.0;
|
||||
|
||||
// #if defined Puddles && defined WORLD && !defined ENTITIES && !defined HAND
|
||||
// // rainfall = rainStrength * noPuddleAreas * lightmap;
|
||||
|
||||
// // Puddle_shape = clamp(lightmap - exp(-15.0 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b,5.0)),0.0,1.0);
|
||||
// // Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5,0.0,1.0);
|
||||
// // Puddle_shape *= rainStrength * noPuddleAreas ;
|
||||
|
||||
// #endif
|
||||
|
||||
|
||||
vec2 adjustedTexCoord = lmtexcoord.xy;
|
||||
|
||||
#if defined POM && defined WORLD && !defined ENTITIES && !defined HAND
|
||||
@ -429,17 +428,68 @@ void main() {
|
||||
//////////////////////////////// ////////////////////////////////
|
||||
float textureLOD = bias();
|
||||
vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color;
|
||||
// Albedo.rgb = vec3(1.0) * min(max(exp(-15.0 * pow(1.0-luma(Albedo.rgb),3.0)) - 0.2,0.0)*5.0,1.0);
|
||||
#if defined HAND
|
||||
if (Albedo.a < 0.1) discard;
|
||||
#endif
|
||||
|
||||
if(LIGHTNING > 0) Albedo = vec4(1);
|
||||
|
||||
// float ENDPORTAL_EFFECT = 0.0;
|
||||
// #ifndef ENTITIES
|
||||
// ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0;
|
||||
// #endif
|
||||
#if defined WORLD && !defined ENTITIES && !defined HAND
|
||||
float endPortalEmission = 0.0;
|
||||
if(PORTAL > 0) {
|
||||
float steps = 20;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
vec3 worldSpaceNormal = viewToWorld(normal);
|
||||
|
||||
vec3 viewVec = normalize(tbnMatrix*fragpos);
|
||||
vec3 correctedViewVec = viewVec;
|
||||
if(PORTAL > 0){
|
||||
correctedViewVec.xy = mix(correctedViewVec.xy, vec2( viewVec.y,-viewVec.x), clamp( worldSpaceNormal.y,0,1));
|
||||
correctedViewVec.xy = mix(correctedViewVec.xy, vec2(-viewVec.y, viewVec.x), clamp(-worldSpaceNormal.x,0,1));
|
||||
correctedViewVec.xy = mix(correctedViewVec.xy, vec2(-viewVec.y, viewVec.x), clamp(-worldSpaceNormal.z,0,1));
|
||||
}
|
||||
correctedViewVec.z = mix(correctedViewVec.z, -correctedViewVec.z, clamp(length(vec3(worldSpaceNormal.xz, clamp(-worldSpaceNormal.y,0,1))),0,1));
|
||||
|
||||
vec2 correctedWorldPos = playerpos.xz + cameraPosition.xz;
|
||||
correctedWorldPos = mix(correctedWorldPos, vec2(-playerpos.x,playerpos.z) + vec2(-cameraPosition.x,cameraPosition.z), clamp(-worldSpaceNormal.y,0,1));
|
||||
correctedWorldPos = mix(correctedWorldPos, vec2( playerpos.z,playerpos.y) + vec2( cameraPosition.z,cameraPosition.y), clamp( worldSpaceNormal.x,0,1));
|
||||
correctedWorldPos = mix(correctedWorldPos, vec2(-playerpos.z,playerpos.y) + vec2(-cameraPosition.z,cameraPosition.y), clamp(-worldSpaceNormal.x,0,1));
|
||||
correctedWorldPos = mix(correctedWorldPos, vec2( playerpos.x,playerpos.y) + vec2( cameraPosition.x,cameraPosition.y), clamp(-worldSpaceNormal.z,0,1));
|
||||
correctedWorldPos = mix(correctedWorldPos, vec2(-playerpos.x,playerpos.y) + vec2(-cameraPosition.x,cameraPosition.y), clamp( worldSpaceNormal.z,0,1));
|
||||
|
||||
|
||||
vec2 rayDir = ((correctedViewVec.xy) / -correctedViewVec.z) / steps * 5.0 ;
|
||||
|
||||
vec2 uv = correctedWorldPos + rayDir * blueNoise();
|
||||
uv += rayDir * 10.0;
|
||||
|
||||
vec2 animation = vec2(frameTimeCounter, -frameTimeCounter)*0.01;
|
||||
|
||||
for (int i = 0; i < int(steps); i++) {
|
||||
|
||||
float verticalGradient = (i + blueNoise())/steps ;
|
||||
float verticalGradient2 = exp(-7*(1-verticalGradient*verticalGradient));
|
||||
|
||||
float density = max(max(verticalGradient - texture2D(noisetex, uv/256.0 + animation.xy).b*0.5,0.0) - (1.0-texture2D(noisetex, uv/32.0 + animation.xx).r) * (0.4 + 0.1 * (texture2D(noisetex, uv/10.0 - animation.yy).b)),0.0);
|
||||
|
||||
float volumeCoeff = exp(-density*(i+1));
|
||||
|
||||
vec3 lighting = vec3(0.5,0.75,1.0) * 0.1 * exp(-10*density) + vec3(0.2,0.7,1.0) * verticalGradient2 * 2.0;
|
||||
color += (lighting - lighting * volumeCoeff) * absorbance;;
|
||||
|
||||
absorbance *= volumeCoeff;
|
||||
endPortalEmission += verticalGradient*verticalGradient ;
|
||||
uv += rayDir;
|
||||
}
|
||||
|
||||
Albedo.rgb = clamp(color,0,1);
|
||||
endPortalEmission = clamp(endPortalEmission/steps * 1.0,0.0,254.0/255.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WhiteWorld
|
||||
Albedo.rgb = vec3(0.5);
|
||||
@ -540,6 +590,10 @@ void main() {
|
||||
#if EMISSIVE_TYPE == 3
|
||||
gl_FragData[1].a = SpecularTex.a;
|
||||
#endif
|
||||
|
||||
#if defined WORLD && !defined ENTITIES && !defined HAND
|
||||
if(PORTAL > 0) gl_FragData[1].a = endPortalEmission;
|
||||
#endif
|
||||
|
||||
#if SSS_TYPE == 0
|
||||
gl_FragData[1].b = 0.0;
|
||||
|
@ -225,10 +225,13 @@ void main() {
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
tangent = vec4(normalize(gl_NormalMatrix * at_tangent.rgb), at_tangent.w);
|
||||
vec3 alterTangent = at_tangent.rgb;
|
||||
|
||||
tangent = vec4(normalize(gl_NormalMatrix * alterTangent.rgb), at_tangent.w);
|
||||
#endif
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix * gl_Normal), 1.0);
|
||||
|
||||
FlatNormals = normalMat.xyz;
|
||||
|
||||
blockID = mc_Entity.x ;
|
||||
@ -239,10 +242,10 @@ void main() {
|
||||
PORTAL = 0;
|
||||
SIGN = 0;
|
||||
|
||||
#ifdef WORLD
|
||||
#if defined WORLD && !defined HAND
|
||||
if(blockEntityId == BLOCK_SIGN) SIGN = 1;
|
||||
|
||||
if(blockEntityId == BLOCK_END_PORTAL) PORTAL = 1;
|
||||
if(blockEntityId == BLOCK_END_PORTAL || blockEntityId == 187) PORTAL = 1;
|
||||
#endif
|
||||
|
||||
NameTags = 0;
|
||||
|
@ -1195,7 +1195,7 @@ void main() {
|
||||
thingy = pow(thingy,3.5);
|
||||
thingy = 1-pow(1-thingy,5);
|
||||
|
||||
if(LabSSS > 0.0) Indirect_lighting = Indirect_lighting + Indirect_SSS * ambientColor;
|
||||
Indirect_lighting = Indirect_lighting + Indirect_SSS * ambientColor;
|
||||
// Indirect_lighting = max(Indirect_lighting, Indirect_SSS * ambientColor);
|
||||
// Indirect_lighting += Indirect_SSS * ambientColor;
|
||||
|
||||
@ -1345,7 +1345,7 @@ void main() {
|
||||
#endif
|
||||
#if DEBUG_VIEW == debug_FILTERED_STUFF
|
||||
if(hideGUI == 0){
|
||||
|
||||
float value = SSAO_SSS.y;
|
||||
value = pow(value,3.5);
|
||||
value = 1-pow(1-value,5);
|
||||
|
||||
|
@ -384,9 +384,11 @@ vec3 invTonemap(vec3 col){
|
||||
}
|
||||
|
||||
vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){
|
||||
vec2 texcoord = ((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0;
|
||||
// vec2 texcoord = ((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0 ;
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
|
||||
vec2 VLtexCoord = texcoord * VL_RENDER_RESOLUTION;
|
||||
|
||||
|
||||
// vec3 closestToCamera = closestToCamera5taps(texcoord, depthtex0);
|
||||
// vec3 viewPos_5tap = toScreenSpace(closestToCamera);
|
||||
@ -396,7 +398,7 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * playerPos + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3Prev(previousPosition);
|
||||
|
||||
vec2 velocity = previousPosition.xy - texcoord/RENDER_SCALE;
|
||||
vec2 velocity = previousPosition.xy - texcoord;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
vec4 currentFrame = texture2D(colortex0, VLtexCoord);
|
||||
@ -415,7 +417,7 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){
|
||||
vec4 colMax = max(currentFrame,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8))))))));
|
||||
vec4 colMin = min(currentFrame,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8))))))));
|
||||
|
||||
vec4 frameHistory = texture2D(colortex10, previousPosition.xy);
|
||||
vec4 frameHistory = texture2D(colortex10, previousPosition.xy*RENDER_SCALE);
|
||||
vec4 clampedFrameHistory = clamp(frameHistory, colMin, colMax);
|
||||
|
||||
float blendingFactor = 0.1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user