Horde3D

Next-Generation Graphics Engine
It is currently 10.11.2024, 20:47

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 11.01.2011, 11:36 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
Hello!

As I see, the invisible nodes geometry are still in the video memory.
Can I control somehow this behavior? I have a huge environment
with large amount of geometry, and just a part of this is visible
at any given time.

anchor


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 12:24 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
You'll probably need to unload the resource.
I think that will be the only way to remove them from the video memory.

I'm not sure how that would affect the scene node, if you attempted to render it that is.
But I'd guess it would be fine as long as you don't try to render the scene node whilst it has no geometry. Otherwise you'd have to remove the scene nodes associated with a removed geometry.

So have you tried unloading the resource?


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 14:24 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
Thank You for the answer!

Yes, meanwhile i solved the problem with resource unloading,
and reloading from the system memory. The performance is
acceptable :) And lot of video memory saved.

Here is a small video from our project:
http://www.youtube.com/watch?v=kMEDbXeRlxk

anchor


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 14:47 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
You're welcome. I wish I answered earlier.
Did you simply call h3dUnloadResource? Or did you remove the scene node when it became invisible? Since nodes might share a resource..
From what you described, I guess you need to unload the resource.

That is a very nice demo. Is that your project or what company do you work for? If you don't mind me asking.


Last edited by vikingcode on 15.01.2011, 05:17, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 18:34 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
I'm use h3dLoadResource(),h3dAddNodes() if visible, and h3dRemoveNode(),h3dUnloadResource() if invisible the node.
This geometry is not shared, every node is unique. (generated vegetation geometry)

Soon We will announce the mentioned game in horde3d forum :) (Its not my project)

anchor


Top
 Profile  
Reply with quote  
PostPosted: 15.01.2011, 05:30 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
anchor wrote:
This geometry is not shared, every node is unique.
If so, why don't you try unloading the resource but not the scene node. Leave the scene node but just set it to not be rendered.
Code:
h3dSetNodeFlags( modelNode, H3DNodeFlags::NoDraw, true );

It may also be necessary to remove the geometry from the mesh, if a mesh can have a NULL geometry that is. You'd need to remove the geometry from the Mesh first if that is the case...maybe not actually, because you are not accessing the geometry, simply setting a new geometry (NULL).
Then when the node becomes visible again, you will only need to load the geometry again and attach it to the mesh for the scene node.

Or if the above is not possible, you could set every invisible node's geometry to have only 1 vertex (the same point for all). That would save a lot of geometry space (nearly all of it) ...

This would save time on creating scene nodes, and I think it would save much more time than you would lose by having many invisible scene nodes to traverse.

What do you think?


Top
 Profile  
Reply with quote  
PostPosted: 15.01.2011, 12:50 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
Maybe I will try it. But Marciano knows the truth, is this possible or not :)

anchor


Top
 Profile  
Reply with quote  
PostPosted: 15.01.2011, 13:54 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
I am sure that the 2nd method I mentioned will work.
vikingcode wrote:
you could set every invisible node's geometry to have only 1 vertex (the same point for all). That would save a lot of geometry space (nearly all of it) ...

I will explain more clearly what I mean. You said that the geometry is all unique.
So to save video card memory for invisible nodes, unload the geometry resource for the invisible node and attach a static geometry resource (one that you build when you initialize the application) to the node's mesh.
Use the same static geometry for every invisible node. That way no matter how many nodes are invisible you will actually only need 1 geometry kept in video memory for the invisible nodes, and it will be pre-built so you just attach it. Then when the node becomes visible again, simply load the proper geometry again and attach it to the node again.

That's what I'd do.
Do it. It makes sense. Don't wait for Marciano. :wink:


Top
 Profile  
Reply with quote  
PostPosted: 15.01.2011, 23:54 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Hi anchor,

setting an invalid geometry resource for a model node is currently not allowed (see ModelNode::setParamI in the horde code). Using some shared dummy resource as vikingcode recommends and setting the Inactive flag for the nodes should work fine.

If your streamable geometry is static (not skinned), instead of loading/unloading resources, another thing you could consider is using a pool of geometry resources for which you update the vertex data. This is a bit more complicated though. Probably you will have to parse the geo file yourself (which is actually quite easy) and second you need to make sure you don't stall the GPU by partly updating a vertex buffer that is still referenced in the command buffer. This would save you from the overhead of allocating/deallocating resources but if you don't have any performance issues with that, I would just keep it simple.


Top
 Profile  
Reply with quote  
PostPosted: 16.01.2011, 17:28 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
I tried the dummy geometry solution, but the shadow goes crazy, when I
rotate or move the camera. This happens when the node changed from
invisible to visible. (the dummy geometry changed to real one)

Image

Image

The nodes bounding box seems okay.

anchor


Top
 Profile  
Reply with quote  
PostPosted: 16.01.2011, 18:12 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
What do you mean the shadow goes crazy?

I'd do it in this order.
Set the node invisible, attach the dummy geometry to the mesh, unload the geometry resource.
Load the geometry resource, attach the geometry to the mesh, set the node visible.


Top
 Profile  
Reply with quote  
PostPosted: 16.01.2011, 18:19 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
I tried the same order, what You proposed.
The shadow disappears randomly, when I
move the camera. (and the node disappears
sometimes too) Its looks like the bounding
box corrupted, and the clipping not working
properly.

anchor


Top
 Profile  
Reply with quote  
PostPosted: 17.01.2011, 03:08 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
anchor wrote:
The shadow disappears randomly, when I move the camera. (and the node disappears sometimes too) Its looks like the bounding box corrupted, and the clipping not working properly.

So does this only happen after you have changed the geometry to a dummy geometry and then changed it back to the proper geometry?
Now Marciano could help! :shock:

Maybe when scene nodes are modified they need a cycle of the engine to set them up properly. Maybe there are internal methods that set up the bounding boxes etc.. But when they are first created they are setup properly in the initializer so to speak.
Marciano is that wrong? It's just the only guess I can make without more knowledge.


Top
 Profile  
Reply with quote  
PostPosted: 19.01.2011, 01:44 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Actually you would have to update the mesh node parameters as well, otherwise they index into a vertex buffer which is too small. But these attributes are read-only at the moment. For a future version I would prefer to have the batch data (index and vertex range) stored in the geometry resource along with the local AABB to avoid all these issues that we have now ;)

Are there any issues with your first solution of just unloading the resource and deactivating the corresponding scene nodes?


Top
 Profile  
Reply with quote  
PostPosted: 19.01.2011, 06:25 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
Marciano wrote:
Actually you would have to update the mesh node parameters as well, otherwise they index into a vertex buffer which is too small. But these attributes are read-only at the moment.
Ahhh of course, the geometry is put into a mesh. Does the mesh have its own set of indices?
Internally, why not just attach the geometry to the mesh and reference the geometry from within the mesh when retrieving mesh geometry data? (I'm probably not thinking about many design issues!!)

Marciano, if the Mesh parameters are read-only, does that mean that anchor must also remove the mesh node and then create a new mesh node when the geometry is loaded again?
If so, then he will also need to remove the model node which holds the geometry will he?

Marciano wrote:
For a future version I would prefer to have the batch data (index and vertex range) stored in the geometry resource along with the local AABB to avoid all these issues that we have now
Sounds like a good move to make.

Marciano wrote:
Are there any issues with your first solution of just unloading the resource and deactivating the corresponding scene nodes?
Not just deactivating, but removing the scene node is what he did.
He said that works well enough so he should be ok for now.

anchor, what happens if you simply remove the geometry resource and set the node invisible?
Do not remove the Node.
Then when the node becomes visible again, load the geometry resource again.

If that works, that is the most efficient. You should only need to remove the node if geometry resources are shared, then you must remove all nodes that contain that particular geometry.

I don't see why it should not work to simply unload the resource because the engine will not attempt to render the invisible node, hence the engine should not try to access the geometry for invisible nodes.

The only problem is, does the Mesh and Model node need to be recreated, or can they be updated?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 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