Skip to content
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

Visual Effects Vol. 1 #14610

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

GefullteTaubenbrust2
Copy link

@GefullteTaubenbrust2 GefullteTaubenbrust2 commented May 4, 2024

This PR is based on #14508 and adds a variety of effects to enhance the visual experience. To this end, it makes changes to shader code, as well as the engine source code, the Lua API and settings.

List of Features and Changes
  • "soft" clouds look
  • Tinted shadows
  • Crude water reflections (sky and sun) and waves
  • Translucent foliage
  • Node specular hihlights
  • Adjusted fog color (more saturated where the fog is lighter)
  • Minor changes to volumetric lighting (crudely simulates the effect of depth)

Lua API additions

  • Cloud parameters: shadow field controls the color of the cloud's base
  • Lighting: tint controls shadow color
    • default would be black { r = 0, g = 0, b = 0}
    • ambient light from the sky could be emulated by a blue color like { r = 0, g = 50, b = 180 }

Settings

Name Technical Name Location Type Default
Soft clouds soft_clouds Graphics>Clouds bool false
Liquid reflections enable_water_reflections Shaders>Waving Nodes bool false
Translucent Foliage enable_translucent_foliage Shaders>Other Effects bool false
Node specular enable_node_specular Shaders>Other Effects bool false
Screenshots

screenshot_20240504_201730
screenshot_20240504_201612
screenshot_20240504_201455
screenshot_20240504_202011

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:

player:set_clouds({shadow = { r = 120, g = 160, b = 240 }})
player:set_lighting(shadows = { intesity = 0.5, tint = { r = 0, g = 50, b = 180 }})

Revert changes to shadow strength, this probably warrants discussion later. Also, the objects shader was missing this anyway.
Fix bad whitespaces
- "Node reflections" renamed to "node specular"
- Fixed goofy artefacts for the foliage effects
@lhofhansl
Copy link
Contributor

Tried it, works well. I'll try to find some time in today or tomorrow evening to do a proper review.

@lhofhansl
Copy link
Contributor

Sorry. Very busy work week. Haven't gotten to it, yet.

}

#if (defined(MATERIAL_WAVING_LIQUID) && defined(ENABLE_WATER_REFLECTIONS)) || defined(ENABLE_BUMPMAPS)
float snoise(vec3 p)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snoise is not used in this shader as far as I can tell... Only gnoise

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, i think the preprocessor stuff is also not in the right place…

@lhofhansl
Copy link
Contributor

Left two nits... Looks pretty good otherwise.
I'll look at it again in more detail next week, but if folks want to merge this, that'd be OK with me.

@lhofhansl
Copy link
Contributor

screenshot_20240510_171750

Flowing water looks a bit weird perhaps, maybe don't do the reflection for flowing water?

@tigercoding56
Copy link

tigercoding56 commented May 11, 2024

Flowing water looks a bit weird perhaps, maybe don't do the reflection for flowing water?

