FAForever / fa

Lua code for FAF
221 stars 229 forks source link

LOD cutoff for percy too small #2075

Closed CookieNoob closed 6 years ago

CookieNoob commented 7 years ago

the point where the high quality model is swiched to the low quality one is on a too low zoom level, so that the actual model is really visible (and not hidden by strategic symbols). Since the low quality model doesnt turn its gun and the barrel points always forward, it looks really silly when its in combat.

grafik

one zoom level closer: grafik

after increasing the LOD cutoff values and the icon fade in level (to see the model better) it seems the model itself is turning, but the weapon isnt. (all of these percies are looking downwards, the barrel is shown towards the top though) grafik

from a bit closer: grafik

Uveso commented 7 years ago

Since the new version of Black Ops unleashed is out (almost a year) , i am testing a new automatic lod calculation function.

Units are only displayed as long as they are not fully covered from the strategig icon. It also removes the low level detail from all units and only use the highres models and textures.

Maybe this will come to the maingame. This is the function that BO is using at the moment:

function CalculateNewLod(uBP)
    -- we only check if we have SelectionSizeX + Z
    if not uBP.SelectionSizeX or not uBP.SelectionSizeZ then return end
    -- if we don't have LOD settings, return
    if table.getn(uBP.Display.Mesh.LODs) <= 0 then return end
    -- copy categories into local variable for faster access
    local Categories = {}
    for _, cat in uBP.Categories do
        Categories[cat] = true
    end
    -- If we use only higrestextures we move LODCutoff from LOD-2 to LOD-1 and delete the 2nd LOD entry
    -- do we have LODCutoff in 2nd LOD array ? 
    if uBP.Display.Mesh.LODs[2].LODCutoff then
        -- copy LODCutoff from lowres to highres LOD
        uBP.Display.Mesh.LODs[1].LODCutoff = uBP.Display.Mesh.LODs[2].LODCutoff
    end
    -- delete the 2nd LOD entry
    uBP.Display.Mesh.LODs[2] = nil
    -- calculate unit/building surface by SelectionSize or HitBoxSize, whatever is bigger
    local SelectionSize = uBP.SelectionSizeX * uBP.SelectionSizeZ
    local HitBoxSize = uBP.SizeX / 1.4  * uBP.SizeZ / 1.4
    local UnitLodSize
    if SelectionSize > HitBoxSize then
        UnitLodSize = SelectionSize
    else
        UnitLodSize = HitBoxSize
    end
    -- make Experimental bigger, if it's not already as big as an factory. So we see experimentals a bit longer if zoomed out
    if (Categories.EXPERIMENTAL or uBP.StrategicIconName == 'icon_experimental_generic') and UnitLodSize < 5.5 then
        UnitLodSize = UnitLodSize * 1.8
    end
    -- mq use 125 as offset, so we start hiding units after strategic icons are shown.
    local mq = math.floor(UnitLodSize *35)+125 -- to compare: UnitLodSize from LandFactory x*y = 10,56.
    -- dont hide units until we display the strategic icon
    if mq < 130 then
        mq = 130
    end
    -- stop displaying land units at LOD 600 (LANDFactory has ~ 500)
    if mq > 600 and not Categories.AIR and not Categories.EXPERIMENTAL then
        mq = 600
    end
    -- stop displaying air units a little bit later then land units
    if mq > 700 and Categories.AIR and not Categories.EXPERIMENTAL then
        mq = 700
    end
    -- stop displaying all units over LOD 1000. (almost zoomed out max)
    if mq > 1000 then
        mq = 1000
    end
    -- Set the new LODCutoff inside blueprint LOD-1 or LOD-2
    uBP.Display.Mesh.LODs[1].LODCutoff = mq
    -- display strategic icons from LOD 130 on, so they will hide smaller units. Except special units.
    if uBP.Display.Mesh.IconFadeInZoom and uBP.Display.Mesh.IconFadeInZoom < 1000 then
        uBP.Display.Mesh.IconFadeInZoom = 130
    end
end
speed2CZ commented 7 years ago

This looks like a problem with the low detail model rather than wrong lod value

CookieNoob commented 7 years ago

The problem is indeed the lod1 model of the percy. The bones are defined differently compared to the lod0 model. grafik

however, showing the low poly model only for larger distances (where the unit is hidden behind the strategic symbol) should be ok (didnt work when I tested it though)

Uveso commented 6 years ago

There is no need to show a model, if it's covered by the strategic icon. You can't see it anyway.

Or in this special case, we can simply increase the lod1 to the point, where the strategic icon will be displayed. So we have a highresolution model until its covered by the icon.

supcomBlackMaster commented 6 years ago

Hello guys, i have checked the 3d model and the bone itself. Both have a Bone called "Turret" which allow the turret to turn without the lower boddy. So basicly its not a problem of the Mesh or Bone itself.

I have recognised another issue while doing so. The "XEL0305_lod1.scm" (low-res) mesh has his pivot point in the center of the body. In comparision with "XEL0305_lod0.scm" (high-res) which has his pivot point at the bottom of the mesh. This could be also an issue later on. But since i dont know how the engine operates with the pivot point of the mesh I cannot say if this is an issue or not.

Here is a screenshoot of the 2 meshes aligned next to each other as you can see the pivot point of the model difference in the Z-Axis:

unbenannt

supcomBlackMaster commented 6 years ago

I have fixed the issue, the gun just simply had no animation. I have moved a bone and renamed it to "Turret_Barrel". It was named mesh_01 or so. Looked like a default bone-name to me.