Comments (12)
Ahh, LayerMask
, I knew there must be a better way, thanks, I updated the gist.
I also added an IMap
property to UnityTile
, to get rid of that nasty FindObjectOfType<>()
call, good idea! This could probably be added to the official API, as IMap
has some useful properties that can be used in custom modifiers...
P.S. Thanks for all the help guys 👍
from mapbox-unity-sdk.
@mihakrajnc We'll probably add the IMap property soon to UnityTile. The plan right now is to separate IMap
into IMapReadable
and IMapWriteable
to keep separation of concerns. Modifiers want to read map aspects, but we should not expose writeable values (zoom, location, etc.).
from mapbox-unity-sdk.
Hey @mihakrajnc, as you noted, default behaviour is to read from height data directly instead of doing raycast which would be a lot more expensive. Intended usage is to have the highest resolution you can for terrain and since it's quite low weight as it's only vertices anyway.
Are you looking for something like; https://twitter.com/brnkhy/status/867754134736429056 ? If that's the case, we'll probably release that low poly terrain factory soon.
Otherwise, a raycast solution would be the most straight forward one I guess but since it's not a common case, we probably wouldn't use it over raw data querying.
from mapbox-unity-sdk.
That's exactly what I'm looking for! So far I've been doing the recalculations myself to modify the vertices and normals for that low-poly look, but it would be awesome to have it integrated.
However won't that factory have the same problem? Snapping will still happen to the height data, and but the terrain will be low poly?
from mapbox-unity-sdk.
@mihakrajnc ah yes, you're absolutely right, that terrain will have it even worse. Actually the ultimate solution is to cut terrain to create roads and stuff but that's a low performance solution so we didn't prioritize it.
a trick to fix that would be rendering terrain and roads in different cameras. but then you'll have problems with buildings as well so you probably will need to render that in a different camera as well. So a three camera setup, going like building->road->terrain (top to down) would work. I used this trick for a while and looks quite good if you have a top down camera and won't go too close to terrain.
from mapbox-unity-sdk.
@mihakrajnc actually, let me correct that; low poly terrain in those shots are exactly same as the normal terrain (resolution wise) but have different shading. So snapping to terrain issue will be exactly same as the normal terrain, not any better or worse. With somewhat high resolution and a little height on roads, it'll probably stay on top of terrain most of the time.
from mapbox-unity-sdk.
@mihakrajnc OK one last thing, have you tried SmoothLineModifier for your roads? It goes before everything in stack and increases road data resolution so it snaps better on terrain. Might worth giving it a shot as well.
from mapbox-unity-sdk.
@mihakrajnc And by all means, if you need to raycast to obtain your height data, please do so. You could build your own version of SnapTerrainModifier
that uses raycasting, instead of height query from UnityTile
. Something like SnapTerrainRaycastModifier
? You could use the terrain layer option as a raycast mask.
from mapbox-unity-sdk.
@brnkhy Well, depending on what kind of low-poly look you're going for, the problem can still be there. If you want a really low poly look (which needs a low resolution terrain) the problem is still there.
@david-rhodes I tried it with Raycasting and the results are looking good!
I also tried a SmoothLineModifier and got better results in some cases. Still have to check the performance of this stack on mobile devices, but as the only impact will be when loading the map for the first time, it should be ok IMO.
Here is the SnapTerrainRaycastModifier if anyone wants to use it!
I'm not a huge fan of FindObjectOfType<AbstractMap>().WorldRelativeScale
but I couldn't find any other way of getting the scale...
from mapbox-unity-sdk.
@mihakrajnc that shot looks really awesome! As long as it satisfies your performance needs, I guess this is the way to go in your case. Thanks a lot for the script as well, I'll try it as soon as possible!
from mapbox-unity-sdk.
@mihakrajnc This is awesome!
I'm not a huge fan of FindObjectOfType().WorldRelativeScale but I couldn't find any other way of getting the scale...
I bet you could cache the IMap
object or the WorldRelativeScale
value in UnityTile
, which is already passed into the MeshModifier
.
Also, instead of serializing the string of the layer, you could use LayerMask
.
from mapbox-unity-sdk.
@mihakrajnc Thanks again: #110.
from mapbox-unity-sdk.
Related Issues (20)
- How to preload the map
- How Tilset work in mapbox?
- Consider switching ARInterface for ARFoundation
- Unexpected behaviour on SetZoom HOT 1
- The 3D models on the map change their position when locating is activated.
- Setting the Map Extent Options to CameraBounds at runtime doesn't work HOT 1
- Spawn prefabs upwards with a fixed gap
- why only mapbox street v7 can edit POI prefab
- Mapbox + Unity Cloud Build
- Error: Cannot Initialize non-default texture with negative or zero width HOT 1
- suddort URP ? HOT 2
- How to Apply Texture to Tiles
- Swapped North/South and West/East coordinates in Tile Id To Bounds?
- This project is dead? HOT 12
- Your hardware does not support this application. Failed to load 'libmain.so' java.lang.UnsatisfiedLinkError: dopen failed: library "libmain.so" not found HOT 1
- Can I make changes to AbstractMap's Features?
- Can I make changes to AbstractMap's Map Layers Tileset ID via code during runtime?
- heatmap rendering issue
- Meta Quest 3 Build Issues
- Some Building Meshes get "cutoff"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-unity-sdk.