mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
Merge pull request #968 from MihailRis/fix-weather-render
fix weather effects render
This commit is contained in:
commit
55a076ed6e
3 changed files with 14 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ uniform vec3 u_fogColor;
|
|||
uniform float u_fogFactor;
|
||||
uniform float u_fogCurve;
|
||||
uniform bool u_alphaClip;
|
||||
uniform bool u_dithering;
|
||||
uniform vec3 u_sunDir;
|
||||
|
||||
const float BAYER_MATRIX[64] = float[](
|
||||
|
|
@ -35,13 +36,17 @@ void main() {
|
|||
vec4 texColor = texture(u_texture0, a_texCoord);
|
||||
float alpha = a_color.a * texColor.a;
|
||||
// anyway it's any alpha-test alternative required
|
||||
if (u_alphaClip) {
|
||||
float bayer = calc_bayer(gl_FragCoord.xy);
|
||||
if (alpha - bayer < 0.01f) {
|
||||
if (u_dithering) {
|
||||
if (u_alphaClip) {
|
||||
float bayer = calc_bayer(gl_FragCoord.xy);
|
||||
if (alpha - bayer < 0.01f) {
|
||||
discard;
|
||||
}
|
||||
alpha = 1.0;
|
||||
} else if (alpha < 0.05f) {
|
||||
discard;
|
||||
}
|
||||
alpha = 1.0;
|
||||
} else if (alpha < 0.05f) {
|
||||
} else if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
|
||||
discard;
|
||||
}
|
||||
f_color = a_color * texColor;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) {
|
|||
auto& shader = assets.require<Shader>("entity");
|
||||
shader.use();
|
||||
shader.uniform1i("u_alphaClip", false);
|
||||
shader.uniform1i("u_dithering", 0);
|
||||
|
||||
for (const auto& [_, wrapper] : wrappers) {
|
||||
if (wrapper->dirtySides) {
|
||||
|
|
@ -198,4 +199,4 @@ void BlockWrapsRenderer::clearOrder(const BlockWrapper* const wrapper) {
|
|||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ void WorldRenderer::renderOpaque(
|
|||
}
|
||||
|
||||
entityShader.uniform1i("u_alphaClip", true);
|
||||
entityShader.uniform1i("u_dithering", 1);
|
||||
entityShader.uniform1f("u_opacity", 1.0f);
|
||||
level.entities->render(
|
||||
assets,
|
||||
|
|
@ -512,6 +513,7 @@ void WorldRenderer::renderWeatherEffects(Camera& camera) {
|
|||
float one = weather->fall.maxOpacity;
|
||||
float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
|
||||
entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
|
||||
entityShader.uniform1i("u_dithering", 0);
|
||||
entityShader.uniform1f(
|
||||
"u_opacity", weather->fall.opaque ? t * t : t
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue