mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-17 16:17:02 +08:00
* fix(renderer): defer uniform location retrieval and add view matrix in outline rendering * refactor(gameplay): encapsulate per-type vertex data into VertexData struct * feat(rendering): separate transparent blocks into discard and blend modes * feat(renderer): implement order-independent transparency * fix(shaders): reduce alpha discard threshold to 0.8
28 lines
587 B
GLSL
28 lines
587 B
GLSL
#version 460
|
|
|
|
layout (location = 0) out vec4 accum;
|
|
layout (location = 1) out float reveal;
|
|
|
|
in vec2 tc;
|
|
flat in int tex_layer;
|
|
in float v_depth;
|
|
layout (binding = 0) uniform sampler2DArray samp;
|
|
|
|
float weight(float z, float a) {
|
|
float intermediate = 0.03 / (1e-5 + pow(z / 200.0, 4.0));
|
|
|
|
return a * clamp(intermediate, 1e-2, 3e2);
|
|
}
|
|
|
|
void main() {
|
|
vec4 color = texture(samp, vec3(tc, tex_layer));
|
|
float alpha = color.a;
|
|
if (alpha < 1e-4) discard;
|
|
|
|
|
|
float w = weight(v_depth, alpha);
|
|
|
|
accum = vec4(color.rgb * alpha * w, alpha * w);
|
|
|
|
reveal = alpha;
|
|
} |