Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Baboonanza

Pages: 1 ... 5 6 [7]
91
DF General Discussion / Re: 3Dwarf beautification project
« on: October 12, 2008, 12:32:05 pm »
How to put this ... I'm pretty much doing all of that already. ^^

You can check a post from me on that topic here: http://forums.somethingawful.com/showthread.php?threadid=2917631&userid=125080&perpage=40&pagenumber=2#post350470768

Summary: I was completely off-base and apparently trying to for-loop through 15000 items per render call is a tad too much. I'm not exactly sure what i can do about that yet. Maybe it's the fact that on each loop instance it instances a new copy of the array index, but in the end i'll figure something out.

Also, VBOs scare me. Working in Perl i can't use ANY c++ examples, since the syntax is slightly different and the variable typing radically so. Aside from that i've also been unable to find a simple enough example to go in and experiment with, since all examples seem to be "let's draw this uber-complex shit with VBOs", instead of "how do i draw a single triangle with VBOs?".
Display lists are nice and easy. They have begin, end, a number, and that's it.
Apologies :) I suspect using VBOs would still give you some advantage but as you say they may be more difficult to use from Perl. One thing to consider using display lists is that I believe they are optimized more efficiently by the driver (ie straight to VBOs) when they contain only geometry calls (no state changes). This might be something to try.

As for the objects, I can think of one or two methods to reduce your overhead that should be simpler than normal frustum culling etc., although I'm basing this on a guess that they are stored similarly to constructions. If this is the case then they are ordered by tile coords (z then x then y if i remember correctly). This immediately allows you to skip multiple items in a single tile, since they will all be consecutive. As you also know which tiles are visible you should also be able to limit drawing to visible objects, especially by z level culling. To avoid iterating through the whole list to find certain coords I would suggest using a binary search, which is what Toady uses in DF.

As you can tell, I have an interest in the subject but I'm just trying to help so please don't take offense if I'm telling you stuff you already know ;) At some point I'll have a look at the code and see if I can help but not knowing Perl is a bit of a hinderance there.

Edit: And if it helps, here is my (limited) knowledge of the construction/building structure:
offset, length, field
0x0 WORD x-coord
0x2 WORD y-coord
0x4 WORD z-coord
0xC WORD stone matgloss index (ie. 192 = bauxite) of contruction material
I never got as far as working out how none-stone constructions worked.

 

92
DF General Discussion / Re: 3Dwarf beautification project
« on: October 10, 2008, 06:39:39 am »
This means that any slowdown you may experience will absolutely only come from OpenGL bogging down under the load of how much it has to draw.
If OpenGL rendering is what's slowing it down then you're doing something wrong :). Seriously, the numbers of triangles you're drawing is trivial, the trick is just knowing how to correctly and efficiently cache the geometry data on the video card. My suggestion would be:
Use Vertex Buffer Objects. These are the most optimised way and also give you more control than display lists.
For each terrain block:
   1 vertex buffer containing triangle vertices (ideally these should be optimised for vertex sharing between triangles)
   1 index buffer containing all the indices for drawing triangles, sorted by triangle texture (so that you have all 'granite' textured triangle indices, followed by 'loam' ect). It may be easier to use a different index buffer for each texture, but this adds the overhead of an additional GL pointer call.
   A structure containing the textures and their first index and number of triangles. To draw the block you iterate through the textures and call glDrawArrays once for each texture.
When you update the blocks it may also be faster to do a memcmp on the tile data to avoid regenerating the buffers when no changes take place.

Which leads to the next thing. I think i have solved the problem of "Omg, i have 10 layers of stones in my stone bunker and the 3000 item are bogging down the performance!" The problem here is: I figured, since items aren't very static, i wouldn't need to put them in a display list. Reason being: Display list generation isn't very cheap and requires for me to create structures to organize them. However i'm pretty much forced to do it in some way.
Each object's model should be stored *once* in vertex/index buffers as outlined above (or a display list if you really want to). Then draw this model as many times as necessary to represent the visible objects, and it won't make any difference whether they are moving or not.

If you have any interest in performance at all you should absolutely avoid sending *any* geometry to the graphics card during the rendering loop, and just be drawing precached data. This will give you many more cycles to spend on updating the map.

93
DF General Discussion / Re: 3Dwarf beautification project
« on: October 07, 2008, 07:05:48 am »
Very nice!

