logarithmic fog parameter (logfog)

This commit is contained in:
Zeno Rogue 2022-04-07 20:50:59 +02:00
parent 589d2dd72c
commit 8c0600d8fe
2 changed files with 8 additions and 1 deletions

View File

@ -492,6 +492,8 @@ EX const char *conffile = "hyperrogue.ini";
/* extra space if more geometries are added */
EX array<ld, gGUARD+64> sightranges;
EX bool logfog;
EX videopar vid;
#define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5)
@ -774,6 +776,8 @@ EX void initConfig() {
param_b(vid.darkhepta, "mark heptagons", false);
param_b(logfog, "logfog", false);
for(auto& lp: linepatterns::patterns) {
addsaver(lp->color, "lpcolor-" + lp->lpname);
addsaver(lp->multiplier, "lpwidth-" + lp->lpname);

View File

@ -402,7 +402,10 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
}
else if(distfun != "") {
have_vfogs = true;
vmain += "vFogs = (uFogBase - " + distfun + " / uFog);\n";
if(logfog)
vmain += "vFogs = uFogBase * exp(- " + distfun + " / uFog);\n";
else
vmain += "vFogs = clamp(uFogBase - " + distfun + " / uFog, 0.0, 1.0);\n";
vsh +=
"uniform mediump float uFog;\n"
"uniform mediump float uFogBase;\n";