Thứ Tư, 1 tháng 5, 2013

Wednesday Success

The Day After The Night Before

Well guys and gals, I spend a good few twilight hours working on my little instance stamp system, taking it from a DrawMesh call to exploding the code out so I could control the whole process again at the DirectX level.

The process took many hours because you have to deal with vertices, indices and draw calls very carefully. Your only evidence that it works is when you see polygons, and when you don't see polygons it could be for a hundred reasons. To this end I used a technique of swapping out one bit at a time the stuff I could run and see polygons, with the new code that was untried. The final step was to recreate and fill the buffers themselves which was a lot of code and a leap of faith, and after one or two false starts managed to get my polygons back!

What We Have

What we have now is a function that collects data from the reference map (populated by adding instance stamps as the user adds objects to the level) and a second system populates a newly created vertex and index buffer with this transformed data to something that can be rendered.  It's only one buffer and one FVF format, and a hacked in way to populate the data, but it is rendering and in the general shape of the final implementation.

As A Bonus

I also changed the index buffer from 16bit to 32bit for instance stamp renderings so we are no longer limited to 65535 vertices per buffer as well. Once upon a time (five years ago) older graphics cards could not cope with this, but all graphics cards handle 32 bit vertex indices fine now so we can cram a lot more stuff into a single buffer.  This will mean better performance and less code to manage fragmented data sets.

Signing Off

It's about 4PM now and the sun is shining, so going to spend two hours baking myself in the garden, then return after dinner to move the chess pieces further. My hope is to manage the buffer so that as I add more polygons, it creates a second and third buffer to keep up with demand. I also plan to sort out the mesh transformations properly so they take into account the frame matrix as well as the instance properties passed in for the particular object to be rendered.  Should not be too hard, except that matrix math is not my strong suit (even after 15 years working with 3D engines).

Không có nhận xét nào:

Đăng nhận xét