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 17 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

@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
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

@superfloh247
Copy link
Contributor

could you please update this branch/PR to latest master?

b7e886a fixes building with LTO (at least for me) and that's a major performance boost (at least for me)

@nerzhul
Copy link
Member

nerzhul commented Jun 11, 2024

clearly an amazing addition, like if it was minetest 2.0 revival, sorry i'll try to review the C++ part, i'm not very nice on shaders.
With a such thing, it can clearly make people adopt more minetest than MC (we are not concurrent) for gameplay (we should work on NPCs !)

@appgurueu appgurueu added this to the 5.10.0 milestone Jun 18, 2024
@Wbjitscool
Copy link

Wbjitscool commented Jun 21, 2024

I know what else would be awesome to see is that entities like players etc and blocks could also reflect off the water too

@GefullteTaubenbrust2
Copy link
Author

I know what else would be awesome to see is that entities like players etc and blocks could also reflect off the water too

There is actually a branch by @GreenXenith that adds screenspace reflections that he is planning to add at some point. It could replace these water reflections.

@lhofhansl lhofhansl removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jun 22, 2024
@lhofhansl
Copy link
Contributor

lhofhansl commented Jun 22, 2024

@grorp 's comments were addressed.

@ezileicorreia

This comment was marked as off-topic.

@lhofhansl
Copy link
Contributor

lhofhansl commented Jul 3, 2024

Do we need to wait for 5.10.0 for this? I'm afraid we'll let another good contribution bit-rot.
I've had this applied for almost 8 weeks and have not observed any issues.

Inlined setShadowTint function, fixed issue where third person view or getting close to nodes causes weird artefacts with their specular reflections
@Zughy
Copy link
Member

Zughy commented Jul 5, 2024

Yes, feature freeze applies to everyone

Fix specular intensity not applying
@nerzhul
Copy link
Member

nerzhul commented Jul 6, 2024

i'd say, release, and merge just after, let people feedback us on 5.11-dev cycle and go ahead :)

@grorp
Copy link
Member

grorp commented Jul 12, 2024

I see @lhofhansl removed "Action/change needed", yet #14610 (review) by @sfan5 still has unresolved comments. What happened there?

@GefullteTaubenbrust2
Copy link
Author

I see @lhofhansl removed "Action/change needed", yet #14610 (review) by @sfan5 still has unresolved comments. What happened there?

They should all be adressed (except one that I don't know how to improve) they just aren't marked as resolved.

@lhofhansl
Copy link
Contributor

lhofhansl commented Jul 15, 2024

@grorp You requested changes and the label, those changes were made so I removed the label. Nothing nefarious here :)
I'm not aware of any requested changes other than @nerzhul's minor request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet