Why dui render like that?

Hi, i was trying some dui today but I have this problem that i don’t know how to fix, would anyone know how to help me?
the problem is the semi-transparent edges

1 Like

Well, you should provide us with your current code, it’d be much easier to spot the problem.

local cache = {}

function LoadScaleform(dui3dHandle, scaleform)
    local scaleformHandle = RequestScaleformMovie(scaleform) -- Request the scaleform

    -- Wait till it has loaded
    while not HasScaleformMovieLoaded(scaleformHandle) do
        scaleformHandle = RequestScaleformMovie(scaleform)

    -- Save the handle in the table
    cache[dui3dHandle].scaleform = scaleformHandle

function StartupDui(dui3dHandle, url, width, height)
    local txd = CreateRuntimeTxd('txd') -- Create texture dictionary

    cache[dui3dHandle].dui = CreateDui(url, width, height) -- Create Dui with the url

    local dui = GetDuiHandle(cache[dui3dHandle].dui) -- Getting dui handle

    CreateRuntimeTextureFromDuiHandle(txd, 'txn', dui) -- Applying the txd on the dui

    if cache[dui3dHandle].scaleform ~= nil and not cache[dui3dHandle].txd then
        PushScaleformMovieFunction(cache[dui3dHandle].scaleform, 'SET_TEXTURE')

        PushScaleformMovieMethodParameterString('txd') -- txd
        PushScaleformMovieMethodParameterString('txn') -- txn

        PushScaleformMovieFunctionParameterInt(0) -- x
        PushScaleformMovieFunctionParameterInt(0) -- y

        cache[dui3dHandle].txd = true

-- Native
function Create3dNui(sfName, url)
    local dui3dHandle = tostring(math.random(0, 9999))

    cache[dui3dHandle] = {
        dui = nil,
        txd = false,
        scaleform = nil,
        show = false,
        coords = nil,
        scale = nil

    -- Auto load the scaleform
    LoadScaleform(dui3dHandle, sfName)

    if url ~= nil then
        StartupDui(dui3dHandle, "nui://"..GetCurrentResourceName().."/"..url, 1920, 1080)

    -- Class to return
    local class3d = {}
    class3d.__index = class3d

    class3d.init = function(self, url, width, height)
        StartupDui(dui3dHandle, "nui://"..GetCurrentResourceName().."/"..url, width or 1920, height or 1080)

    class3d.show = function(self, coords, scale)
        cache[dui3dHandle].coords = coords
        cache[dui3dHandle].scale = scale or 0.1
        cache[dui3dHandle].show = true

    return dui3dHandle, setmetatable({}, class3d)

-- Main
    while true do
        local ped = PlayerPedId()
        local pos = GetEntityCoords(ped)
        for k,v in pairs(cache) do
            if v.show then
                local scaleformCoords = vector3(v.coords.x - 1, v.coords.y, v.coords.z + 2)
                local  scaleformScale = vector3(v.scale*1, v.scale*(9/16), 1)
                if v.scaleform ~= nil and HasScaleformMovieLoaded(v.scaleform) then
                    --                            handle           coords            rot      unk        scale      unk
                    DrawScaleformMovie_3dNonAdditive(v.scaleform, scaleformCoords, 0, 0, 0, 0, 0, 0, scaleformScale, 0)

-- Snippets
local dui = nil

    local _, _dui = Create3dNui("generic_texture_renderer", "html/ui.html")
    dui = _dui


so you have any idea?

No I never messed with DUI’s before sorry, I only said that so someone who actually knows about these would easily spot the issue.


1 Like

Did you find an answer to this? I’m having the same issue where the borders are a gradient. it’s really annoying…

nope :frowning_face_with_open_mouth:

news ?

no, for now

That’s weird - this should’ve been fixed as of fix(nui): correct for premultiplied alpha in DUI blit · citizenfx/[email protected] · GitHub this January.

Did you ever provide a full repro for this at all, in case it isn’t fixed? That code was a bit incomplete.

you can find a working example here: utility_lib/native.lua at main · utility-library/utility_lib · GitHub

here is the rendering part utility_lib/main.lua at main · utility-library/utility_lib · GitHub

if i rewrite the same code in js works perfectly, in lua that happens.

Use floats where designated as required by the native site. Your call to DrawScaleformMovie_3dNonAdditive is providing integers of 0 for the “unk” variables, the center variable is sharpness as far as I can tell from DrawScaleformMovie_3d, so the “unk” variables should be 0.0, 1.0, 0.0 I believe. Someone is testing this and initial tests with floats showed proper edges. They are testing the rest of their DUI now

1 Like

thank you, i tried it and it seems to work perfectly, back in the day i didn’t know that “number” in the natives means float or int, actually if i would have put my hand to it again now i probably would have also succeeded, but thank you very much for your answer and your deduction.
may i ask you kindly what is your name on github, at least i also give you credits for the answer :wink: