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

Implement trapezoidal shadow maps (TSM) #599

Closed
jedStevens opened this issue Mar 18, 2020 · 5 comments
Closed

Implement trapezoidal shadow maps (TSM) #599

jedStevens opened this issue Mar 18, 2020 · 5 comments

Comments

@jedStevens
Copy link

I was thinking of implementing TSM for the engine, but I'm not sure it's worth it if Vulkan is coming. I suppose it could be useful for 3.2 users. Let me know if this is something worth while.

This link describes the technique: https://www.comp.nus.edu.sg/~tants/tsm/tsm.pdf

Essentially it transforms the shadow maps into a trapezoid shape to increase quality of shadows. I notice in 3.2 there are some ugly artifacts with directional lights and it'd be a nice option to flick on TSM for the light to increase the shadow quality.

I assume that Godot doesn't do this already but I thought I'd leave it here for now to start a discussion on the quality of the shadows as is.

This could be a good solution, unless someone has a better idea in the works I am unaware of.

@jedStevens
Copy link
Author

I did some poking around and I am not too well versed on the generation of shadows, but from what I understand, each light renders the depth pass of the frustum from its perspective. The whole point of this technique would be to skew the coordinates of the render to fit the frustum to the full texture size, now I'm not sure what we can do to intercept the shadow map generation but I imagine this technique could be stored in a matrix and applied during the depth pass render. I wonder if passing some augmentation matrix could work, but I'm not exactly sure where, if anyone has any ideas on how I could augment the depth pass that would help, because it almost looks like its just linking some depth pass to the shadow map.

@Calinou
Copy link
Member

Calinou commented Mar 20, 2020

Related to #262. Is this a different technique?

@jedStevens
Copy link
Author

jedStevens commented Mar 21, 2020

Looks different. After some skimming, I don't see the same math or technique but that one seems to improve the quality a bit. I think in that one he is stretching the AABB of the frustum up to get less of the pixelation on the edge although you can still see a bit of the same pixelation in the second image they provided.

I think the frustum could be corrected even more by getting the bound trapezoid of the frustum then scaling that to the full texture resolution of the depth map. Also I think that snippet is good as an addon for now but it would be nice to have that as an option in the directional light eventually.

I'll keep trying to augment the shadowmaps using TSM in my own fork for now, and I'll make a PR when I'm done.

@Calinou
Copy link
Member

Calinou commented Apr 30, 2020

Now that godotengine/godot#37678 was merged, shadowmapping quality was hugely improved.

@jedStevens Please test the current master branch and tell me whether the new shadow maps look good enough for your use cases. I'm not sure if TSM can be implemented in tandem with the current techniques anyway.

@Calinou Calinou changed the title (TSM) Trapezoidal Shadow Maps Implement trapezoidal shadow maps (TSM) May 5, 2020
@Calinou
Copy link
Member

Calinou commented Jun 19, 2020

Closing per the above comment.

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

No branches or pull requests

2 participants