Spaces:
Build error
Build error
File size: 2,167 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
#version 150
uniform sampler2D MainSampler;
uniform sampler2D MainDepthSampler;
uniform sampler2D TranslucentSampler;
uniform sampler2D TranslucentDepthSampler;
uniform sampler2D ItemEntitySampler;
uniform sampler2D ItemEntityDepthSampler;
uniform sampler2D ParticlesSampler;
uniform sampler2D ParticlesDepthSampler;
uniform sampler2D WeatherSampler;
uniform sampler2D WeatherDepthSampler;
uniform sampler2D CloudsSampler;
uniform sampler2D CloudsDepthSampler;
in vec2 texCoord;
#define NUM_LAYERS 6
vec4 color_layers[NUM_LAYERS];
float depth_layers[NUM_LAYERS];
int active_layers = 0;
out vec4 fragColor;
void try_insert( vec4 color, float depth ) {
if ( color.a == 0.0 ) {
return;
}
color_layers[active_layers] = color;
depth_layers[active_layers] = depth;
int jj = active_layers++;
int ii = jj - 1;
while ( jj > 0 && depth_layers[jj] > depth_layers[ii] ) {
float depthTemp = depth_layers[ii];
depth_layers[ii] = depth_layers[jj];
depth_layers[jj] = depthTemp;
vec4 colorTemp = color_layers[ii];
color_layers[ii] = color_layers[jj];
color_layers[jj] = colorTemp;
jj = ii--;
}
}
vec3 blend( vec3 dst, vec4 src ) {
return ( dst * ( 1.0 - src.a ) ) + src.rgb;
}
void main() {
color_layers[0] = vec4( texture( MainSampler, texCoord ).rgb, 1.0 );
depth_layers[0] = texture( MainDepthSampler, texCoord ).r;
active_layers = 1;
try_insert( texture( TranslucentSampler, texCoord ), texture( TranslucentDepthSampler, texCoord ).r );
try_insert( texture( ItemEntitySampler, texCoord ), texture( ItemEntityDepthSampler, texCoord ).r );
try_insert( texture( ParticlesSampler, texCoord ), texture( ParticlesDepthSampler, texCoord ).r );
try_insert( texture( WeatherSampler, texCoord ), texture( WeatherDepthSampler, texCoord ).r );
try_insert( texture( CloudsSampler, texCoord ), texture( CloudsDepthSampler, texCoord ).r );
vec3 texelAccum = color_layers[0].rgb;
for ( int ii = 1; ii < active_layers; ++ii ) {
texelAccum = blend( texelAccum, color_layers[ii] );
}
fragColor = vec4( texelAccum.rgb, 1.0 );
}
|