Have you had any luck with rock materials yet? If you are interested I can give you a full explanation (though my offsets are a bit out of date), it's more complicated than I ever would have imagined and my previous explanation was incomplete. I also have some info on determining the material types of constructed walls/floors.

94
Maybe I'm being moronic, but the post doesn't actually seem to say what the purpose of the tool actually is.

Is it designed to allow patterns to be created so that tools can automatically find the memory offsets based on pieces of assembly code that use them, even when a new version is released (as long as the pattern still holds)? If so, cool :)

95
1- Yes. C++/OpenGL using a BSD-licensed GUI toolkit. It's a bit like Qt, but without all 'new' usage, and has some very fast containers: www.ultimatepp.org
2- This is more difficult to explain :)

As Toady stated in another thread, the DESIGNATION_MATGLOSS_BITX is the index of the geological layer for a rock tile. You have to jump through a load of hoops to link this to a material type though.

To get the list of geological layers you have to:
1- Find the coordinates of the map block on the world map. ie. (mapXY + blockXY + (1,1)) / 16
2- Use these to find the region block data in the world map. There is a 2-dimensional array that holds these
3- Read the geological block index from the region block (I assume these are kept seperate to save space)
4- Find the geological block. These are stored in a vector.
5- Read the list of matgloss indices.
You can then use the designation matgloss index to find the material.

My notes:
Spoiler (click to show/hide)
My hideous code to do it (Point region already holds the correct region coords for the block, proc is an abstraction of the Win32 ReadProcess calls):
Spoiler (click to show/hide)
The relevant offsets:
Spoiler (click to show/hide)
As you can imagine, this took a little while to figure out :) Good luck if you try and implement it. I'm going to try the same contructed walls/pillars next but that seems even more complicated.

96
I'm actually working on a more advanced renderer at the mo. and to be honest the concern about performance is largely unneccessary.

My current fortress (relatively small  <60 dwarves) on an 18x18x34 map (6 region squares, 288x288x544) tiles is rendered with:
452272 triangles
328313 verticies (optimal sharing isn't always possible because of texture-coord issues)
24 textures (this will probably go up, I'm using the same texture for multiple materials at the moment)
only 1 draw call per texture using 1 vertex buffer and 1 index buffer for all geometry
per-pixel lighting (simple) and shadow mapping
And performance is fine, and much much faster than 3Dwarf on my Radeon X800. It even runs without GPU shaders on the GeForce2MX at work (although a bit slowly)

TBH using a 3D-party renderer would only help with certain things. The difficult work is in the geometry creation, but it would help with things like dynamic LOD for trees and best case senarios such as when the view is inside. What it probably wouldn't help with is the exterior view (worst-case) where you just want to push geometry as fast as possible to the GPU and using paging/BSP/occlusion culling might just increase the overhead. I also suspect that the nature of the geometry combined with the floating viewpoint maps isn't very well suited to the usual optimisation techniques for landscapes.
But then I'm only an amateur so I may be wrong :), and writing the renderer is mainly the point of the exercise for me.

Also I think the reasons people have been focused on hacking memory rather than the save file is:
1- There is already some info on it from tool writers who need to hack the running process anyway
2- Perhaps most importantly it's much easier to find the information, since you can step through the assembler in a debugger to find where things are. With so little information on the internal data structures used this is really the only way - just finding the type of material used for a virgin rock tile requires knowledge of 4-5 different structures.

As for using the file-depot format, I've looked at it and I'm not sure it contains enough information. There is no actual data on the type of the tiles, just the image.

I'll be releasing my renderer when it's finished, or nearly so (I'll probably release before implementing good trees, since these are a real PITA). As I have the geometry anyway I could also export it to some other format, but that's not high on my list of priorities

97
DF General Discussion / Re: 3Dwarf beautification project
« on: August 07, 2008, 06:24:26 pm »
Hi. This is a fasinating thread and I've got a related question (I'm also playing with 3D visualisation).

DESIGNATION_MATGLOSS_BIT1-4 seems to be an index into a list of stone types that make up the layers for the map. However, I can't find the relation between this index and the array of stone types loaded from the raws. Presumably there is some sort of intermediate array, but I can't find it.

Does anyone have any info on either the form or location of this data? Or am I barking up the wrong tree?
 Cheers.

Pages: 1 ... 5 6 [7]