New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the server to control fog_distance and fog_start via the sky-api #13448
Conversation
16e2f20
to
3eb6186
Compare
BTW. I like the model that the server can force a value, and if the server game/mod does not care then that client gets to control it. Orbital tilt was the first to do that. |
Yes, please. Right now people can cheat by disabling fog, so modders are forced to lower clouds and put players inside them to emulate the effect |
@Zughy Just be clear, viewing range is still limited when fog is disabled... (Unlike viewing range all). So you cannot cheat into seeing more when the server limits the fog distance (which is effectively the client's viewing_range) |
Question: In order to do what we want in #13421 we would have to override MT's logic to determine the sky color, specifically the logic that determines the average lighting around the player and choose a black background if there is no (or little) light. Do we want that? It's not really about setting the color (you can already set the sky/fog color) but about optionally disabling the "darkness-check". |
Given that MT poses itself as an engine, giving as much as possible control of these not-so-technical things is a natural thing to do. Not to mention it's a little bit buggy right now and can trigger when player's avatar just stands under an overhang, and not every game needs caves and all that stuff. Funnily enough, I thought about this thing just yesterday. And yes, calling |
OK. Then there is the question about the API. Could one of the following:
|
I haven't looked up how the darkness check thing works, or how useful it is, but it should definitely be possible to turn it off, for dehardcoding reasons. It kinda sounds like fog color is a somewhat complex topic. A separate PR may be better. |
This is ready... |
Nice! 🥇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried:
//lua local p=core.get_player_by_name("singleplayer"); p:set_sky({fog={fog_distance=10}})
and then:
//lua local p=core.get_player_by_name("singleplayer"); p:set_sky({fog={fog_distance=-1}})
But setting to -1
didn't work.
doc/lua_api.md
Outdated
* `fog_start`: float, override the client's fog_start. | ||
Fraction of the visible distance at which fog starts to be rendered. | ||
By default, fog_start is controlled by the client's `fog_start` setting, and this field is not set. | ||
Any value between [0.0, 0.99] set the fog_start as a fraction of fog_distance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 0.99? Is 0.999 not ok? A limit to percent feels weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what the client setting has (see settingtypes). It's can be 100 and more than 99 does not make sense.
See float fogShadingParameter = 1.0 / (1.0 - fogStart);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 0.99 is only to prevent a division by 0, right? But 0.99 is pretty arbitrary, it could also be 0.999, for example. My point is that it's kinda ugly to expose this to the API. Can't we just take [0.0, 1.0]
here, and hide the clamp as implementation detail in the client?
21b8f25
to
47af35b
Compare
Setting to -1 should work now. Did not realize that the client might keep its setting persistent. Should all work now. |
Issue I found while testing: The view distance setting shouldn't be limited by the fog distance. It should rather be independent instead.
|
Hmm... On the other hand setting a viewing_range on the client is also a performance setting. If the server sets it to 1000 that does not mean the client should immediately set it to 1000 if it was smaller before. We would have to remember the last manual client setting...? Even then, what if the viewing_range was 200, then server sets it 100, then the user reduces that 50. Now the server unsets it, what should it revert to? We can round to multiples of 10 of course. |
I'd say just let the user change their view distance setting freely, and only clamp the used value. So the actual view distance is always the minimum of the setting and the server-set value. |
@Desour That makes a lot of sense, I'll do that. |
@Desour How about this? |
Works. |
Anything else needed here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything else needed here?
Sorry, I forgot about this PR.
Still unresolved: #13448 (comment) and #13448 (comment)
Review comments addressed, except for the two that I kept unresolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine otherwise.
Just noticed a thing: It would be good if the server also used the fog distance as a limit to the block and object send distance, to avoid cheating with modified or old clients. Can be done in another PR though. |
The server relies on what client requests and its own max setting |
This enforces the fog_distance (if set) at the server, so that a hacked client could not cheat and retrieve blocks beyond the set distance.
minetest#13643) This enforces the fog_distance (if set) at the server, so that a hacked client could not cheat and retrieve blocks beyond the set distance.
See #13421 ...
Edit: Actually this does not, yet, achieve was is asked in #13421 . For that we need to override the fog color, and probably also disable MT's scanning of surrounding brightness to see if something is black (resulting in black fog)
Edit II: Color is actually not that easy to do. Has to work with and without shaders, etc, I'd prefer that as a separate PR.
There is no separate API to set the fog color. That is already possible via the sky_color.
Disabling fog (F3 by default) is still possible, the range is still enforced, so I wasn't sure about this. Easy to add if we wanted that.
To do
This PR is Ready for Review.
How to test
Test with shaders and without.
Set the fog distance/start via the API:
Try "unsetting" via a negative value. Messages on the client should make sense.
Set only one of the two, and make sure everything works as expected. (large fog_start with unchanged fog_distance enhances sunny days for example)