在3D中,LOST OF DETAIL 是一种避免过多渲染细节的方法。
使用一些列的级别细节图来模拟LOST OF DETAIL;
但是如何选择合适的距离来使用不同的细节图呢?
下面一个方法。
[img]
[/img]
在以上图中:
errorH表示图块失去细节后所失去的高度。
因此根据三角形相似可以求出d.
CB 为errorH的投影。
当CB为一个阀值的时候,errorH可以被忽略。
errorH越远,CB越短,当短到人的肉眼可以忽略的时候,说明errorH从错误变成了可以忽略的误差。这个时候,细节图可以被更高级别模糊度的图块所取代。
公式就是三角形相似外加坐标转换,像素坐标转换为自定义坐标。
代码如下:
//earlier in the file:
inline int PINDEX( int x, int z ) { return x * 33 + z; }
void CScape::CalcErrors( float MaxError, int Vres, float FoV, float NearClip )
{
//vars for de Boer's equations
float C, A, T;
T = 2 * MaxError / Vres;
//convert FoV to radians
FoV *= PI / 180.0f;
A = 1.0f / (float) tan( FoV / 2.0f );
C = A / T;
//go through all of the vertices that will be removed and calc errors
/*
*-----*-----*-----*-----*
| | | | |
| | | | |
| | | | |
| | | | |
*-----*-----*-----*-----*
| | | | |
| | | | |
| | | | |
| | | | |
*-----*-----*-----*-----*
| | | | |
| | | | |
| | | | |
| | | | |
*-----*-----*-----*-----*
| | | | |
| | | | |
| | | | |
| | | | |
*-----*-----*-----*-----*
*/
int x, z, l, p;
ScapePatch* Patch;
float Delta;
ScapeVertex* Vert;
for( p = 0; p < m_NumPatches; ++p )
{
Patch = &m_Patches[p];
Delta = 0.0f;
for( l = 0; l < 4; l++ )
{
int start = (int)fastpow( 2.0f, l );
int inc = start*2;
//first set of removed vertices
for( x = start; x < 33; x+=inc )
{
for( z = start; z < 33; z+=inc )
{
Vert = &Patch->Vertices[PINDEX(x,z)];
Delta = Max( Delta, fabsf(Vert->y-(Patch->Vertices[PINDEX(x-start,z-start)].y + Patch->Vertices[PINDEX(x+start,z+start)].y) / 2.0f) );
Delta = Max( Delta, fabsf(Vert->y-(Patch->Vertices[PINDEX(x+start,z-start)].y + Patch->Vertices[PINDEX(x-start,z+start)].y) / 2.0f) );
}
}
Patch->D[l] = Delta * C;
}
}
}
完毕。
- 大小: 4.3 KB
分享到:
相关推荐
Terrain Rendering Using GPU-Based Geometry Clipmaps
A primary difficulty in terrain rendering is displaying realistic terrains to the user at real-time frame rates. The brute force approach is usually too complex for real-time frame rates to be ...
《Real-Time 3D Terrain Engines Using C++ And DirectX 9 》.rar《Real-Time 3D Terrain Engines Using C++ And DirectX 9 》.rar《Real-Time 3D Terrain Engines Using C++ And DirectX 9 》.rar《Real-Time 3D ...
NULL 博文链接:https://univasity.iteye.com/blog/891706
clayman大牛推荐的《Real-Time 3D Terrain Engines Using C++ And DirectX9》的中文翻译,目前进度到1到6章,免费
《Real-Time 3D Terrain Engines using C++ and DirectX9》中、英文电子书和官方完整源代码更新V1.6。英文电子书为原书图片扫描,中文电子书为承天一的翻译文字版。
网上和emule上的该书的code都不全,这是个完全版的。但编译时需要使用dxsdk较早的版本(应该是dx8.*)。
clayman大牛推荐的《Real-Time 3D Terrain Engines Using C++ And DirectX9》的中文翻译,目前进度到1到9章,免费
Real Time 3D Terrain Engines Using C++ And Dx9 中英文pdf和代码
经典书籍,英文版。写地形必看的书籍。作者:Greg Snook
Real Time 3D Terrain Engines Using C++ And DirectX 9源代码
关于地形渲染的资料,主要介绍利用GPU的曲面细分单元辅助进行地形渲染的技术
这是一本介绍战地3地形技术的书籍,很使用的书籍
基于GPU的地形算法实现文档,游戏编程精粹里的地形算法就是参考此篇的思想
使用OpenGL进行地形的绘制,可以在程序外部自行修改样貌,并在程序中进行渲染
of posts on terrain rendering algorithms that seem to fly at you from every angle? Terrain rendering seems to be a favorite subject among today’s hobbyist programmers; it serves as an excellent ...
使用了Game Programming Gems 6中GPU Terrain Rendering与Clipmap的方法渲染大地形
Terrain To Mesh 2021 is new rebuild, upgraded and improved version of Terrain ...• Holes in mesh are supported as Alpha Cutout effect using shaders – the same way as it is done by Unity terrain system.