Ticket #434: water.434.patch

File water.434.patch, 2.2 KB (added by peter_ym_account, 14 years ago)

2nd try: changes transparent objects rendering behavior so they are rendered only once; except for the underwater portion when fancy water is disabled

  • source/renderer/Renderer.cpp

    old new  
    12741274    RenderModels();
    12751275    ogl_WarnIfError();
    12761276
    1277     // render transparent stuff, so it can overlap models/terrain
    1278     MICROLOG(L"render transparent");
    1279     RenderTransparentModels();
    1280     ogl_WarnIfError();
    1281 
    12821277    // render water
    12831278    if (m_WaterManager->m_RenderWater && g_Game)
    12841279    {
     1280        // We no longer render transparent objects twice, once before water
     1281        // and once after water (ticket 434); except that when fancy water is disabled
     1282        // we have to draw the underwater portion of transparent objects twice.
     1283        if (!m_WaterManager->WillRenderFancyWater())
     1284        {
     1285            // render underwater transparent stuff before plain water;
     1286            // use a clipping plane so that we only draw things below the water plane
     1287            MICROLOG(L"render underwater transparent");
     1288            double eqn[] = { 0.0, -1.0, 0.0, m_WaterManager->m_WaterHeight };
     1289            glClipPlane(GL_CLIP_PLANE0, eqn);
     1290            glEnable(GL_CLIP_PLANE0);
     1291            RenderTransparentModels();
     1292            ogl_WarnIfError();
     1293            glDisable(GL_CLIP_PLANE0);
     1294        }
     1295       
    12851296        MICROLOG(L"render water");
    12861297        m->terrainRenderer->RenderWater();
    12871298        ogl_WarnIfError();
    1288        
    1289         // render transparent stuff again, so it can overlap the water
    1290         MICROLOG(L"render transparent 2");
    1291         RenderTransparentModels();
    1292         ogl_WarnIfError();
    1293        
    1294         // TODO: Maybe think of a better way to deal with transparent objects;
    1295         // they can appear both under and above water (seaweed vs. trees), but doing
    1296         // 2 renders causes (a) inefficiency and (b) darker over-water objects (e.g.
    1297         // trees) than usual because the transparent bits get overwritten twice.
    1298         // This doesn't look particularly bad, but it is noticeable if you try
    1299         // turning the water off. On the other hand every user will have water
    1300         // on all the time, so it might not be worth worrying about.
    13011299    }
     1300   
     1301    // render transparent stuff, so it can overlap models/terrain
     1302    MICROLOG(L"render transparent");
     1303    RenderTransparentModels();
     1304    ogl_WarnIfError();
    13021305
    13031306    // Clean up texture blend mode so particles and other things render OK
    13041307    // (really this should be cleaned up by whoever set it)