fix opacity jitter

This commit is contained in:
2019-02-25 02:27:45 +01:00
parent abca1d5162
commit 87044e06c4
2 changed files with 5 additions and 5 deletions

View File

@@ -100,11 +100,11 @@ void main()
fg.rgb = mix(fg.rgb, mbg.rgb, mix_alpha * mbg.a);
}
mediump float contribution = (opacity - bg.a) * fg.a;
mediump float contribution = max(0.0, opacity - bg.a) * fg.a;
mediump float alpha_tot = bg.a + contribution;
mediump vec3 rgb = mix(bg.rgb, fg.rgb, fg.a / alpha_tot);
mediump vec3 rgb = mix(bg.rgb, fg.rgb, clamp(fg.a / alpha_tot, 0.0, 1.0));
mediump vec4 frag_wet = vec4(rgb, max(bg.a, fg.a * 1.2));
mediump vec4 frag_dry = vec4(rgb, min(alpha_tot, opacity));
mediump vec4 frag_dry = vec4(rgb, alpha_tot);
frag = mix(frag_dry, frag_wet, wet);
}

View File

@@ -330,9 +330,9 @@ bool ShaderManager::load(kShader id, const std::string& path)
bool ShaderManager::reload()
{
bool success = true;
bool success = false;
for (auto& s : m_shaders)
success &= s.second.reload();
success |= s.second.reload();
return success;
}