idk i like how it looks, kinda like jello . however maybe some rounding of the corners would be nice (like by interpolating between normals idk i can't glsl)
image

@Wbjitscool
Copy link

Wbjitscool commented May 11, 2024

yeah I like the reflective water too I think it looks good although you can always change it to look a bit different if you don't like it tho

@GefullteTaubenbrust2
Copy link
Author

Yeah the water is a bit goofy with slopes… It looks awkward without the reflections, and smoothing the normals isn’t exactly trivial, but I‘ll look into it.

@Wbjitscool
Copy link

Wbjitscool commented May 11, 2024

yeah thanks also any ideas for the god rays to have a setting to control the strength of it too

@ryvnf
Copy link
Contributor

ryvnf commented May 11, 2024

Can the water reflections be generalized to other nodes? Like having nodes specify (possibly animated) normal maps together with an option to enable it?

@tigercoding56
Copy link

tigercoding56 commented May 12, 2024

Can the water reflections be generalized to other nodes? Like having nodes specify (possibly animated) normal maps together with an option to enable it?

probably out of scope but i like the idea. maybe also a option to specify a cube map (to reflect from) , oh and maybe costum node shaders in lua ? , yeah definitely out of scope.

@Wbjitscool
Copy link

yeah thanks also any ideas for the god rays to have a setting to control the strength of it too
Yeah tested and works for Mineclonia but VoxeLibre isn't updated to support the sunrays yet anyway

@Wbjitscool
Copy link

Wbjitscool commented May 12, 2024

is there a way to fix this problem you place a full block over the water and the water glitches out with shaders on the screenshot doesn't work

@tigercoding56
Copy link

is there a way to fix this problem you place a full block over the water and the water glitches out with shaders on the screenshot doesn't work

did you enable waving water by any chance , if so try disabling it (it sometimes does not render water under block correctly)

@Wbjitscool
Copy link

Wbjitscool commented May 13, 2024

yep I have waving shaders enabled just disabled it now it renders the water properly but I want the shaders to be on as the liquid shows as a full block and I don't like that I prefer the water to be at least a node below the full block

@tigercoding56
Copy link

tigercoding56 commented May 13, 2024

yep I have waving shaders enabled just disabled it now it renders the water properly but I want the shaders to be on as the liquid shows as a full block and I don't like that I prefer the water to be at least a node below the full block

make a github issue, i think the bug is in water shader as it is a bug even without using GefTau's shader (just with stock minetest)

@Wbjitscool
Copy link

yeah okay

@grorp grorp added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label May 21, 2024
@lhofhansl
Copy link
Contributor

@grorp The volumetric strength can be configured - by the server and client. The change makes it more "correct' (more natural, see explanation above)

The "Jello" effect is OK, IMHO. Not sure how else we would tweak the reflections there. Perhaps we can just not have flowing water have specular reflections. I do not think that stops this PR.

For node specular you have to be at the right angle so that the sun reflects to you. For me that works just fine.

Perhaps like @GefullteTaubenbrust2 I had expected that disabling a setting would disable all settings depending to their default. In any case, this has to be fixed.

@GefullteTaubenbrust2
Copy link
Author

GefullteTaubenbrust2 commented May 22, 2024

Some feedback:

  1. There's a shader compilation error when enabling "Waving Liquids" and "Liquid Reflections", then disabling "Waving Liquids" again:

    Please make sure that all "invalid" setting cases are handled correctly.

Agreed that this needs addressing.

  1. Volumetric lighting looks less cool than before.

This is very intentional. While it may look „cooler“ when you get intense god rays at a close distance like this, it is actually an entirely non-physical artifact of the non-volumetric nature in the way „volumetrics“ are done. It may look cool in the case you posted, but the issues become more apparent when you have objects both very close and very far away from you being lit at the same level of brightness, it just doesn’t look right, because it physically doesn’t make sense. The brightness of the scattered light should decrease as the depth of the scattering volume decreases. I suppose it’s up for debate how much sense my simple power function makes as a fix, but it does create the expected effect that objects that are very close are affected less by the scattering.
I suppose though physical accuracy isn’t everything so maybe it could also be optional…

  1. Comparing the screenshots above, I can also see that something has changed about the way dynamic shadows look. What happened there?

Now you bring it up, that is true and I’m honestly not sure. I did notice something changed from when I was working on this before but I just attributed it to changes to post processing, but this is definitely something else and not intentional.

  1. What does "Node specular" do? I can't notice a difference between enabled and disabled.

The reason for that is because the specular is modulated by a fresnel effect, so it becomes most apparent when the sun is at a shallow angle.

  1. Even though you already mentioned that there are still "jello" artefacts, I'd like to point out that they're especially bad when looking up a hill:

It is sort of both in the nature of both the problem and the way minetest renders water that we see artifacts. Properly interpolating all the normals would not only require major changes to the mesh generation, but would also introduce artifacts of its own, so I don’t really have a „perfect“ fix for this.

@GefullteTaubenbrust2
Copy link
Author

Actually, it looks like the look of the dynmaic shadows changed simply because I set a bad default value for the tint. Probably left that in from debugging, very embarrassing indeed.

@Wbjitscool
Copy link

this works quite nicely now I really like the shaders in this

@lhofhansl
Copy link
Contributor

I will do a more in depth core review this evening. Is anything else in the way of this?

@tigercoding56
Copy link

I will do a more in depth core review this evening. Is anything else in the way of this?

i hope not it looks awesome
screenshot_20240530_194512
screenshot_20240530_194830
screenshot_20240530_194948

@Wbjitscool
Copy link

Wbjitscool commented May 31, 2024

yeah it dose but I noticed after a few days the the water sometimes starts randomly glitching for some reason and then it stops by glitching it flickers like crazy but it doesn't happen all the time but not sure what causes that it's nothing to do with the block on top of water business either some possibilities it could be either my pc's graphics card is having some strange issue trying to render it in or it could be a code somewhere that might be the cause of it if anyone else notices it then it will be clear it's nothing to do with my pc's graphics card but not sure yet

@Wbjitscool
Copy link

Wbjitscool commented May 31, 2024

screenshot_20240531_153451
but man this looks so cool in voxeLibre with my own texture pack

@lhofhansl
Copy link
Contributor

water sometimes starts randomly glitching

I don't see any code in this PR that would cause this.
I think you are seeing a version of #14159.

@@ -1,3 +1,10 @@
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_BASIC || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT)
#define MATERIAL_WAVING_LIQUID 1
#define MATERIAL_LIQUID 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MATERIAL_LIQUID is not used anywhere

