Use fractal noise to generate terrain, plus mountain shader, plus snow shader
Noise Generating Results
Noise generate the main reference to this article, will not repeat
Value3d:
PERLIN2D:
Fractal Noise:
Terrain Generation Results
Generate Terrain Grid method The main reference to this article, will not repeat
Noise frequency: 22, resolution: 256
Value3d:
perlin2d:
Fractal Noise:
Noise has many uses, such as topography, water bodies, fluids, textures of special objects, or making stickers non-repeatable, etc.
Mountain ShaderThe shader aspect is divided into two layers, the upper layer is the rock, the lower level is the plant, (can vary according to the map)
Using four kinds of maps, the upper two, the lower two, the noise map to adjust the two proportions, so as to avoid a monotonous, artificial signs obvious
The code mainly uses LERP
Note: When creating terrain, the UV proportions of the noise are adjusted (mountain density and detail)
Snow is mainly based on the direction of snow and normal direction of judgment, the two do dot product,
And then give the snow part to a specific snow texture, OK.
if (dot (N, _snowdir) > _snowinten) {c = _snowcolor; N = Normalize (I.normal) + normalize (Unpacknormal (tex2d (_snownormaltex, I.uv_snownormaltex)));}
Results
Add fog effect and Aa,bloom
All code is shared to GitHub
---------------by wolf96 http://blog.csdn.net/wolf96
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Random mountains of unity3d randomly generated terrain