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

Sky Implementation according to spec #3645

Merged
merged 45 commits into from
Jun 27, 2024
Merged

Sky Implementation according to spec #3645

merged 45 commits into from
Jun 27, 2024

Conversation

prozessor13
Copy link
Collaborator

This PR is a successor of #1713 which is working with the actual maplibre-codebase. Writing Tests is still an open issue for which i currently do not have any time :/

@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2024

Codecov Report

Attention: Patch coverage is 92.83489% with 23 lines in your changes missing coverage. Please review.

Project coverage is 87.77%. Comparing base (863541f) to head (592ded2).
Report is 25 commits behind head on main.

✅ All tests successful. No failed tests found.

Files Patch % Lines
src/render/mesh.ts 61.90% 8 Missing ⚠️
src/style/sky.ts 91.95% 3 Missing and 4 partials ⚠️
src/render/program/terrain_program.ts 82.14% 0 Missing and 5 partials ⚠️
src/style/style.ts 95.45% 0 Missing and 2 partials ⚠️
src/style/light.ts 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3645      +/-   ##
==========================================
- Coverage   87.91%   87.77%   -0.14%     
==========================================
  Files         242      246       +4     
  Lines       33082    33361     +279     
  Branches     2158     2219      +61     
==========================================
+ Hits        29084    29283     +199     
- Misses       3029     3056      +27     
- Partials      969     1022      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/geo/transform.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Jan 31, 2024

I've opened the following issue for the spec as I have forgot to add the diff part of the sky to the relevant place in the code.
maplibre/maplibre-style-spec#517

src/style/sky.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/ui/map.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Jan 31, 2024

Thanks for putting this together again!!
@acalcutt do you want to open a PR against this branch to add tests instead of this PR:

@ibesora do we want to wait with this PR for GSoC or can we change plans in case of this being completed before the program starts?

@acalcutt acalcutt mentioned this pull request Feb 1, 2024
@acalcutt
Copy link
Contributor

acalcutt commented Feb 1, 2024

Thanks for putting this together again!! @acalcutt do you want to open a PR against this branch to add tests instead of this PR:

I've never been the best at adding test, but I added a few expect tests in
#3648

@HarelM
Copy link
Collaborator

HarelM commented Feb 1, 2024

@prozessor13 can I delete sky branch and leave only sky2?

@HarelM
Copy link
Collaborator

HarelM commented Feb 1, 2024

@acalcutt feel free to fix the unit tests as well while you are at it :-)

@acalcutt
Copy link
Contributor

acalcutt commented Feb 1, 2024

I'm not sure I understand those errors

Error: TypeError: painter.transform.calculateFogMatrix is not a function

    at drawTerrain (src/render/draw_terrain.ts:88:45)
    at RenderToTexture.renderLayer (src/render/render_to_texture.ts:[18](https://github.com/maplibre/maplibre-gl-js/actions/runs/7742575082/job/21112014472?pr=3645#step:6:19)7:24)
    at Object.<anonymous> (src/render/render_to_texture.test.ts:119:20)

isn't it a function?

calculateFogMatrix(unwrappedTileID: UnwrappedTileID): mat4 {
const posMatrixKey = unwrappedTileID.key;
const cache = this._fogMatrixCache;
if (cache[posMatrixKey]) {
return cache[posMatrixKey];
}
const fogMatrix = this.calculateTileMatrix(unwrappedTileID);
mat4.multiply(fogMatrix, this.fogMatrix, fogMatrix);
cache[posMatrixKey] = new Float32Array(fogMatrix);
return cache[posMatrixKey];
}

@HarelM
Copy link
Collaborator

HarelM commented Feb 1, 2024

The tests are mocking stuff, if the mock doesn't have a function that the test need you'll see this error.
I'll take a look later this week.

@ibesora
Copy link
Collaborator

ibesora commented Feb 2, 2024

@ibesora do we want to wait with this PR for GSoC or can we change plans in case of this being completed before the program starts?

I don’t think it’s worth waiting for GSoC if this is good to go… but we’ll need to find something else for GSoC. I didn’t realize this was so close to being done

acalcutt and others added 2 commits February 2, 2024 11:41
* try to fix calculateFogMatrix error

* Raise expectedBytes for maplibre-gl.js size
@HarelM
Copy link
Collaborator

HarelM commented Feb 2, 2024

I've merged the tests fix, and merged main branch.
Let's see what the coverage is reporting and decide how to continue.

test/build/min.test.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Feb 2, 2024

but we’ll need to find something else for GSoC

Increasing coverage is always an option.
Helping the globe effort might be a good idea too.
Supporting multiple coordinate systems is always high up.
Improving performance.
Ping me on slack if you want to brain storm.

@HarelM
Copy link
Collaborator

HarelM commented Jun 22, 2024

I've added the relevant unit test to make sure the bug won't happen in the future.
I also moved a sky test under a sky folder.
@louwers note that merging this to main, which should happen soon might create an issue with the parity render tests, this is expected, I have created a folder named sky to hold other sky related tests so you can ignore them until the native parity is completed.

Copy link
Contributor

@Pheonor Pheonor left a comment

Choose a reason for hiding this comment

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

Adding the fog call systematically, even when not used could propably be avoided with a simple chech in the painter class.

src/render/painter.ts Outdated Show resolved Hide resolved
src/render/draw_sky.ts Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Jun 26, 2024

This is now ready to be merged. I'll merge it tomorrow if there's no new review changes requirements.

@HarelM
Copy link
Collaborator

HarelM commented Jun 27, 2024

Good luck to us all.
I'm pushing the button.

@HarelM HarelM merged commit 6612f1b into main Jun 27, 2024
15 checks passed
@HarelM HarelM deleted the sky2 branch June 27, 2024 07:14
github-merge-queue bot pushed a commit to linz/basemaps that referenced this pull request Jul 1, 2024
### Motivation

Upgrade maplibre to latest version, so we can have sky box support.
maplibre/maplibre-gl-js#3645

### Modifications


### Verification
@@ -475,4 +475,44 @@ describe('#getStyle', () => {
expect(spy).not.toHaveBeenCalled();
});

describe('#setSky', () => {
Copy link

@chrisgervang chrisgervang Jul 30, 2024

Choose a reason for hiding this comment

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

How should one unset the sky? (revert back to the default white). It seems calling setSky({}) doesn't do it, and setSky() isn't allowed by the typing but reverts back to white, as desired.. could the type just need a tweak?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does setSky(undefined) works?

Copy link

@chrisgervang chrisgervang Aug 2, 2024

Choose a reason for hiding this comment

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

setSky() and setSky(undefined) work, but then reversing it seems to not work quite right. Turning the sky off is no problem, but then calling setSky with the same sky object as before doesn't render until the sky color value is different.

sky_toggle.mov

I think the typescript type should be relaxed to accept undefined.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to submit a PR to fix this, probably a missing implementation for this case...

@Uranbold
Copy link

Hello guys. Will that fog-ground-blend work on 2D? I'm using the fog ground but it looks like this.
Screenshot 2024-09-11 at 10 04 24

@HarelM
Copy link
Collaborator

HarelM commented Sep 11, 2024

Fog was only added to the terrain...

@Uranbold
Copy link

a Vector map with Fog will look cool. Please consider it :)

@HarelM
Copy link
Collaborator

HarelM commented Sep 12, 2024

Sure will, you should consider taking the time to implement this and open a PR :-)

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

Successfully merging this pull request may close these issues.