-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Can buildings make shadows? #7976
Comments
There's currently no easy way to do this. I did an experiment on this with I'd still be interested in seeing shadows as a part of core — perhaps we'll implement it some day. |
That's very awesome @mourner. I had to make some tweaks to get it working, so I hope you don't mind I've published it at https://bl.ocks.org/andrewharvey/9490afae78301c047adddfb06523f6f1 |
Awesome! One thing that didn't carryover from the demo is the semi-transparency — I hoped to get |
@mourner @andrewharvey thank you for the help |
I think opacity will have to be in the hands of the custom layer implementer now that we aren't rendering into a texture first. Two approaches to implement opacity here:
|
@ansis thanks! This makes sense. Maybe we can even get away with double-drawing for the building shadows layer (it may have a cool effect). |
@mourner Hi! Thanks for the example :). I tried setting this up in my project which uses v2.1.0 from mapbox. Since v2 this example doesn't seem to work anymore, I'm getting the following error:
When I change the drawElements part to something like this:
the shadows do render, but they're really off. Any idea what has changed since v2 of mapbox which causes this error? This is the full code which I'm using to test: |
@Stefwint were you able to figure anything out for this? We're struggling with the same issue at the moment. |
@BraydenKC Unfortunately not. The owner of this repository is giving some more in depth explanation about the issue: So let's hope there will be a solution soon.. |
i solved this like below
|
@satorbs Do you have a full example? It looks better with your changes, but it's not quite there yet. |
Awesome work @mourner |
For Mapbox GL JS version 2.0 and up, here is the updated example https://gist.github.com/ted-piotrowski/420a31bf3c157664fdda14bf45692785 ...and the revision if you're wondering what changed https://gist.github.com/ted-piotrowski/420a31bf3c157664fdda14bf45692785/revisions |
@ted-piotrowski
|
@yan-map Let me know if the following works for 2.12.0. |
@mourner @ted-piotrowski |
Somewhat. Because the implementation is quite naive (it uses "Carpet shadows" which pass underneath objects instead of colliding with them), translucent shadows will stack on top of each other resulting in different opacities. Here's a sample gist: https://gist.github.com/ted-piotrowski/420a31bf3c157664fdda14bf45692785 In theory, you could do two passes using a renderbuffer. The first one to get the shadow outlines and a second pass to assign a uniform color/opacity to all of them. |
https://gist.github.com/ted-piotrowski/420a31bf3c157664fdda14bf45692785 @McFly78 Here is a revised gist to allow for shadow transparency. Modify this line to set the shadow rgba values:
Let me know if you run into any issues. (Note: this approach does not work with 3D terrain enabled) |
@ted-piotrowski Thanks so much ! |
Hey, the gist worked perfectly for my application. However, since mapbox 3.0.6 it does not work any more. After building, there are no shadows, but the actual building get's darker depending of the time. Are there any changes that could result in that? Greetings |
The text was updated successfully, but these errors were encountered: