- Home /
Transform all Terrain Vertices to Map to Sphere
I want to map cube coordinates to a sphere. Don't worry, I already have an algorithm to do this. I basically have posXinSphere = (math involving vertex x, y, and z coords), and the same thing for posYinSphere, and posZinSphere.
How would I apply this to a terrain in Unity, i.e. how would I transform each individual vertex? I'm looking for an efficient method. Is it possible to do this in a geometry shader in Unity Free?
you want to transform the terrain into a cube and then into a sphere? or directly the terrain into a sphere?
As @gnp89 commented - not sure how your cube->sphere algorithm is going to help - terrains aren't cubes, they're heightmaps with an array of regularly-spaced elevation samples above a base height.
To answer the second part of your question though, yes you can create geometry shaders in Unity free.
@tanoshimi my algorithm can transform each plane onto a sphere. I've researched the problem I'm having, and I believe I can answer my own question. I can successfully transform heightmaps using my algorithm onto a sphere, but the problem is that Unity doesn't support rotating Terrain objects. This can probably be solved in the shader, but adds quite a bit of overhead. Also, there are weird terrain LOD details that would need to be sorted out.
It seems geometry shaders aren't required since I discovered they're for creating geometry rather than simply modifying it.
Terrain comes with a whole pile of extra features, including collisions, grass & trees, and LoD. A shader technique that moves rendered vertices may not play nice with the LoD, culling, or grass/trees, and won't do anything to match the collision representation to the visual.
Rather than hack each of these systems, it may be simpler to create your own spherized cube mesh using the $$anonymous$$esh class. You'll have to replicate the specialized Terrain functionality that you need, but you'll have more flexibility and won't need to hack around a system that was made to do something very different from what you're trying to do.
You might even find that performance is better this way since you're spending your cycles directly creating the behaviour you want, not fighting the behaviour you don't.
Your answer
Follow this Question
Related Questions
Geomorphing terrain with a vertex shader (custom vertex data maybe?+ 0 Answers
How does the unity terrain shader handle an arbitrary amount of textures ? 1 Answer
Unity Terrain - shader for custom post-splat? 0 Answers
How to automatically apply different textures on terrain based on height? 5 Answers