简体   繁体   English

纹理Opengl地形?

[英]Texturing Opengl Terrain?

What is the best way to texture terrain made from quads in OpenGL? 在OpenGL中用四边形构造地形的最佳方法是什么? I have around 30 different textures I want to have for my terrains (1 texture per terrain type, so 30 terrain types) and would like to have smooth transitions between any two of the terrains. 我想为我的地形提供大约30种不同的纹理(每种地形类型有1种纹理,因此有30种地形类型),并且希望在任意两种地形之间有平滑的过渡。

I have been doing some browsing on the web and found that there are many different methods, including 3d texturing, Alpha channels, blending, and using shaders. 我一直在网上做一些浏览,发现有很多不同的方法,包括3D纹理,Alpha通道,混合和使用着色器。 However, which of these is the most efficient and can handle the amount of textures I am looking to use? 但是,哪些是最有效的,可以处理我想要使用的纹理量? For example: This popular answer describes how to use some techniques, but since the mixmap only has 4 properties (RGBA) and so can only support 4 textures. 例如: 这个流行的答案描述了如何使用某些技术,但由于mixmap只有4个属性(RGBA),因此只能支持4个纹理。

I should also note that I know nothing about shaders, so non-shader required techniques would be preferable. 我还应该注意,我对着色器一无所知,因此非着色器需要的技术会更好。

Since you linked to an answer that describes texture splatting , and its question mentions the game Oblivion, I can provide some additional insight into that. 由于您链接到描述纹理喷溅的答案,并且其问题提到游戏Oblivion,我可以提供一些额外的洞察力。

Basic texture splatting with an RGBA mixmap only supports four textures per terrain quad, but you can use different sets of textures for different quads. 使用RGBA mixmap的基本纹理splatting仅支持每个terrain四个纹理四个纹理,但您可以为不同的四边形使用不同的纹理集。 Oblivion divides its terrain into squares (called "cells") of 32 grid points (192 feet) per side, and each cell defines its own set of four terrain textures. Oblivion将其地形划分为每边32个网格点(192英尺)的正方形(称为“单元格”),每个单元格定义自己的四个地形纹理集。 So you can't have lots of texture diversity within a small area, but you can easily vary your textures over larger regions. 因此,您不能在一个小区域内拥有大量纹理多样性,但您可以轻松地在较大区域上改变纹理。 If you prefer, you can define texture sets for smaller regions, even individual quads, at the expense of using more memory. 如果您愿意,可以为较小的区域(甚至是单个四边形)定义纹理集,但代价是使用更多内存。

If you really need more than four textures in a quad, you can use multiple mixmaps. 如果您在四元组中确实需要四个以上的纹理,则可以使用多个混合地图。 For each additional one, you just do another texture lookup to get four more blending factors, and blend in four more textures on top of the results from the previous mixmap. 对于每个额外的一个,您只需执行另一个纹理查找以获得另外四个混合因子,并在前一个mixmap的结果之上混合另外四个纹理。 You can scale up to as many textures as you want, again at the expense of memory. 您可以根据需要扩展到尽可能多的纹理,同样以牺牲内存为代价。

Texture splatting can be tricky to combine with with LOD techniques on the height map, because when a single low-detail terrain quad represents a group of high-detail quads, you have to sample several different mixmaps for different regions of the big quad. 纹理喷溅在高度图上与LOD技术相结合可能很棘手,因为当单个低细节地形四边形代表一组高细节四边形时,您必须为大四边形的不同区域采样几个不同的混合图。 Oblivion sidesteps that problem by using texture splatting only for full-detail terrain; Oblivion通过仅对全细节地形使用纹理喷溅来回避这个问题; distant cells, rendered at lower resolution, use precomputed textures produced by the editor, which does the splatting and downscaling in advance. 以较低分辨率渲染的远程单元格使用由编辑器生成的预先计算的纹理,其预先进行喷溅和缩小。

One alternative to texture splatting is to use a clipmap to render a " megatexture ". 一种可以替代的质感泼洒是使用clipmap渲染“ megatexture ”。 With this approach, you have a single large texture that represents your entire terrain, and you avoid filling up your RAM by loading different parts of it with only as much detail as is actually needed to render it based on the viewer's current position. 使用这种方法,您可以使用单个大型纹理来表示整个地形,并且可以通过加载RAM的不同部分来填充RAM,其中只需要根据查看器的当前位置实际渲染它所需的细节。 (Distant parts of the terrain can't be seen at full detail, so there's no need to load them at full detail.) (在完整细节处无法看到地形的远处部分,因此无需在完整细节处加载它们。)

The advantage of this approach is its artistic freedom: you can place fine details anywhere you want in the texture, without regard to the vertex grid. 这种方法的优点是它的艺术自由:您可以在纹理中的任何位置放置精细的细节,而不考虑顶点网格。 The disadvantage is that it's rather complex to implement, and the entire clipmap has to be stored somewhere , probably in a big file on disk, so that you can load parts of it into RAM as needed. 缺点是它实现起来相当复杂,并且整个剪贴图必须存储在某个地方 ,可能存储在磁盘上的大文件中,以便您可以根据需要将部分内容加载到RAM中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM