mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-20 16:07:22 +08:00
110 lines
3.4 KiB
GLSL
110 lines
3.4 KiB
GLSL
#version 120
|
|
//#extension GL_EXT_gpu_shader4 : disable
|
|
|
|
|
|
#include "/lib/settings.glsl"
|
|
|
|
|
|
flat varying vec3 ambientUp;
|
|
flat varying vec3 ambientLeft;
|
|
flat varying vec3 ambientRight;
|
|
flat varying vec3 ambientB;
|
|
flat varying vec3 ambientF;
|
|
flat varying vec3 ambientDown;
|
|
|
|
flat varying vec3 lightSourceColor;
|
|
flat varying vec3 sunColor;
|
|
flat varying vec3 sunColorCloud;
|
|
flat varying vec3 moonColor;
|
|
flat varying vec3 moonColorCloud;
|
|
flat varying vec3 zenithColor;
|
|
flat varying vec3 avgSky;
|
|
flat varying vec2 tempOffsets;
|
|
flat varying float exposure;
|
|
flat varying float rodExposure;
|
|
flat varying float avgBrightness;
|
|
flat varying float exposureF;
|
|
flat varying float fogAmount;
|
|
flat varying float VFAmount;
|
|
|
|
uniform sampler2D colortex4;
|
|
uniform sampler2D noisetex;
|
|
|
|
uniform int frameCounter;
|
|
uniform float rainStrength;
|
|
uniform float eyeAltitude;
|
|
uniform vec3 sunVec;
|
|
uniform vec2 texelSize;
|
|
uniform float frameTimeCounter;
|
|
uniform mat4 gbufferProjection;
|
|
uniform mat4 gbufferProjectionInverse;
|
|
uniform mat4 gbufferPreviousProjection;
|
|
uniform mat4 gbufferModelViewInverse;
|
|
uniform mat4 gbufferModelView;
|
|
uniform mat4 shadowModelView;
|
|
uniform mat4 shadowProjection;
|
|
uniform float sunElevation;
|
|
uniform vec3 cameraPosition;
|
|
uniform float far;
|
|
uniform ivec2 eyeBrightnessSmooth;
|
|
|
|
|
|
#include "/lib/util.glsl"
|
|
|
|
|
|
vec3 toShadowSpaceProjected(vec3 p3){
|
|
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
|
p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
|
p3 = diagonal3(shadowProjection) * p3 + shadowProjection[3].xyz;
|
|
|
|
return p3;
|
|
}
|
|
float interleaved_gradientNoise(){
|
|
vec2 coord = gl_FragCoord.xy;
|
|
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+frameCounter/1.6180339887);
|
|
return noise;
|
|
}
|
|
float blueNoise(){
|
|
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
|
}
|
|
vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.);
|
|
const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0);
|
|
|
|
#include "/lib/nether_fog.glsl"
|
|
|
|
void main() {
|
|
/* DRAWBUFFERS:4 */
|
|
|
|
gl_FragData[0] = vec4(0.0,0.0,0.0,0.0);
|
|
|
|
vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0);
|
|
//Sky gradient with clouds
|
|
if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){
|
|
|
|
// vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0);
|
|
vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2);
|
|
vec3 viewVector = cartToSphere(p);
|
|
|
|
// vec3 BackgroundColor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.01)) / 30.0;
|
|
// BackgroundColor *= abs(viewVector.y+0.5);
|
|
vec3 BackgroundColor = vec3(0.0);
|
|
|
|
vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887));
|
|
BackgroundColor += VL_Fog.rgb/5.0;
|
|
|
|
gl_FragData[0] = vec4(BackgroundColor,1.0);
|
|
}
|
|
|
|
//Temporally accumulate sky and light values
|
|
vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb;
|
|
vec3 curr = gl_FragData[0].rgb*150.;
|
|
gl_FragData[0].rgb = clamp(mix(temp,curr,0.05),0.0,65000.);
|
|
|
|
//Exposure values
|
|
if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
|
gl_FragData[0] = vec4(exposure,avgBrightness,exposureF,1.0);
|
|
if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
|
gl_FragData[0] = vec4(rodExposure,0.0,0.0,1.0);
|
|
|
|
}
|