-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Render shadows on entities. #11747
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
Render shadows on entities. #11747
Conversation
3067fe2 to
3a906b3
Compare
|
Normals look good with the latest change and minetest/irrlicht#77: |
|
That's caused by changes made in IrrlichtMt commit 52e03a that required fixes to the engine, and this PR is based off of an older commit of the engine which doesn't contain the fixes. Checkout dd09fd in IrrlichtMt and it should compile without issues (no difference in behavior anyways, it's just unused code removal). |
c2be311 to
fbd3cdf
Compare
|
@Andrey2470T @rollerozxa I've rebased the branch to the latest master and checked that it compiles with the current tip of IrrlichtMt. |
|
Tested that shadows affect entities and that entities are properly self-shading, including player entities. Pretty cool! |
|
@x2048 What's left for this one? Looks good. Based on that, set "One Approval". I realize this is marked as WIP, but it seems to work pretty well. |
|
@lhofhansl It was long ago, and I need to review the code myself :) Phantom shadows appeared as tiny spots at certain angles, when there were nearby entities. I'll look if I can reproduce it. |
|
:) I think this is needed to "complete" shadow functionality. |
|
@lhofhansl I've narrowed the phantom shadows to a problem with materials in upright_sprite entities. The most noticeable change is that player has a shadow in devtest now. I've checked that entities in devtest cast and accept shadows correctly, but extra testing would always help. I've removed One Approval and requested a review for the new code when you have time. |
Add compatibility with colored shadows.
Pass correct natural & artificial light to the shaders Use natural/artificial light ratio for correct rendering of shadows
Detect non-zero normals which point in the opposite direction from the face plane normal.
Fixes shadows of animated sprite entities
Avoid using read only materials in mesh scene node, as it confuses shadow renderer.
f1a5dc2 to
cef252b
Compare
|
|
||
| if (PCFBOUND == 0.0) return 0.0; | ||
| // Return fast if sharp shadows are requested | ||
| if (PCFBOUND == 0.0) |
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.
Nit: Looks like this a duplicate.
|
The soft-shadow stuff is still weird, and leads to strange artifacts. Also for a different PR - or maybe we just remove that code and/or replace it with something simpler (not depth dependent). Then we can rethink #11944 and control both strength a softness via an API. |
|
I do not think we have to wait with this one. If there are bugs, we can file additional PRs. Without this shadows are not visually complete. |
|
@lhofhansl There's one last change I have in the works while I am on it, and I'll move to merging. One thing I noticed is that bias0 of 0.9 is very aggressive, causing significant undersampling of all shadows farther than rougly 10% of the shadow distance. Value of 0.8 gives a smoother curve and contributes to removing shadow acne. |
Remove use of magic constants. Apply cameraOffset Calculate distance projected on SM plane
|
For the record, the texelSize expression in the shaders is the solution of the following equation for d: where r is texture resolution, and x is distance between player and vertex projected on the shadow map. @lhofhansl I have not seen the artifact before, but I guess it is related to the precision of perspective factor transformation, and the center of this circle is the center of the SM texture. |
|
This is because the normal bias is quite small right now, and PCF filter leaks shadow. I want to adjust perspective bias first, then normal bias, and then PCF filter radius, but not in this PR (and I'm well aware this looks like a regression). |
|
@x2048 Cool. Let's merge this one and get it out of the way. :) |






Fixes a number of problems with how shadows are applied to entities:
What I've done so far:
What's left
This PR is Ready for Review
How to test
Another test: