weird thing with renderworld rendertime

Blitz3D Forums/Blitz3D Programming/weird thing with renderworld rendertime

RemiD(Posted 2014) [#1]
I was doing some tests to see how much ms it takes to render 1000000 triangles in several surfaces of around 32000 vertices/triangles each.

If i calculate the rendertime the first time, the value is higher than if i calculate the rendertime the second time. I suppose that is because the first time the surfaces of the mesh are sent to the GPU ? And the second time the surfaces of the mesh are already in the GPU ?

Try to run the code below with 1 renderworld and then with 2 renderworld, you will see what i mean
edit : updated code



Floyd(Posted 2014) [#2]
A discussion of this from ten years ago: http://www.blitzbasic.com/Community/posts.php?topic=37168#408365

It includes contributions from professionals, such as Mustang who was at Futuremark at the time.


Guy Fawkes(Posted 2014) [#3]
AWESOME! =D


Guy Fawkes(Posted 2014) [#4]
Something like this, Floyd?

I don't know if my addition to this "PreCache()" function does it justice or not, but perhaps you can tell me if it does or not, and why you came to that conclusion.

I too would like to be able to add 10,000 trees on 1 area of my map! :)



Thank You so kindly! :)

Sincerely,

~GF


RemiD(Posted 2014) [#5]
I don't understand what is the point to rotate the camera twice, if all the meshes are in the camera fov, i think that's enough.
Also i don't know if that's a good idea to free the camera which has rendered these meshes, i have read that when a mesh is not in the camera fov and there is not enough space in the vram, the meshes which are in the camera fov can be resent to the vram and the meshes not in the camera fov stored in vram can be erased.
So if you free the camera, no more meshes are in the camera fov...

An "overview" render seems to be enough. See my example above.


Guy Fawkes(Posted 2014) [#6]
its a "dummy" camera, Remi. :)

It's only used to "warm up" the graphics card. You know... Put things in memory then take them out so it registers the cache faster? :)


RemiD(Posted 2014) [#7]
I have updated the code in the first post if you want to try with the "overview" idea.


Guy Fawkes(Posted 2014) [#8]
Awesome, Remi! :) 1,000,000+ Triangles in less than 2 seconds!

Now... Do you think you can somehow get it to work with a "Forest of Trees" of complex 3D tree models?

You know, like 25,000 trees around the map in 1 area, and 25,000 or so in another part of the map?

EDIT: Here's a Tree model I made in tree[d] with around 12,835 triangles or so.

https://www.mediafire.com/?4w6q9qwd5k7ctv5


RemiD(Posted 2014) [#9]
The RenderTime is in ms...
I have around 150ms on my laptop computer and around 90ms on my desktop computer.
These are low end computers, but they are recent enough (2009)
2 seconds = 2000ms seems to be a lot. Is this on a crappy netbook or on a 10+ years old computer ?


Here's a Tree model I made in tree[d] with around 12,835 triangles or so


A tree does not need to have 12835 triangles to look good. Bah !


Guy Fawkes(Posted 2014) [#10]
I miscalculated. It was around 200 ms. I was tired last night.

It was on my laptop which is built for gaming. 750 GB Hard drive, 4 GB RAM, Intel Core i3.


Rroff(Posted 2014) [#11]
You'd only draw 12K poly versions for the closest 2-3 trees really, anything further than short range can be dropped down to a couple of dozen polys or so and still look good enough and further than that its best to bake them into some kind of background image.


Guy Fawkes(Posted 2014) [#12]
@Rroff: How would you do that?

I mean we want to have a way above decent and ALMOST superb looking forest, right?

Well how would we do that Rroff / Remi?


RemiD(Posted 2014) [#13]
What i would do :
Create many pivots and position rotate them where each tree must be.
Create one mesh with one surface and many textured quads in this surface (up to 32000/4 (4 vertices, 2 triangles) so this will allow you to have 8000trees per surface.
There would be 8 textures for each tree, each texture would be a prerendered tree with an orientation of 0, 45, 90, 135, 180, 225, 270, 315
Each quad would be textured with one of the texture depending on the orientation of the tree related to the camera position (not sure if this would be fast enough to change 8000 textures but maybe yes if it is done only each xms)
For the trees which are near player and in the camera fov, 3d models would be positioned around the player with the appropriate orientation (same as the pivot)

But a nice tree does not need 12835 triangles. 500 tris is enough i think, you only need a trunc (subdivided cylinder and cone), some branches (subdivided cylinder and cone), some leaves (textured quads)


Guy Fawkes(Posted 2014) [#14]
Well, I prefer my forest to look as close to realistic as possible.


Rroff(Posted 2014) [#15]
I would probably take a scene graph type approach so as to be able to quickly identify nearby trees and render them in all their glory (I'm not personally against 12K poly trees for the closest ones as I like graphic fidelity) and 2 levels of single surface systems (probably using a few instances so as to make handling range based LOD easier) like RemiD describes for mid range and long range trees.

EDIT: This is just placeholder assets from an old project so don't judge it on its artistic merits but this is basically the level of detail on my mid-range trees (~16-20 tris each)




Guy Fawkes(Posted 2014) [#16]
Um wow... Well is there a way to drop the amount of polys in a "tree[d]" model?


Rroff(Posted 2014) [#17]
Not really played around with tree[d] but for stuff like that I'd normally chuck the output mesh file into something like blender or milkshape or whatever and use an LOD tool to reduce the poly count.

Looks like the nature of the models output by tree[d] don't naturally suit use of tris decimation tools though, does it have anything internally to output different LOD versions?


Guy Fawkes(Posted 2014) [#18]
Idk if it does or not.


Guy Fawkes(Posted 2014) [#19]
Any luck getting 10,000 trees in one area?


stayne(Posted 2014) [#20]
I'm pretty sure most "game ready" models come with high, mid and low-poly versions? I would just hide/show each one according to distance. I suck at programming so eh. Maybe a Select/Case method?


Guy Fawkes(Posted 2014) [#21]
Perhaps. But it's faster to use "If/Else" rather than "Select/Case" because you cut off 2 or more lines when using "If/Else". And for logic, it's easier to understand.


angros47(Posted 2014) [#22]
You don't have a clue about how a compiler works, do you? Having more lines in the source code does not mean that the compiled code will be longer, or slower.


Guy Fawkes(Posted 2014) [#23]
If you're not going to be of any help, please leave this thread & don't come back, troll. This is RemiD's thread. And I don't care what you think or say about me after this post. I am now ignoring you.


stayne(Posted 2014) [#24]
I meant something like:

For t.tree = Each tree

  Select True
    Case EntityDistance(camera,t\mesh) < 1000
      ShowEntity(t\highpolymesh)
      HideEntity(t\lowpolymesh)
    Case EntityDistance(camera,t\mesh) > 1000
      HideEntity(t\highpolymesh)
      ShowEntity(t\lowpolymesh)
  End Select

Next



Rroff(Posted 2014) [#25]
^^ Problem with that approach your going to hit overheads pretty fast long before you get to 10,000 trees.

You need to batch mid and long distance versions into cells of single surfaces containing multiple trees and use a scene graph approach to only draw very close ones as individual instances in high detail. (You should never be walking through 10,000+ instances of "tree" to find the close ones).


Guy Fawkes(Posted 2014) [#26]
Um.... In English? ROFL! XD

Care to tell the rest of the class? :P


Guy Fawkes(Posted 2014) [#27]
Well. The forest has to have a couple gigantic trees and a few 'big' yet small trees. If I use a low poly, good looking tree with scaleentity, will I be able to keep the frame rate at 60 or close to 60?

That's what I'm shooting for.


RemiD(Posted 2014) [#28]
Only one way to know : try.
You have already all the infos that you need to do it.
Know that a tree/plant can also be built with code with different parts (trunc, branches, leaves).


Rroff(Posted 2014) [#29]
Expounding on it all in detail from scratch is beyond a post here really, will try and get some sample code up at some point but work schedule doesn't give me much time to sit down and code atm.

For B3D I would probably use a cheap trick with types so as to a have a limited number of cell types that point into a bigger collection of tree types (with a dummy tree entry acting as a demarcation between trees in each cell).


Rick Nasher(Posted 2014) [#30]
Very interesting topic.
I would love to see a working example of this for I want to do it in a free roaming environment(and: I'm not a brilliant coder, but I do have some brilliant ideas, so I have a lot to learn ;-).