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 10 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…

@@ -46,7 +46,7 @@ float sampleVolumetricLight(vec2 uv, vec3 lightVec, float rawDepth)
if (min(samplepos.x, samplepos.y) > 0. && max(samplepos.x, samplepos.y) < 1.)
result += texture2D(depthmap, samplepos).r < 1. ? 0.0 : 1.0;
}
return result / samples;
return result / samples * pow(texture2D(depthmap, uv).r, 128.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this one?
Maybe add a short comment here in the code, too.

Choose a reason for hiding this comment

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

So basically, the closer an object is to us, the less air we are looking through that scatters light, hence the pixel should not be as bright. The exponent of 128 is just a value that made it look reasonable to me.

@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'm happy to have this merged - with redundant snoise removed and the pre-preprocessor stuff (that @GefullteTaubenbrust2 mentioned) fixed.
I'll give my conditional "One Approval"

@GefullteTaubenbrust2
Copy link
Author

I'm happy to have this merged - with redundant snoise removed and the pre-preprocessor stuff (that @GefullteTaubenbrust2 mentioned) fixed. I'll give my conditional "One Approval"

Awesome! I do have an idea on how to fix the „jello“ thing too, hoping to have everything done this weekend.

@tigercoding56
Copy link

tigercoding56 commented May 15, 2024

Awesome! I do have an idea on how to fix the „jello“ thing too, hoping to have everything done this weekend.

when done please share some screenshots :D

@GefullteTaubenbrust2
Copy link
Author

GefullteTaubenbrust2 commented May 20, 2024

Sorry for the slight delay :p
Heres what I came up with:
screenshot_20240520_203818
screenshot_20240520_203803
screenshot_20240520_203810
By no means a perfect solution, it too suffers from artefacts, but it fixes some of the more egregious jello.

Removed redundant stuff from nodes shader and made smooth normals for liquids.
Copy link
Member

@grorp grorp left a comment

Choose a reason for hiding this comment

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

Some feedback:

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

    ERROR[Main]: Irrlicht: GLSL (> 2.x) shader failed to compile: shaderType: 35632
    ERROR[Main]: Irrlicht: 0(515) : error C1503: undefined variable "WATER_WAVE_SPEED"
    0(516) : error C1503: undefined variable "WATER_WAVE_LENGTH"
    0(517) : error C1503: undefined variable "WATER_WAVE_LENGTH"
    0(521) : error C1503: undefined variable "WATER_WAVE_HEIGHT"
    
    ERROR[Main]: generate_shader(): failed to generate "nodes_shader", addHighLevelShaderMaterial failed.
    

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

  2. Volumetric lighting looks less cool than before.
    before:
    before
    after:
    after

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

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

  5. 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:

    screenshot of jello

@tigercoding56
Copy link

Sorry for the slight delay :p Heres what I came up with: By no means a perfect solution, it too suffers from artefacts,.... but it fixes some of the more egregious jello.

don't worry about the delay :P. the jello looks acceptable now (especially in inside block corners) . to the person above i think the god rays changed intensity and the shadows may be a bit brighter? i personally like it but maybe it should be a setting

@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

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

8 participants