简体   繁体   中英

Projected grid water horizon detail

I'm trying to implement an ocean scene with C++ and DirectX11. Currently I have a projected grid, Gerstner waves and a basic shading. My problem is that when I aim my camera horizontally, so I can see the water horizon, in the distance, the projected grid becomes insufficient, even at high vertex numbers. These screenshots illustrate the problem:

阴影水面

线框水面

I know the cause of the problem is in the concept of the projected grid (the grid is detailed near the camera, rough far from it), but there has to be a best practice to solve this.

Any ideas?

Benedikt Bitterli and joojaa answered my question here: https://computergraphics.stackexchange.com/questions/1681/projected-grid-water-horizon-detail

I chose the laziest solution for now. I calculate an attenuation factor from the distance from the camera in the vertex shader, and I gradually flatten the waves in the distance.

The function:

float CalculateWaveAttenuation(float d, float dmin, float dmax)
{
    // Quadratic curve that is 1 at dmin and 0 at dmax
    // Constant 1 for less than dmin, constant 0 for more than dmax
    if (d > dmax) return 0.f;
    else
    {
        return saturate((1.f / ((dmin-dmax)*(dmin-dmax))) * ((d-dmax) * (d-dmax)));
    }
}

Here are the results:

阴影 线框

您应该尝试在片段着色器而不是顶点着色器中实现您的“基本着色”算法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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