Opened 14 years ago

Closed 13 years ago

#434 closed enhancement (fixed)

[PATCH] Don't render transparent objects twice

Reported by: Philip Taylor Owned by: philip
Priority: Nice to Have Milestone: Alpha 7
Component: Core engine Keywords:
Cc: peter_ym_account Patch:

Description

CRenderer::RenderSubmissions() calls RenderTransparentModels() twice, once before drawing water and once after, so that underwater transparent models will blend properly.

That seems like a terrible idea. We have lots of transparent objects (trees) so it will kill performance; and the overdraw makes transparent objects look different, so when we fix the performance bug all the art will be wrongly calibrated.

Possible temporary solution: don't support transparent objects underwater. Possible better solution: do the overdraw only on models which intersect the water plane. Ideal solution: render transparent objects correctly always (but I don't know how that'd be implemented).

Attachments (4)

singlerender.jpg (50.4 KB ) - added by peter_ym_account 14 years ago.
Single render transparent objects screenshot
doublerender.jpg (52.7 KB ) - added by peter_ym_account 14 years ago.
double render transparent objects (current behavior) screenshot
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
waterblend.jpg (61.8 KB ) - added by Philip Taylor 14 years ago.
blending at edge of water

Download all attachments as: .zip

Change History (29)

by peter_ym_account, 14 years ago

Attachment: singlerender.jpg added

Single render transparent objects screenshot

by peter_ym_account, 14 years ago

Attachment: doublerender.jpg added

double render transparent objects (current behavior) screenshot

comment:1 by peter_ym_account, 14 years ago

As Philip reported, and illustrated in the screenshots, transparent objects are twice as opaque when rendered twice. Underwater objects appear to render correctly with only a single post-water render when fancy water is enabled; so maybe the underwater transparency double-rendering is only necessary when fancy water is disabled.

comment:2 by peter_ym_account, 14 years ago

It looks like rendering the transparent objects before plain water, but after fancy water lets us get away with only rendering them once; the attached patch makes this change. Can anyone confirm whether the patch works, thanks.

comment:3 by fcxSanya, 14 years ago

Keywords: review added

peter_ym_account you can add the "review" keyword (like I did it) when you want that someone to checked your patch. Usually Philip does it in the next few days.

comment:4 by peter_ym_account, 14 years ago

Keywords: review removed

removing review keyword for now -- it seems alpha blending over water with fancy water disabled is not quite right with this patch.

by peter_ym_account, 14 years ago

Attachment: water.434.patch added

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

comment:5 by peter_ym_account, 14 years ago

Keywords: review added

I updated the patch - it now blends correctly in both fancy/plain water cases. Transparent objects are only rendered once, after the water, except when fancy water is disabled. When fancy water is disabled, a clipping plane is used to overdraw only the underwater portion (before the water).

As Philip mentioned, this means transparent objects everywhere will no longer look twice as opaque, which may require recalibrating art.

Critical feedback is appreciated! thanks

by Philip Taylor, 14 years ago

Attachment: waterblend.jpg added

blending at edge of water

comment:6 by Philip Taylor, 14 years ago

Keywords: review removed

Thanks, seems mostly good - the clipping planes sound useful here.

I think this introduces a problem where fancy water uses alpha blending, mainly around the edges where it meets terrain. In the attachment there's some (white) terrain and a partially-submerged bush - the left screenshot is with this patch, the right screenshot is with the if (!m_WaterManager->WillRenderFancyWater()) line removed (so it renders twice). The left one cuts off too suddenly at the water, which isn't nice. (In deeper water it's okay because it's rendering the refraction texture instead of blending.)

With fancy water disabled, the patch seems to actually reduce performance slightly, since it's still rendering as many polygons as before but now it's got the clipping plane too. Since the goal is to improve performance, that seems important to fix. I guess what we could possibly do is:

  • Model.h could add flags MODELFLAG_ABOVEWATER, MODELFLAG_BELOWWATER
  • Something like CModel::ValidatePosition (not sure if that's a great place) could set one or two of those flags, depending on whether the bounding box intersects the water plane.
  • CRenderer::RenderTransparentModels can pass a flag filter to Render.
  • Then the pre-/post-water calls to RenderTransparentModels can tell it to filter out objects that aren't (at least partially) below/above the water. (Also the reflection and refraction code can then filter out objects on the wrong side of the water, so this seems useful for more than just transparent objects.)

comment:7 by (none), 14 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:8 by Andrew, 14 years ago

Milestone: Backlog
Owner: set to peter_ym_account

comment:9 by peter_ym_account, 14 years ago

thanks for the feedback! I'll have to revisit the approach.

comment:10 by fabio, 14 years ago

Milestone: BacklogAlpha 3

comment:11 by Kieran P, 13 years ago

Milestone: Alpha 3Alpha 4

comment:12 by Kieran P, 13 years ago

Priority: majorminor

comment:13 by Kieran P, 13 years ago

Owner: peter_ym_account removed

comment:14 by Kieran P, 13 years ago

Summary: Don't render transparent objects twice[PATCH] Don't render transparent objects twice

comment:15 by Kieran P, 13 years ago

Keywords: review added

comment:16 by Philip Taylor, 13 years ago

Keywords: review removed
Milestone: Alpha 4Alpha 5

Reviewed already - I think we need to do something roughly like in my earlier comment.

(Moving to Alpha 5 since that might be a good time to sort out these graphics things.)

comment:17 by Kieran P, 13 years ago

Priority: Nice to HaveShould Have

comment:18 by Kieran P, 13 years ago

Cc: peter_ym_account added
Owner: set to peter_ym_account

comment:19 by Kieran P, 13 years ago

Milestone: Alpha 5Alpha 6

in reply to:  6 comment:20 by Philip Taylor, 13 years ago

Replying to Philip:

Model.h could add flags MODELFLAG_ABOVEWATER, MODELFLAG_BELOWWATER. Something like CModel::ValidatePosition (not sure if that's a great place) could set one or two of those flags, depending on whether the bounding box intersects the water plane.

I don't think that's a good idea now - we ought to add a decent culling system so we can find all objects in the frustum below the water, render them, find all the ones above, render them, etc, instead of special-casing this with extra flags. (The culling system is probably mostly a separate task from this.)

comment:21 by Kieran P, 13 years ago

Milestone: Alpha 6Alpha 7

comment:22 by Kieran P, 13 years ago

Priority: Should HaveNice to Have

comment:23 by Kieran P, 13 years ago

Owner: changed from peter_ym_account to philip

comment:24 by Kieran P, 13 years ago

Type: taskenhancement

comment:25 by philip, 13 years ago

Resolution: fixed
Status: newclosed

(In [9814]) Graphics optimisations and features from eihrul. Add shadow filtering (PCF) option. Fix ugly shadow saturation in old lighting mode. Fix fancy water shader. Fix camera matrix computation. Support scissoring of camera frustum. Optimise vertex skinning. Inline various matrix functions. Support filtering of the list of submitted models before a rendering pass, for more precise culling. Optimise water renderer (fixes #721, based on patch by ortalo). Use scissoring when generating reflection/refraction textures. Skip reflection/refraction texture generation when no water is visible. Render alpha-blended objects differently (fixes #434). Reduce shadow swimming effects.

Note: See TracTickets for help on using tickets.