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

3D vision for isometric tilesets #66383

Merged
merged 12 commits into from
Jun 23, 2023

Conversation

Rewryte
Copy link
Contributor

@Rewryte Rewryte commented Jun 22, 2023

Summary

Features "3D vision for isometric tilesets"

Purpose of change

In #65738, 3D vision was disabled for isometric tilesets because of several visual bugs, mostly involving height_3d.

Describe the solution

Update: This PR has been merged but the feature will not be fully functional until I-am-Erk/CDDA-Tilesets#2036 is merged as well and the next tileset update takes place.

This fixes said issues and enables 3D vision for all tilesets. The height_3d feature should now be fully compatible with 3D vision. The apparent height of each z-level can be tweaked by changing the zlevel_height property in the tile_info.json / tile_config.json of the target tileset. Cross z-level map memory still does not work properly so I have disabled it for now. That will be worked on next.
iso1
iso2

Describe alternatives you've considered

Testing

Builds ok.
Tested with various scenarios involving different elevations using both HitButton_iso and Ultica_iso tilesets. Renders fine so far.
Map memory for the same z-level works as expected.
Updated compose.py built new tilesets successfully.

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON [Python] Code made in Python Code: Tooling Tooling that is not part of the main game but is part of the repo. SDL: Tiles / Sound Tiles visual interface and sounds. <Enhancement / Feature> New features, or enhancements on existing astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Jun 22, 2023
@vetall812
Copy link
Contributor

Can't wait for it!

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 22, 2023
@Zupercharged
Copy link

From the screenshots it doesn't render the wall tiles on the layer below, would it be possible to modify it slightly to render the walls beneath ledges as well?

@Rewryte
Copy link
Contributor Author

Rewryte commented Jun 22, 2023

From the screenshots it doesn't render the wall tiles on the layer below, would it be possible to modify it slightly to render the walls beneath ledges as well?

That is due to "occlusion culling", one of the reasons why we could pull off 3D vision with minimum performance loss. The code is meant for the usual top-down perspective of most tilesets and hence is pretty basic. We could improve it if someone comes up with a specialized algorithm to determine what should be drawn from an isometric perspective.

Copy link
Contributor

@Qrox Qrox left a comment

Choose a reason for hiding this comment

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

Looking very nice!

src/cata_tiles.cpp Outdated Show resolved Hide resolved
@Qrox
Copy link
Contributor

Qrox commented Jun 22, 2023

render the walls beneath ledges as well?

I think it can be achieved by making the unseen tile sprite have height if it connects to a wall or unseen tile above (so the unseen walls and multi-zlevel unseen regions look like vertical shadow instead of horizontal shadow shown in the screenshot).

I also notice the fog sprites have ragged edges, is that due to the overlay rendering function rendering open air tiles as rectangles rather than rhombuses?

@vetall812
Copy link
Contributor

This PR (right above this comment) will help with the fog.
I'd recommend to use it also for unknown tiles on the same level as player character. So it'll create consistent fog even in currently invisible areas that contains stuff from the levels below.

@vetall812
Copy link
Contributor

We could improve it if someone comes up with a specialized algorithm to determine what should be drawn from an isometric perspective.

We can draw tiles that below current level if it touches any one of eight neighboring visible/remembered tiles. But i'm not a programmer, so it's just a guess.

@Rewryte
Copy link
Contributor Author

Rewryte commented Jun 22, 2023

is that due to the overlay rendering function rendering open air tiles as rectangles rather than rhombuses?

Yup. Personally, I like how it gives fog a bit of volume especially with the smaller tiles of SmashButton, but the jaggedness is more pronounced in Ultica.

This PR (right above this comment) will help with the fog.

Thanks, looks good to me.

We can draw tiles that below current level if it touches any one of eight neighboring visible/remembered tiles. But i'm not a programmer, so it's just a guess.

That would be performance unfriendly I'm afraid. Other than fog, what we usually draw are a single z-level's worth of layers. Drawing an additional level underneath could double draw time. We would still have the same problem on buildings taller than 2 levels too.

Rewryte added 2 commits June 23, 2023 01:39
measured from t_wall sprite
@Zupercharged
Copy link

Zupercharged commented Jun 22, 2023

are the fog sprites for open air trimmed to match the grid pattern of the tile? it looks like theyre just normal square sprites which creates the overlapping and jagged effect when aligned to an iso grid.

Edit: nevermind I noticed Vetal already fixed that for you in his pull request, regarding the accidental volumetric effect you can assign specific sprites for ledges which could be used to do a similar effect more intentionally and cleanly

Co-Authored-By: Jianxiang Wang (王健翔) <[email protected]>
@Rewryte
Copy link
Contributor Author

Rewryte commented Jun 23, 2023

you can assign specific sprites for ledges which could be used to do a similar effect more intentionally and cleanly

tr_ledge is only spawned in a small radius around the player so fog further away would not have the effect. Might be able to achieve this with the multi-tile system though.

@Rewryte
Copy link
Contributor Author

Rewryte commented Jun 23, 2023

Not sure if I should include the t_open_air and tr_ledge tile_config.json changes this time round. Without it, the feature wouldn't be fully functional until the next tileset update. With it, there will be merge conflicts every tileset update until this PR itself is merged.

@Rewryte Rewryte marked this pull request as ready for review June 23, 2023 07:21
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Auto-requesting reviews from non-collaborators: @jbytheway @int-ua

@bombasticSlacks
Copy link
Contributor

bombasticSlacks commented Jun 23, 2023

Not sure if I should include the t_open_air and tr_ledge tile_config.json changes this time round. Without it, the feature wouldn't be fully functional until the next tileset update. With it, there will be merge conflicts every tileset update until this PR itself is merged.

ahhh I was wondering about this.

was my only curiousity in testing.

@bombasticSlacks bombasticSlacks merged commit 6ce851f into CleverRaven:master Jun 23, 2023
@Rewryte
Copy link
Contributor Author

Rewryte commented Jun 23, 2023

Yeah, I guess I should put a disclaimer on the original post.

@bombasticSlacks
Copy link
Contributor

Don't worry about it, I should have read the conversations before testing.

Either way, it's in now 😄

@Rewryte Rewryte deleted the 3d_vision_iso2 branch August 4, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tooling Tooling that is not part of the main game but is part of the repo. <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Python] Code made in Python SDL: Tiles / Sound Tiles visual interface and sounds.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants