I load some terrains from my asset bundle, but their edges are not matched together.
I recognize when I edit the terrain in Unity Editor, the problem is solved because the terrains are in the same terrain group (see it here).
So my question is: Can I do it runtime by code? If yes, please tell me how! Many Thanks!
P/S: I know the function TerrainData.SetHeights() and I can match edges of two terrains with this function, but I don't want to do it so manually.
Related
I'm trying generate custom procedural landscape in unreal engine 4
To implement this I'm using this class https://docs.unrealengine.com/en-US/API/Plugins/ProceduralMeshComponent/UProceduralMeshComponent/index.html
and for nice noise generation on Z axis I'm using this plugin https://github.com/devdad/SimplexNoise from this library the only method I use is: USimplexNoiseBPLibrary::SimplexNoise2D
How to implement whole process I inspired from this video: https://www.youtube.com/watch?v=IKB1hWWedMk
I will try to describe flow of whole process:
define vertices count in row and column
iterate through row and column and create vertex vectors on (xscale, yscale, FMath::Lerp((-maxFallOff, maxHeight, USimplexNoiseBPLibrary::SimplexNoise2D(xperlinScale,yperlinScale)))
generate triangles using this method: https://docs.unrealengine.com/en-US/API/Plugins/ProceduralMeshComponent/UKismetProceduralMeshLibrary/ConvertQuadToTri-/index.html
generate UVs
That is all, at this point I can say everything works fine, but there is little issue, when I move camera in editor or in game on mesh appears extra edges. I also recorded video to show what I'm talking about.
https://youtube.com/watch?v=_B9Fxg5oZcE the edges I'm talking, appears on 00:05 second
Code is written in C++, I could post code here, but I think code is not problem here, I think something happens on runtime while I move camera something that I don't know...
I can say in advance if you interested that I'm not manipulating on mesh on Tick event
Problem solved...
Actually seems like I had bug in my code, I was passing too many triangle points to CreateMeshSection_LinearColor method that was the problem.
Anyway thanks for attention
Cheers
I am looking for approach for casting hex based grid on terrain which is for now pre-made but eventually it will be procedural for my exploration game where you can scan planet and elements will be highlighted/hex grid selected. What could be the approach towards making this kind of hex grid as my terrain will be un-even.
I have seen approaches like mesh creation, using tile-map, unity projectors but eventually I feel like this should be something using shaders but what about selection?
Can someone please guide me in a right direction.
I think this topic is more like for https://gamedev.stackexchange.com .
My tips for you:
I think the hexa grid projection can be solved with Unity built in Projector, you can use ortoghraphic projection with it, so it does not matter if your terrain is uneven, also it has a convenient way for selecting which layers are affected only (terrain, your buildings etc...)
(The projector, is a shader magic tho, it blends the picture you give it to it, and the layer below it)
If projector does not satisfies your needs, im pretty sure there are grid shader already written for unity.
About the selection, i think you could also solve that with projector, or give some trail effect to the grid boundaries? - i guess you gonna still store the boundaries so..
About country borders in Civ:
I think they cast a spline using the hex grid border points, then blend it on the terrain. I saw a shader that could draw lines on a terrain, so you might found it!
Keywords for search: Beziér, Catmull–Rom, Spline, terrain shader
I am currently developing an asteroid mining/exploration game with fully deformable, smooth voxel terrain using marching cubes in Unity 3D. I want to implement an "element ID" system that is kind of similar to Minecraft's, as in each type of material has a unique integer ID. This is simple enough to generate, but right now I am trying to figure out a way to render it, so that each individual face represents the element its voxel is assigned to. I am currently using a triplanar shader with a texture array, and I have gotten it set up to work with pre-set texture IDs. However, I need to be able to pass in the element IDs into this shader for the entire asteroid, and this is where my limited shader knowledge runs out. So, I have two main questions:
How do I get data from a 3D array in an active script to my shader, or otherwise how can I sample points from this array?
Is there a better/more efficient way to do this? I thought about creating an array with only the surface vertices and their corresponding ID, but then I would have trouble sampling them correctly. I also thought about possibly bundling an extra variable in with the vertices themselves, but I don't know if this is even possible. I appreciate any ideas, thanks.
I'm creating my game with dynamicly generated terrain. It is very simple idea. There are always three parts of terrain: segment on which stands a player and two next to it. When the player is moving(always forward) to the next segment new one is generated and the last one is cut off. It works wit flat planes, but i don't know how to do it with more complex terrain. Should I just make it have the same edge from both sides(for creating assets I'm using blender)? Or is there any other option? Please note that I'm starting to make games with unity.
It depends on what you would like your terrain to look like. If you want to create the terrain pieces in something external, like Blender, then yes all those pieces will have to fit together seamlessly. But that is a lot of work as you will have to create a lot of pieces that fit together for the landscape to remain interesting.
I would suggest that you rather generate the terrain dynamically in Unity. You can create your own mesh using code. You start by creating an object (in code), and then generating vertex and triangle arrays to assign to the object, for it to have a visible and sensible mesh. You first create vertices at specific positions and then add triangles that consist of 3 vertices at a time. If you want a smooth look instead of a low poly look, you will reuse some vertices for the next triangle, which is a little trickier.
Once you have created your block's mesh, you can begin to change your code to specify how the height of the vertices could be changed, to give you interesting terrain. As long as the first vertices on your new block are at the same height (say y position) as the last vertices on your current block (assuming they have the same x and z positions), they will line up. That said, you could make it even simpler by not using separate blocks, but by rather updating your object mesh to add new vertices and triangles, so that you are creating a terrain that is just one part that changes, rather than have separate blocks.
There are many ways to create interesting terrain. One of the most often used functions to generate semi-random and interesting terrain, is Perlin Noise. Another is his more recent Simplex noise. Like most random generator functions, it has a seed value, which you can keep track of so that you can create interesting terrain AND get your block edges to line up, should you still want to use separate blocks rather than a single mesh which dynamically expands.
I am sure there are many tutorials online about noise functions for procedural landscape generation. Amit Patel's tutorials are good visual and interactive explanations, here is one of his tutorials about noise-based landscapes. Take a look at his other great tutorials as well. There will be many tutorials on dynamic mesh generation as well, just do a google search -- a quick look tells me that CatLikeCoding's Procedural Grid tutorial will probably be all you need.
as you can see, the pivot is outside my mesh. I want to use the pivot for rotating around, for that I need to set the pivot to the real "rotating point". I know that there's the SetPivot script, but it only works with pivots inside meshes.
This mesh is part of an object which contains several meshes, I created it with Wings3d. The problem appears with .obj and .3ds as file extension.
1.How can I fix this?
2.Is there a possibility to define a second pivot which can be used in scripts to "rotate around"(maybe a vector3 which can be set in "Designer")?
I found a youtube vide which might help. I don't know whether it will help though.
Does THIS help?