Horde3D
http://horde3d.org/forums/

Tweaking the frustum culling
http://horde3d.org/forums/viewtopic.php?f=2&t=1651
Page 1 of 1

Author:  eiguckamalda [ 13.03.2012, 15:55 ]
Post subject:  Tweaking the frustum culling

Hello,
It’s me again having some problems… ;)

The water simulation I’m working on uses multiple maps generated at different stages. At one stage, the reflection-stage, the shader mirrors the viewProjMat at the water-plane to accieve the “look from below” needed for reflection. This works quite fine and is very cheap depending on computational time in comparison to using a second camera, which would cost double of the draw calls mentioned in an older thread of mine.
The problem is, if the camera looks more and more to the ground, the original camera can’t “see” the trees and their leaves anymore, so the frustum culling correctly culls them away. But in the reflection you should still “see” the trees and their leaves. To illustrate my problem, I’ve added three screenshots in a row, where the camera looks more and more to the ground. Left is the final image, right is the reflection-map generated in the reflection-stage.

Image

I’ve thought about two solutions for my problem:
- Stretching the culling frustum at y-axis to prevent the trees from culling
- Increase the size of the AABB of the trees to the bottom to keep the AABB still in frustum

Searching the forum, the api and the code I found no function to implement one of my solutions mentioned before. So has anyone an idea or propose me how the problem could be fixed?
Thanks :)

Author:  Volker [ 14.03.2012, 11:38 ]
Post subject:  Re: Tweaking the frustum culling

Regarding your second proposal: AFAIK there's currently no API to adjust the AABB programmatically. What you can do instead is adding some invisible geometry to the tree models so the AABB will be increased automatically. But I guess that would solve your problem only temporarily because I guess you'll have always some geometry that may be culled because the original viewProjMat won't see some geometry.

Stretching the culling frustum would be a possible way. The camera frustum is calculated in CameraNode::onPostUpdate() in egCamera.cpp. Maybe you can add an EnhancedFrustumBottom, EnhancedFrustumTop, EnhancedFrustumLeft, EnhancedFrustumRight enum to the CameraNodeParams struct (in egCamera.h) and set those params via the void CameraNode::setParamF( int param, int compIdx, float value ) function (alternatively you could also use the compIdx param to differentiate the top, bottom, left, right values and use only a single EnhencedFrustum enum value).

Then in CameraNode::onPostUpdate() you could use those values to stretch the frustum.

Not sure if that fits your needs, since I only skimmed over your question very quickly

Author:  eiguckamalda [ 18.03.2012, 16:05 ]
Post subject:  Re: Tweaking the frustum culling

Hi Volker,

thanks for your reply! With your comment I finally managed to get this working by adding/rewriting a few lines in the egCamera.cpp 8)
But there's still a problem left: When my project is finished it's going to be added to the GameEngine and then this problem comes back like a boomerang. Are there any future plans on shipping a function with Horde to change the culling frustum? I would be glad to help creating such a functionality :)

Greets,
Peter

Author:  marciano [ 20.03.2012, 00:45 ]
Post subject:  Re: Tweaking the frustum culling

Not sure if I understand correctly what you are doing. When you mirror the matrix in the shader, you still have to render all objects in your reflection pass, so you won't save any draw calls, only the culling. Or did you mean something else?

Author:  eiguckamalda [ 20.03.2012, 13:04 ]
Post subject:  Re: Tweaking the frustum culling

marciano wrote:
Not sure if I understand correctly what you are doing. When you mirror the matrix in the shader, you still have to render all objects in your reflection pass, so you won't save any draw calls, only the culling. Or did you mean something else?

You're absolutely right! Meant that :) You agree, that this way is faster than rendering a second camera or is it more or less equal in computation time regarding that I have many nodes in my scene?

Author:  marciano [ 24.03.2012, 22:41 ]
Post subject:  Re: Tweaking the frustum culling

In theory you save the culling which can be a bit faster depending on the scene complexity but currently it is always done again for each rendering pass, so there won't be any benefit. For the future we would have to introduce the concept of views and cull several views concurrently. That way having a separate camera for the reflection view will just have a small performance overhead.

Author:  Almahmudrony [ 13.12.2016, 09:57 ]
Post subject:  Re: Tweaking the frustum culling

Wow!
i was searching for water shader for my open world game project exactly like eiguckamalda did above.. :)
can you tell me how you done that with H3D. any good advice or a good demo or a link would be cool.....

:)
Thank you....

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/