mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 08:42:50 +08:00
redo application for ambient lighting in all dimensions. fix RTAO/SSGI in end/nether
This commit is contained in:
@ -149,29 +149,24 @@ void main() {
|
||||
Direct_lighting *= phaseg(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), 0.65)*2 + 0.5;
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, Torch_Color, clamp(lightmap.xy,0,1), 3.0);
|
||||
#endif
|
||||
|
||||
#ifdef END_SHADER
|
||||
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(lightmap.x)),5.0)+0.1));
|
||||
TorchLM = pow(TorchLM/4,10) + pow(lightmap.x,1.5)*0.5;
|
||||
vec3 AmbientLightColor = averageSkyCol_Clouds;
|
||||
|
||||
vec3 TorchLight = (Torch_Color * TorchLM * 0.75) * TORCH_AMOUNT;
|
||||
|
||||
Indirect_lighting = max(vec3(0.5,0.75,1.0) * 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) ) + TorchLight;
|
||||
#endif
|
||||
|
||||
#ifdef NETHER_SHADER
|
||||
vec3 AmbientLightColor = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10;
|
||||
vec3 AmbientLightColor = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 15;
|
||||
#endif
|
||||
|
||||
vec3 nothing = vec3(0.0);
|
||||
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, Torch_Color, lightmap.x, nothing, nothing, nothing);
|
||||
#ifdef END_SHADER
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef FALLBACK_SHADER
|
||||
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), Torch_Color, lightmap.x, vec3(0.0), feetPlayerPos);
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), clamp(lightmap.xy,0,1));
|
||||
|
||||
#ifndef LINES
|
||||
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
|
||||
#else
|
||||
|
@ -397,7 +397,7 @@ void main() {
|
||||
// #endif
|
||||
|
||||
#ifdef WhiteWorld
|
||||
Albedo.rgb = vec3(1.0);
|
||||
Albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -368,9 +368,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
////////////////////////////////
|
||||
|
||||
vec2 lightmap = lmtexcoord.zw;
|
||||
|
||||
#ifndef OVERWORLD_SHADER
|
||||
lightmap.y = 1.0;
|
||||
#endif
|
||||
|
||||
vec3 Indirect_lighting = vec3(0.0);
|
||||
vec3 Direct_lighting = vec3(0.0);
|
||||
|
||||
@ -437,14 +439,15 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
Direct_lighting = (lightCol.rgb/80.0) * NdotL * Shadows;
|
||||
|
||||
|
||||
vec3 AmbientLightColor = averageSkyCol_Clouds;
|
||||
|
||||
vec3 ambientcoefs = WS_normal / dot(abs(WS_normal), vec3(1));
|
||||
float SkylightDir = ambientcoefs.y*1.5;
|
||||
|
||||
float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + SkylightDir, 0.25);
|
||||
|
||||
// float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + viewToWorld(normal).y, 0.25) * 1.35;
|
||||
Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
|
||||
// Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
|
||||
#endif
|
||||
|
||||
#ifdef NETHER_SHADER
|
||||
@ -459,19 +462,18 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
down *= pow( max(-WS_normal.y, 0), 2);
|
||||
AmbientLightColor += up + down;
|
||||
|
||||
// do all ambient lighting stuff
|
||||
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
#endif
|
||||
|
||||
#ifdef END_SHADER
|
||||
// do all ambient lighting stuff
|
||||
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos );
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef FALLBACK_SHADER
|
||||
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, WS_normal, feetPlayerPos);
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
|
||||
|
||||
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
|
@ -210,19 +210,16 @@ vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth,
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715) ) );
|
||||
return noise ;
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
|
||||
}
|
||||
// vec2 R2_dither(){
|
||||
// vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
// return vec2(fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter), fract((1.0-alpha.x) * gl_FragCoord.x + (1.0-alpha.y) * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter));
|
||||
// }
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * (frameCounter*0.5+0.5) );
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
|
||||
@ -943,48 +940,39 @@ void main() {
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
|
||||
vec3 ambientcoefs = slopednormal / dot(abs(slopednormal), vec3(1));
|
||||
|
||||
float SkylightDir = ambientcoefs.y*1.5;
|
||||
if(isGrass) SkylightDir = 1.25;
|
||||
|
||||
float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.25) ;
|
||||
|
||||
// #if indirect_effect == 2
|
||||
// skylight = 1.0;
|
||||
// #endif
|
||||
|
||||
#if indirect_effect != 3 || indirect_effect != 4
|
||||
Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
|
||||
#endif
|
||||
|
||||
|
||||
Indirect_lighting += LightningFlashLighting;
|
||||
AmbientLightColor *= skylight;
|
||||
#endif
|
||||
|
||||
#ifdef NETHER_SHADER
|
||||
AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 10;
|
||||
AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb;
|
||||
|
||||
vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10;
|
||||
vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb / 10;
|
||||
vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb;
|
||||
vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb;
|
||||
|
||||
up *= pow( max( slopednormal.y, 0), 2);
|
||||
down *= pow( max(-slopednormal.y, 0), 2);
|
||||
AmbientLightColor += up + down;
|
||||
|
||||
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized, feetPlayerPos );
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef END_SHADER
|
||||
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized);
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef FALLBACK_SHADER
|
||||
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos);
|
||||
// if(hand) Indirect_lighting = vec3(TORCH_R,TORCH_G,TORCH_B) * 0.3;
|
||||
vec3 AmbientLightColor = vec3(1.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
|
||||
|
||||
// Indirect_lighting += LightningFlashLighting;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1034,12 +1022,13 @@ void main() {
|
||||
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
|
||||
|
||||
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
|
||||
AO *= exp((1.0-SSAO_SSS.x) * -5.0);
|
||||
// AO *= exp((1.0-SSAO_SSS.x) * -5.0);
|
||||
AO *= SSAO_SSS.x*SSAO_SSS.x*SSAO_SSS.x;
|
||||
SkySSS = SSAO_SSS.y;
|
||||
|
||||
Indirect_lighting *= AO;
|
||||
|
||||
#endif
|
||||
|
||||
// GTAO
|
||||
#if indirect_effect == 2
|
||||
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
|
||||
@ -1052,7 +1041,7 @@ void main() {
|
||||
|
||||
// RTAO and/or SSGI
|
||||
#if indirect_effect == 3 || indirect_effect == 4
|
||||
if (!hand) ApplySSRT(Indirect_lighting, normal, vec3(bnoise, noise_2), viewPos, lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass);
|
||||
if (!hand) ApplySSRT(Indirect_lighting, viewPos, normal, vec3(bnoise, noise_2), lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass);
|
||||
#endif
|
||||
|
||||
#ifdef SSS_view
|
||||
@ -1100,18 +1089,14 @@ void main() {
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0);
|
||||
|
||||
// do this here so it gets underwater absorbtion.
|
||||
|
||||
// Direct_lighting += Direct_SSS * DirectLightColor;
|
||||
Direct_lighting = max(Direct_lighting, Direct_SSS * DirectLightColor);
|
||||
// do these here so it gets underwater absorbtion.
|
||||
Direct_lighting = max(DirectLightColor * (NdotL * Shadows), DirectLightColor * Direct_SSS);
|
||||
#endif
|
||||
|
||||
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo;
|
||||
|
||||
#ifdef Specular_Reflections
|
||||
vec2 specularNoises = vec2(noise, interleaved_gradientNoise());
|
||||
vec2 specularNoises = vec2(noise, R2_dither());
|
||||
DoSpecularReflections(gl_FragData[0].rgb, viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*Shadows*NdotL, lightmap.y, hand);
|
||||
#endif
|
||||
|
||||
@ -1150,29 +1135,9 @@ void main() {
|
||||
waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol);
|
||||
}
|
||||
#endif
|
||||
// vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+150.0),lightningBoltPosition.z);
|
||||
// // vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, lightningBoltPosition.y + 60,lightningBoltPosition.z);
|
||||
|
||||
// gl_FragData[0].rgb = vec3(1) * CustomPhase(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0));
|
||||
// float phaseorigin = 1.0 - clamp(dot(feetPlayerPos_normalized, normalize(testPos) ),0.0,1.0);
|
||||
|
||||
|
||||
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
|
||||
// mat4 Custom_ProjectionMatrix = BuildShadowProjectionMatrix();
|
||||
|
||||
// // vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos + Custom_ViewMatrix[3].xyz;
|
||||
// // projectedShadowPosition = mat3(Custom_ProjectionMatrix) * projectedShadowPosition + Custom_ProjectionMatrix[3].xyz;
|
||||
|
||||
// vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz;
|
||||
// projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
// //apply distortion
|
||||
// float distortFactor = calcDistort(projectedShadowPosition.xy);
|
||||
// projectedShadowPosition.xy *= distortFactor;
|
||||
|
||||
// projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
|
||||
|
||||
// gl_FragData[0].rgb = vec3(1);
|
||||
|
||||
|
||||
/* DRAWBUFFERS:3 */
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ uniform sampler2D depthtex0;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex3;
|
||||
// uniform sampler2D colortex4;
|
||||
uniform sampler2D colortex6;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
uniform vec3 sunVec;
|
||||
@ -68,7 +69,11 @@ float interleaved_gradientNoise(){
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a+ 1.0/1.6180339887 * frameCounter );
|
||||
}
|
||||
|
||||
float R2_dither(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
|
||||
}
|
||||
void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){
|
||||
inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value
|
||||
|
||||
@ -223,7 +228,13 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
|
||||
}
|
||||
vec2 R2_samples(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
|
||||
void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
@ -233,8 +244,8 @@ void main() {
|
||||
float z = texture2D(depthtex0,tc).x;
|
||||
vec3 viewPos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
|
||||
|
||||
float noise_1 = blueNoise();
|
||||
float noise_2 = interleaved_gradientNoise();
|
||||
float noise_1 = R2_dither();
|
||||
float noise_2 = blueNoise();
|
||||
|
||||
|
||||
if (isEyeInWater == 0){
|
||||
|
@ -39,12 +39,9 @@ vec3 toScreenSpace(vec3 p) {
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float R2_dither2(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * (1.0-gl_FragCoord.x) + alpha.y * (1.0-gl_FragCoord.y) + 1.0/1.6180339887 * frameCounter);
|
||||
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
|
Reference in New Issue
Block a user