Author Topic: Globe Sphere Model  (Read 478 times)

lordzeon

  • Newbie
  • *
  • Posts: 30
    • View Profile
Globe Sphere Model
« on: May 13, 2020, 06:18:15 PM »
Hi, im having a issue with the standard globe model, by default, going close to the sphere makes faces too noticeable, so the objects positioned near the surface at height 0, will go inside planet sometimes, or far from surface. This make working with scales too difficult, i know the shader avoid Z-write for this reason, but i think that solution is more like a patch, because it doesnīt look natural up close... and also i need Z-Write for depth of field effect at least, but with Z-write, sometimes country and provinces lines go under and precise object positioning is impossible.

Iīve tried using tessellation, to improve the curvature and "spherize" the sphere, and it improves a little... but the problem is still there, so i think the problem is the sphere model itself is irregular maybe... because with the same tessellation, some locations look good, and others donīt.

Other sphere types have been tried to solve this problem?, i donīt think Z-write disabled as a permanent solution for a quality earth asset, make imposible to work with custom shaders.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Globe Sphere Model
« Reply #1 on: May 15, 2020, 10:34:15 AM »
Hello,

Quote
im having a issue with the standard globe model, by default, going close to the sphere makes faces too noticeable, so the objects positioned near the surface at height 0, will go inside planet sometimes, or far from surface.
The front half of the Earth doesn't write to z-buffer to prevent clipping. So why do you get clipping on surface objects? Can you tell which Earth style or mode (tile system?) are you using?


lordzeon

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Globe Sphere Model
« Reply #2 on: May 15, 2020, 05:21:00 PM »
i changed the shader, i know the normal ones donīt write to Zbuffer, but that not desirable, because i need the clipping for the objects, and i need the z buffer to have depth of field effect. The solutions iīve found always have a downside:
1) all the shaders overwriting earth make objects behind in front of the planet too, eliminate shadows and it looks weird like a parallax up close
2) making all objects with a considerable distance to the surface, to absorb diameter differences: well, it doesnīt look good to have objects flying.
3) render in 2 cameras: the same problem as 1 with the objects behind and also, its slower and the camera effects have to be used twice, looking weird too.

I think the solution is to have a correct sphere model, with a uniform diameter and more vertex to avoid any tesselation problem.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Globe Sphere Model
« Reply #3 on: May 17, 2020, 04:51:03 AM »
Quote
I think the solution is to have a correct sphere model, with a uniform diameter and more vertex to avoid any tesselation problem.

That's correct. Ideally a perfectly rounded sphere at pixel level will solve all issues. However that may turn in something not possible in terms of performance, or only applicable to certain platform or use cases.

Note that all geometry ends in a collection of triangles. So one approach could involve dynamically molding a mesh that covers just the camera viewport and ensures it has very small triangles whose vertices matches perfectly a regular sphere surface.

However, this also has side effects. If you follow this approach, then any other geometry that covers certain map area must also be curved in the same way so there's no clipping involved. For instance, if you texture or color a country, the asset generates a surface mesh that covers the country region polygon. That mesh is generated using a delaunay algorithm to ensure minimal number of polygons and their vertices are normalized to match the sphere radius. But to match a perfect sphere, those triangles also need to be tesselated or replaced by the same technique that ensures perfect fit to a sphere surface and not only to discrete number of vertices. Repeat that for animated lines, roads, etc. or anything that's at ground level.

You can find an example of perfect clipping in demo scene "13 Clipping Objects". The objects in that scene use a variation of unlit and standard shader that clips the pixel if its distance to the center of the sphere is less than the radius. This ensures perfect clipping and makes it compatible with the way other shaders in globe asset work.
Here's a video: https://youtu.be/IxNhq3KT0_M

The standard shader used in the video for the Earth globe uses a lower geometry queue and doesn't write to z-buffer (ZWrite Off, queue="Geometry-20" so it renders before other objects and objects do not clip). The shader is "World Political Map/Unlit Earth Standard Shader".

The standard shader used for one of the spheres that clips depending on radius is "World Political Map/SurfaceGlobeClip". And there's another unlit shader that does the same called "World Poltiical Map/UnlitGlobeClip".


« Last Edit: May 17, 2020, 04:55:33 AM by Kronnect »

lordzeon

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Globe Sphere Model
« Reply #4 on: May 17, 2020, 12:01:12 PM »
I knew of that example but didn't know which technique it was using... i think taking the distance to the Center is very good Idea for clipping objects!... but i think i will have the same problem with depth for depth of field, do you think it could be possible to have both in the same shader? i can only think only think of a transparent shadow receiver and depth mask but that would duplicate globe triangles and maybe create other clipping issues with shadows and alpha channel.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Globe Sphere Model
« Reply #5 on: May 17, 2020, 12:15:42 PM »
Yeah, it would require a change to the CoC computation of depth of field. Let it take the depth as normal but then it also must compute the intersection of the view dir ray and sphere and clamp the depth to that point.

lordzeon

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Globe Sphere Model
« Reply #6 on: May 17, 2020, 12:48:50 PM »
Wow... i dontīhave any idea how to do that... its that something i could archieve with unityīs post process? or should i make a custom solution for it? or maybe there is an asset with that option?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Globe Sphere Model
« Reply #7 on: May 18, 2020, 10:32:09 AM »
You could try Beautify's depth of field. It comes with an option to precompute depth for certain layers. It was designed for transparent objects (which don't write to zbuffer) but it could be used for this use case:



Try assigning the same Earth globe layer to this option. Beautify will perform a prepass with a depth replacement shader and will combine the depth from the sphere with the scene depth to compute CoC.

lordzeon

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Globe Sphere Model
« Reply #8 on: May 18, 2020, 03:26:02 PM »
Didnīt saw the Beautify post process... it could be a solution long term, but right now i cannot buy more "expensive" assets (i know it is not, but im from Argentina  :-\) for this project, so i will try doing the transparent sphere trick, cannot think of other solution.