It's GLES3.
The code I referred to does only handle fogging, but should still work.
void fragment(){
// vec2 uv = UV;
// uv.y += (0.01 * (sin(uv.x * 3.5 + (TIME*ripple_speed) * 0.35) + sin(uv.x * 4.8 + (TIME*ripple_speed) * 1.05) + sin(uv.x * 7.3 + (TIME*ripple_speed) * 0.45) / 3.0))*ripple_scale;
// uv.x += (0.12 * (sin(uv.y * 4.0 + (TIME*ripple_speed) * 0.5) + sin(uv.y * 6.8 + (TIME*ripple_speed) * 0.75) + sin(uv.y * 11.3 + (TIME*ripple_speed) * 0.2) / 3.0))*ripple_scale;
// uv.y += (0.12 * (sin(uv.x * 4.2 + (TIME*ripple_speed) * 0.64) + sin(uv.x * 6.3 + (TIME*ripple_speed) * 1.65) + sin(uv.x * 8.2 + (TIME*ripple_speed) * 0.45) / 3.0))*ripple_scale;
// NORMALMAP = texture(normalmap,uv*wave_scale).xyz;
float ref_str = refraction/VERTEX.z;
vec2 ref_ofs = (NORMALMAP.xy*ref_str)-(ref_str*0.5);
// ROUGHNESS = roughness;
// SPECULAR = specular;
// float foammask = texture(foam_texture,uv).r;
// vec4 foamcolor = mix(foamcolor_1*vec4(1,1,1,0),foamcolor_1,foammask);
// float foam2mask = texture(foam_texture,rotateUV(uv,vec2(0.5),90)).r;
// vec4 foam2 = foam2mask*foamcolor_2;
// vec4 foam = mix(foam2,foamcolor,foammask);
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
depth = depth * 2.0 - 1.0;
depth = PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
depth += VERTEX.z;
depth = exp(-depth * beer_factor);
float colorDepth = exp(-depth * beer_factor);
colorDepth = clamp(1.0-depth,-1.0,1.0);
// ALBEDO = mix(color.rgb,foam.rgb,foam.a);
// TRANSMISSION = vec3(transmission);
vec3 screenTexture;
if(depth>0.0){
depth = texture(DEPTH_TEXTURE, SCREEN_UV+ref_ofs).r;
depth = depth * 2.0 - 1.0;
depth = PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
depth += VERTEX.z;
depth = exp(-depth * beer_factor);
colorDepth = clamp(1.0-depth,0.0,1.0);
screenTexture = textureLod(SCREEN_TEXTURE,SCREEN_UV+ref_ofs,murkiness).rgb;
}
else{
screenTexture = texture(SCREEN_TEXTURE,SCREEN_UV).rgb;
}
ALPHA = clamp(mix(0.0,1.0,colorDepth+foammask+foam2mask),min_alpha,1.0);
ALBEDO = mix(screenTexture,ALBEDO,ALPHA);
ALPHA = 1.0;
}
This is my code, irrelevant parts are commented out. colorDepth is what I use for depth coloring, for now I leave depth the same(it could maybe be used).
Note that
if(depth>0.0){
is a placeholder, I tried a lot of different solutions but reverted to this when they didn't work. I know it won't work, I just have it there for now.
I think it should still work, especially because I've been declaring separate variables for the depth test(for debugging purposes).