@lhofhansl
Copy link
Contributor

@GefullteTaubenbrust2 Left two more nits. I think this is ready to be merged.

@Wbjitscool
Copy link

awesome I would love to see this merged

@Wbjitscool
Copy link

Wbjitscool commented Jun 1, 2024

next awesome pr for shaders clouds can be seen in reflecting water in the future

@lhofhansl
Copy link
Contributor

I also think that sky reflection effect could be a little softer (maybe replace the 0.5 factor in the shader with 0.4). This is visible especially at larger viewing distances. But we can change that later if we want to.

@Wbjitscool
Copy link

sorry about the duped text I had a bit of lag on my end that's why I must of clicked on it a few times for comment not knowing it would post or not

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first look

builtin/settingtypes.txt Outdated Show resolved Hide resolved
doc/lua_api.md Outdated Show resolved Hide resolved
@@ -8401,6 +8403,8 @@ child will follow movement and rotation of that bone.
* `shadows` is a table that controls ambient shadows
* `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
* This value has no effect on clients who have the "Dynamic Shadows" shader disabled.
* `tint` tints the shadows with the provided color, with RGB values ranging from 0 to 1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default?

if (translucent_foliage) {
const u32 leaves_shader = m_client->getShaderSource()->getShader("nodes_shader", TILE_MATERIAL_WAVING_LEAVES, NDT_ALLFACES);
leaves_material = m_client->getShaderSource()->getShaderInfo(leaves_shader).material;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good suggestion but this looks like totally breaking the abstraction.
Maybe it could be read from a TileLayer of an existing leaf node (NodeDefManager)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I find hard to fix... This is something that isn't so much inherent to the material as it is the shader really, so breaking the abstraction is kind of an inherent thing to the problem unfortunately. I'm open to suggestions but I have no idea how to improve it tbh...

src/client/clouds.cpp Outdated Show resolved Hide resolved
@@ -101,6 +101,11 @@ class Clouds : public scene::ISceneNode
m_params.color_ambient = color_ambient;
}

void setColorShadow(video::SColor color_shadow)
{
m_params.color_shadow = color_shadow;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comparison & mesh invalidation

c_side_2_f.b *= shadow.b * 0.66f + 0.33f;
c_bottom_f.r *= shadow.r;
c_bottom_f.g *= shadow.g;
c_bottom_f.b *= shadow.b;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the default of 204 this results in 0.92, 0.85, 0.8 (respectively)
which is different than before.

so now I have to ask: where do these magic numbers come from? what is the effect of the change?

src/client/game.cpp Outdated Show resolved Hide resolved
src/network/clientpackethandler.cpp Outdated Show resolved Hide resolved
GefullteTaubenbrust2 and others added 2 commits June 5, 2024 13:36
Co-authored-by: sfan5 <sfan5@live.de>
Also minor changes to fresnel factor
@lhofhansl
Copy link
Contributor

Sky reflection looks nicer now. All my nits are resolved.
I maintain my "One Approval"

@GefullteTaubenbrust2
Copy link
Author

GefullteTaubenbrust2 commented Jun 5, 2024

Oops i think the updateBox() call is redundant… I‘ll fix that soon

@DragonWrangler1
Copy link

DragonWrangler1 commented Jun 5, 2024

I compiled this to test it, and wow. This is incredible. Great job

@superfloh247
Copy link
Contributor

superfloh247 commented Jun 8, 2024

very impressive!

MacOS 14, apple silicon M1pro

screenshot_20240606_072006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) @ Client / Audiovisuals Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️ @ Script API Shaders
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants