当前位置: 动力学知识库 > 问答 > 编程问答 >

opengl - Displacement mapping

问题描述:

What exactly are the benefits of displacement maps? Do they actually speed up rendering of higher count polys at all, or is it just a nifty trick for artists and in-engine tools to temporarily lower the poly count? The only real thing I could see it used for is maybe level of detail algorithms, but only at much greater distances.

网友答案:

Well it can provide a more compact structure for rendering high poly models. A displacement map can contain as few as 1 byte per pixel. If you tesselate that up for displacement mapping then you are saving a HUGE amount of memory bandwidth on the GPU.

Image for a second a simple vertex struct.

struct Vert
{
    float x, y, z;
    float nx, ny, nz;
    float u, v;
};

That struct is 32 bytes in size. So if you imagine that you can quarter the number of vertices (and you ought to be able to do a HELL of a lot more than that) and replace all other vertices with a 1 byte height map then you the amount of memory used works out as follows:

100,000 poly object = 3,200,000 bytes using vertex struct alone.
25,000 polys + 100,000 entry height map = 900,000 bytes.

ie dispalcement mapping provides you with the same data in 28% of the memory. WIN! :D

If you store a normal map and use the w/a component for height then you use up 400000 bytes for the texture and you are now 1,200,000 bytes in size which is STILL 37.5% of the size. PLUS you can now remove 12 bytes for normal storage and you are really down to the same figure of 900,000 bytes.

You ought to be able to get SIGNIFICANTLY higher geometry compression rates than that. So, in summary, you get a better looking model for a fraction of the storage data.

As an added bonus, using the normal map/height map system you can also easily scale so that less powerful machines simply use the normal data and you still get reasonably good results.

分享给朋友:
您可能感兴趣的文章:
随机阅读: