-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Various visual effects #14508
Various visual effects #14508
Conversation
Little fix
Most notably, (hopefully) fixed network protocols
Oops that part is redundant
Use the adjusted fog rendering from the nodes shader
Do this work on OpenGL ES 2? |
I haven't checked thoroughly but it should |
Main fix is to the translucency effect, as it didn't take into account nodes that are tinted by the vertex color
This is hardly worthy of a commit but it bugged me
Nice. Note, we already have tinted sunlight (as long as volumetric light and shadows are enabled). Is this in addition? |
We do? I mean the volumetric light is tinted, but the light illuminating nodes is always white/grey isn't it? I'm confused |
Sorry, yes, misunderstood. |
builtin/settingtypes.txt
Outdated
# - default: Neutral, white light. | ||
# - medium: Slightly warmer color than default. | ||
# - warm: Warm (yellowish-orangy) light. | ||
artificial_light (Artificial light color) enum default default,medium,warm |
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.
This needs shaders on, let's move it in that section, and require shaders
# When enabled, liquid reflections are simulated. | ||
# | ||
# Requires: shaders, enable_waving_water, enable_dynamic_shadows | ||
enable_water_reflections (Liquid reflections) bool false |
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.
Hmm... Should this be here, or also under shaders? I feel like this into the shader section.
} | ||
|
||
float wave_noise(vec3 p, float off) { | ||
return snoise(p + vec3(0.0, 0.0, off)) * 0.4 + snoise(2.0 * p + vec3(0.0, off, off)) * 0.1 + snoise(3.0 * p + vec3(0.0, off, off)) * 0.075 + snoise(4.0 * p + vec3(-off, off, 0.0)) * 0.05; |
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.
Is there a simpler way? We call snoise 4 times here, then later we call wave_noise 3 times.
In the vertex shader we're only calling snoise once to get the wave pattern.
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.
Good point, the 4 calls in wave_noise i know seem a bit much and it’s one more than would technically be needed for regular fractal noise - however, especially with these reflections, any artifacts in the noise show very clearly and these 4 just look significantly better.
The fact wave_noise has to be called three times is because we need normal information in the fragment shader, which we don’t need in the vertex shader. I did implement it for the vertex shader in my „shader pack“ for 5.8.0 and that does almost definitely improve performance, but also shows very distinct artifacts.
With many functions you can get their gradient as an analytical function, but I‘m not sure how that would work with noise like this. I could look into using analytical functions like sine waves instead of noise, which would reduce the calls to effectively 2 calls to the „noise“ function, but it would introduce periodicity and I‘m not sure about the performance improvement.
If anyone else has ideas as to how to optimize this, let me know.
Edit: Actually, looking at the noise function again… the smooth noise samples a not so smooth function several times already, so in principle the normal information is there… I might be able to work something out.
@@ -262,14 +265,14 @@ void main(void) | |||
|
|||
if (f_timeofday < 0.2) { | |||
adj_shadow_strength = f_shadow_strength * 0.5 * | |||
(1.0 - mtsmoothstep(0.18, 0.2, f_timeofday)); |
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.
Can you explain the magic number changes?
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.
Simple reason is the old values don't look very good imo, especially during sunsets the shadows fade far too quickly. This is basically a function for shadow strength over time, so I've plotted that here. Blue is the original, red is the changed one.
It should be pretty apparent why sunsets would be especially washed out. The old function is also very strangely asymmetric, which is odd if you think about the physical implications of that, and the new one isn't. I suppose it makes sense that the shadows change faster when the moon rises and sets compared to the sun, so that might make sense to change back to be fair.
const float gamma = 1.6; | ||
const float exposureBias = 5.5; | ||
color.rgb = uncharted2Tonemap(exposureBias * color.rgb); | ||
// Precalculated white_scale from | ||
//vec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W)); | ||
vec3 whiteScale = vec3(1.036015346); | ||
color.rgb *= whiteScale; | ||
return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a); |
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 do you no longer need the light-space transformations?
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.
They looked very strange to me and created very harsh contrast and oversaturated colors, which as far as I know is exactly what the gamma correction was there to prevent. I’ll post a comparison later.
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.
So actually this has to do with #14109, I'll have to look deeper into that...
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.
I might have some time this weekend, I suppose I'll just add it back. |
reintroduces eyePosition uniform
Water reflections don't work on windows, neither does volumetric lights, bloom, or just about any other shader besides the shadows. |
Using OpenGL3 render engine on the debug build results in
|
@Infernia829 You verified it works without this applied? You built the same way? |
Baseline MT works, yes. However none of the listed shaders/visual effects work in any way, shape, or form. I tried over 20 different combinations of settings, cmake settings, and more, no matter what I did I was unable to get your shaders working. What I sent above was the only error messages I was able to get, otherwise the shaders just didn't load, it looked the same as it did with them disabled. |
The nodes_shader error are fixed now =D |
Please make a clear statement :)
Finally, I have a local change that brings back the needed parts removed in #14516 combined with this, and that is all working fine (on Linux) |
MT build from master works fine, but again it is lacking all the features that don't work anyway. MT build from master with this PR applied is broken. |
This sounds absolutely beautiful and I can't wait to see the PR approved if there are no issues blocking it! Water reflections are a long awaited last piece of the puzzle ever since the other effects were finally added: All that will be left is support for specular and normal maps in some form, it can be done with our lighting system but will likely require an original approach to get a 3D reflection volume right. Realistic sun / moon colors that get yellow then red near the horizon are another thing I've always hoped to see changed, thank you for addressing that! The only huge limitation left as far as lights go is that in nearly 20 years of Minetest, no attempt has been made to support colored light sources so you can for example have a green lamp: I'm hoping that someday this final blocker can be lifted which will open the doors to a lot of new possibilities. |
Does this add actual water reflections like in GreenXenith's bfs_ssr branch though? From what I can see, it's "just" some fancy lighting. |
Nope it just adds simple sun reflection. |
I did not suggest that. I also prefer imperfect solutions over no solutions. My goal was to correct possibly false expectations expressed in #14508 (comment) and #14508 (comment). |
@grorp I also like real reflection. :) Did ever get @GreenXenith's ssr branch to work? I tried half-heartedly and all I get is blank screen as soon as the game starts. |
I agree, I would rather migrate my SSR branch (to replace the simple reflections probably) after this is merged. |
I suggest that we could include the following effects with relatively little discussion with just client settings:
I don't know what the following do:
The following perhaps need some discussion:
I will say that overall this quite increases the immersion. The colors are better, and the simple sun reflection makes it look like real water. |
The split proposed by lhofhansl seems sensible to me. Re "vignette": A vignette can be implemented as a mod or even a client mod using the HUD API. Some games already do this, e.g. Repixture. Therefore, I think having it as a client-side setting is unnecessary and may result in multiple vignettes being applied on top of each other. |
That is kinda dumb, a client side vignette would be so much better then some sort of hack hud api, why would you purposfully remove it when its already been made |
So you're saying that a shader vignette is better than a HUD API vignette? Why? The benefit of vignettes via the HUD API is that they can be customized (e.g. their strength) by games/mods depending on player status effects, and that this works without any explicit support from Minetest. Surely we could also make a shader vignette customizable, but that would need another API. Re "a client side vignette would be so much better": Strictly speaking, a vignette implemented via a client mod is also client-side. |
Strictly speaking, once you send the vignette HUD element from a regular mod it is also client-side. |
True that, I just moved that one over from my shaderpack without realizing there is a vignette effect already. Although I think the hud based vignette suffers from banding, so I may at some point look into that instead. |
OT but: same with formspecs. Just put a perfect shade as a formspec image and you'll see the banding effect. I discovered this the other day (MT 5.8) |
What about user choice? In lots of cases, HUD vignette looks way worse than the post process alternative. There also games that don't add the effect, what if the user wants to enable it while playing them? |
There's actually another issue, which is the HUD is applied after everything is rendered out, but color grading for example should actually apply after the vignette... Not sure how to solve this, I suppose I could also add lua options for a vignette as part of the second stage shaders? That would also allow the user to still add mods that add the vignette. None of this will be in the first PR, but it's still important to think about... |
This PR adds various effects intended to improve the visual experience. This includes changes to the shader code, as well as the engine source code, Lua API and settings.
List of Features and Changes
Lua API additions
shadow
field controls the color of the cloud's baseshadow_tint
controls shadow color{ r = 0, g = 0, b = 0}
{ r = 0, g = 50, b = 180 }
Settings
Screenshots
To do
This PR is Ready for Review.
How to test
For most features, simply change the game settings. Of course, the game you use should support dynamic shadows and volumetrics.
The added Lua properties can be used like so: