Horde3D

Next-Generation Graphics Engine
It is currently 28.10.2021, 09:16

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 13.03.2012, 15:55 
Offline

Joined: 26.09.2011, 23:56
Posts: 14
Location: Augsburg
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 :)


Top
 Profile  
Reply with quote  
PostPosted: 14.03.2012, 11:38 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1149
Location: Germany
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


Top
 Profile  
Reply with quote  
PostPosted: 18.03.2012, 16:05 
Offline

Joined: 26.09.2011, 23:56
Posts: 14
Location: Augsburg
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


Top
 Profile  
Reply with quote  
PostPosted: 20.03.2012, 00:45 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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?


Top
 Profile  
Reply with quote  
PostPosted: 20.03.2012, 13:04 
Offline

Joined: 26.09.2011, 23:56
Posts: 14
Location: Augsburg
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?


Top
 Profile  
Reply with quote  
PostPosted: 24.03.2012, 22:41 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 13.12.2016, 09:57 
Offline

Joined: 02.12.2016, 12:30
Posts: 23
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....

_________________
~@AlmahmudRony@~


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group