Yes, it's redrawing all the scene again, but tiles are cached. I think this is used in Map Editor framework.
Actually it's impossible to be done, but maybe we can achieve a better way of rendering, like others 2D engine or just optimize the OTC way and hope for better results.
What bothers me is, on my video, I filled a screen up with items and still had 300 fps.
(I also filled a screen up with animated items, but it wasn't on the video, I lost about 20-30fps with animated items instead of non-animated items)
But when I filled the screen up with creatures, even after removing names, and health bars, I still saw a drop in 150-250 fps.
And these creatures had the outfit OF an item.
I will do a test later, where I fill one screen with items, and another screen with creatures that look like the same exact item.
If it is drawing the same sprite, shouldn't it have the same FPS?
It shouldn't matter if it is a creature or not.
**EDIT**
@Sportacus found a interesting video on youtube that I studied a bit last weekend.
Tibia apparently let people do a benchmark for their client, and it looks like tiles are drawn differently than we do on the Otclient.
If you watch the video. When teleporting to new areas, the tiles are NOT drawn in any order.
Instead, it looks like they instead loop through sprites, and check the tiles for matches.
OTClient currently draws like this: (just an simplified example)
Code:
for x = Left, Right do
for y = Top, Bottom do
for z = 0, 15 do
for stackpos = 0, 255 do
local item = getItem(x, y, z, stackpos)
local texture = getTexture(item)
draw(texture)
end
end
end
end
But the video looks more like they are doing something like.
Code:
local texture = getTexture(0)
local loaded = true
for searchItem = 0, LAST_ITEM do
loaded = false
for x = Left, Right do
for y = Top, Bottom do
for z = 0, 15 do
for stackpos = 0, 255 do
local item = getItem(x, y, z, stackpos)
if item == searchItem then
if loaded = false then
texture = getTexture(item)
loaded = true
end
drawTexture(texture)
end
end
end
end
The difference would be:
- Currently we check each tile once, but load each texture multiple times.
- The way it seems the video does it, is it loads each texture once, but loops through the tiles multiple times.
Does loading a texture really cost that much GPU? Would it be a large FPS boost to load a texture once, then draw it multiple times? Even if we have to loop through every tile multiple times?
I have no idea, I might actually test it out myself. It also looks like they have a way to draw a tile BEHIND objects, or at least tell the texture to skip pixels that have other pixels on top of it. (It draws trees first, then the ground under it afterwards, in some instances)