Code Monkey home page Code Monkey logo

Comments (12)

mihakrajnc avatar mihakrajnc commented on July 20, 2024 1

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.

david-rhodes avatar david-rhodes commented on July 20, 2024 1

@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.

brnkhy avatar brnkhy commented on July 20, 2024

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.

mihakrajnc avatar mihakrajnc commented on July 20, 2024

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.

brnkhy avatar brnkhy commented on July 20, 2024

@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.

brnkhy avatar brnkhy commented on July 20, 2024

@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.

brnkhy avatar brnkhy commented on July 20, 2024

@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.

david-rhodes avatar david-rhodes commented on July 20, 2024

@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.

mihakrajnc avatar mihakrajnc commented on July 20, 2024

@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!

snapterrainmod

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.

brnkhy avatar brnkhy commented on July 20, 2024

@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.

david-rhodes avatar david-rhodes commented on July 20, 2024

@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.

david-rhodes avatar david-rhodes commented on July 20, 2024

@mihakrajnc Thanks again: #110.

from mapbox-unity-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.