mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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_fogFactor;
|
||||||
uniform float u_fogCurve;
|
uniform float u_fogCurve;
|
||||||
uniform bool u_alphaClip;
|
uniform bool u_alphaClip;
|
||||||
|
uniform bool u_dithering;
|
||||||
uniform vec3 u_sunDir;
|
uniform vec3 u_sunDir;
|
||||||
|
|
||||||
const float BAYER_MATRIX[64] = float[](
|
const float BAYER_MATRIX[64] = float[](
|
||||||
|
|
@ -35,13 +36,17 @@ void main() {
|
||||||
vec4 texColor = texture(u_texture0, a_texCoord);
|
vec4 texColor = texture(u_texture0, a_texCoord);
|
||||||
float alpha = a_color.a * texColor.a;
|
float alpha = a_color.a * texColor.a;
|
||||||
// anyway it's any alpha-test alternative required
|
// anyway it's any alpha-test alternative required
|
||||||
if (u_alphaClip) {
|
if (u_dithering) {
|
||||||
float bayer = calc_bayer(gl_FragCoord.xy);
|
if (u_alphaClip) {
|
||||||
if (alpha - bayer < 0.01f) {
|
float bayer = calc_bayer(gl_FragCoord.xy);
|
||||||
|
if (alpha - bayer < 0.01f) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
alpha = 1.0;
|
||||||
|
} else if (alpha < 0.05f) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
alpha = 1.0;
|
} else if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
|
||||||
} else if (alpha < 0.05f) {
|
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
f_color = a_color * texColor;
|
f_color = a_color * texColor;
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) {
|
||||||
auto& shader = assets.require<Shader>("entity");
|
auto& shader = assets.require<Shader>("entity");
|
||||||
shader.use();
|
shader.use();
|
||||||
shader.uniform1i("u_alphaClip", false);
|
shader.uniform1i("u_alphaClip", false);
|
||||||
|
shader.uniform1i("u_dithering", 0);
|
||||||
|
|
||||||
for (const auto& [_, wrapper] : wrappers) {
|
for (const auto& [_, wrapper] : wrappers) {
|
||||||
if (wrapper->dirtySides) {
|
if (wrapper->dirtySides) {
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,7 @@ void WorldRenderer::renderOpaque(
|
||||||
}
|
}
|
||||||
|
|
||||||
entityShader.uniform1i("u_alphaClip", true);
|
entityShader.uniform1i("u_alphaClip", true);
|
||||||
|
entityShader.uniform1i("u_dithering", 1);
|
||||||
entityShader.uniform1f("u_opacity", 1.0f);
|
entityShader.uniform1f("u_opacity", 1.0f);
|
||||||
level.entities->render(
|
level.entities->render(
|
||||||
assets,
|
assets,
|
||||||
|
|
@ -512,6 +513,7 @@ void WorldRenderer::renderWeatherEffects(Camera& camera) {
|
||||||
float one = weather->fall.maxOpacity;
|
float one = weather->fall.maxOpacity;
|
||||||
float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
|
float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
|
||||||
entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
|
entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
|
||||||
|
entityShader.uniform1i("u_dithering", 0);
|
||||||
entityShader.uniform1f(
|
entityShader.uniform1f(
|
||||||
"u_opacity", weather->fall.opaque ? t * t : t
|
"u_opacity", weather->fall.opaque ? t * t : t
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue