I’ve been working on a terrain editor in my spare time, and I’ve been noticing a bit of a performance snag. I’ve implemented the ability to script certain filters that can modify the heightmap or the blend texture, including filters to randomly locate terrain blending based on noise fractals, filters to place roads etc… But I have noticed that the more I use filters that modify the blend map, the worse my performance degrades. For example, when I first start the application, I get decent performance: screenshot.
When I run a fractal filter that iterates the blend image and sets the pixels of the blend, then calls blendtex:SetData(blend) to upload the edited texture, the framerate drops noticeably: screenshot. Doing further operations such as building an elevation map and adding a road drop it even further: screenshot. (Note that the heightmap, while it has a miniscule effect, is nowhere near as drastic as modifying the blend map.) If I quicksave the heightmap and blendmap, exit the application and restart, then load the quicksaves, I get a lot of performance back: screenshot.
So I’m wondering if I’m handling the process of modifying and updating the blend texture sub-optimally. My standard technique is to modify the texture, or part of a texture, directly into the image then upload the image via Texture2D::SetData(). But I wonder if I somehow miss a crucial step, perhaps related to detail levels or to discarding old texture data or something of that nature.
Possibly related, when I create the texture for the blend map I initially call SetSize(0,0,0,TEXTURE_DYNAMIC) in order to specify dynamic usage, as I did not see anywhere to specify the usage otherwise. However, according to the comments, using sizes of 0 causes the texture size to follow the application window size. Then, when SetData is called, the texture is resized again.
I am using a 64-bit Mingw-w64 build with LuaJIT and Direct3D.