Terrain Texturing

醉酒当歌 提交于 2019-12-13 20:44:42

问题


Is there a way to blend 2 textures in a gradient manner? ex. first textures starts at top and goes to the bottom, and second one starts bottom and goes top. I want to make them loose opacity like in a gradient to create a smooth connection. Is it possible?

Maybe there is some other way to create such textures? The problem is that the difference in heights in my terrain does not look really well - in one square area, one triangle has a different texture than the other.


回答1:


For every terrain texture store an additional blend amount in your terrain vertex. This blend amount is simply a float value in the range of 0 to 1, where 0 means zero opacity and 1 means that the texture is fully opaque.

In the pixel shader you can use this amount to interpolate between the sampled pixels from the base texture and the blended one.

In this picture you can see a 3*3 terrain with a ground texture and a grass texture on top of it. The numbers represent the blend amount for each of the vertices:




回答2:


Use a shader. You can either use two sampler2D textures, or one single sampler2DArray texture. GLSL has linear (mix) and hermite (smoothstep) interpolation functions builtin.



来源:https://stackoverflow.com/questions/14630838/terrain-texturing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!