Opened 14 years ago

Closed 10 years ago

Last modified 10 years ago

#579 closed defect (fixed)

Water reflections use wrong camera frustum for culling

Reported by: frapell Owned by: philip
Priority: Nice to Have Milestone: Alpha 17
Component: Core engine Keywords:
Cc: Patch:

Description (last modified by historic_bruno)

When watching an object through a water reflection, but this object is outside the camera, unwanted behaviour is observed. I uploaded a video to show the bug.

http://www.vimeo.com/15241286

Related: #504

Change History (13)

comment:1 by Philip Taylor, 14 years ago

This is a roughly similar problem to #504 - it's using the wrong camera frustum for culling.

comment:2 by (none), 14 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:3 by Andrew, 14 years ago

Milestone: Backlog
Priority: majorminor

comment:4 by Kieran P, 11 years ago

Milestone: BacklogAlpha 12
Owner: set to wraitii

comment:5 by wraitii, 11 years ago

Okay, so this is actually sort of a duplicate to #504 (which I sadly noticed after 3 hours of tinkering.)

Basically everything works properly, the trouble is that objects too far-away get culled in the pre-rendering phase, and thus pop up suddenly. Mostly trees, since they are tall. Namely, there is a call to CGameView::BeginFrame which updates the cull-camera, and then Crenderer::RenderScene culls the models too far away (I believe it's enumerateobjects() that does it).

Information can be found through CRenderer::DisplayFrustum().

The easy way out is pushing CGameView::GetCullFOV() higher, right now it adds 6 degrees. Adding about 15/20 mostly solves the issue for trees, however it comes at a semi-serious rendering cost. It could perhaps be made "setting dependent", ie if reflections are wanted push it above, if not don't.

Linked to #504 because it's sort of the same issue, though it's worse for #504 as shadows might require an even bigger FOV change, and obviously that's just out of the question. However, fixing #504 properly could fix #579, or perhaps the same method could be used to fix both.

I'm waiting on your opinions, but I don't really have time (must do AI work) or skill to fix that particular problem.

Edit: I believe Philip's last comment on #504 is still mostly relevant and mostly right.

Last edited 11 years ago by wraitii (previous) (diff)

comment:6 by historic_bruno, 11 years ago

As I understand it, the only way to do #504 properly is to determine exactly which objects cast shadows falling into the camera view (similar for reflections). If we have a solution for #504, then we have a solution for this ticket, albeit slightly different. What we have now is already a hack that expands the culling FOV a bit, with side effects like worse performance (as you mentioned), decreased shadow map detail, and it still won't work with combinations of arbitrarily tall objects, low sun angles and camera views. So yeah, simply expanding it more as a hack would be worse.

If I remember correctly a past discussion with Philip, there are actually at least three cases to consider: shadows, reflections, and refractions.

Last edited 11 years ago by historic_bruno (previous) (diff)

comment:7 by wraitii, 11 years ago

Refraction seem like less of a problem. First, the water is often fairly murky, so you usually couldn't see any object that could be culled. Furthermore, there rarely are any object underwater that would cause the issue. But I guess it could happen.

So yes, this is basically unfixable unless it's really tackled thoroughly.

comment:8 by Kieran P, 11 years ago

Milestone: Alpha 12Backlog

Moving to backlog. Perhaps myconid's upcoming changes to the renderer will make generating shadows a lot less problematic. We'll wait and see. Refs #504

Last edited 11 years ago by Kieran P (previous) (diff)

comment:9 by historic_bruno, 11 years ago

Description: modified (diff)
Summary: Water reflections bugWater reflections use wrong camera frustrum for culling

comment:10 by historic_bruno, 11 years ago

Summary: Water reflections use wrong camera frustrum for cullingWater reflections use wrong camera frustum for culling

comment:11 by historic_bruno, 11 years ago

Owner: wraitii removed

comment:12 by philip, 10 years ago

Owner: set to philip
Resolution: fixed
Status: newclosed

In 15445:

Fix culling for shadows and reflections.

Previously we had a single culling frustum based on the main camera, and any object outside the frustum would never get rendered, even if it should actually contribute to shadows or reflections/refractions. This caused ugly pop-in effects in the shadows and reflections while scrolling.

Extend the renderer to support multiple cull groups, each with a separate frustum and with separate lists of submitted objects, so that shadows and reflections will render the correctly culled sets of objects.

Update the shadow map generation to compute the (hopefully) correct bounds and matrices for this new scheme.

Include terrain patches in the shadow bounds, so hills can cast shadows correctly.

Remove the code that tried to render objects slightly outside the camera frustum in order to reduce the pop-in effect, since that was a workaround for the lack of a proper fix.

Remove the model/patch filtering code, which was used to cull objects that were in the normal camera frustum but should be excluded from reflections/refractions, since that's redundant now too.

Inline DistanceToPlane to save a few hundred usecs per frame inside CCmpUnitRenderer::RenderSubmit.

Fixes #504, #579.

comment:13 by B. Guns, 10 years ago

Milestone: BacklogAlpha 17
Note: See TracTickets for help on using tickets.