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
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)
Citizen.Wait(5)
end
-- Save the handle in the table
cache[dui3dHandle].scaleform = scaleformHandle
end
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
PushScaleformMovieFunctionParameterInt(width)
PushScaleformMovieFunctionParameterInt(height)
PopScaleformMovieFunctionVoid()
cache[dui3dHandle].txd = true
end
end
-- 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)
end
-- 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)
end
class3d.show = function(self, coords, scale)
cache[dui3dHandle].coords = coords
cache[dui3dHandle].scale = scale or 0.1
cache[dui3dHandle].show = true
end
return dui3dHandle, setmetatable({}, class3d)
end
-- Main
Citizen.CreateThread(function()
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)
end
end
end
Citizen.Wait(5)
end
end)
-- Snippets
local dui = nil
Citizen.CreateThread(function()
local _, _dui = Create3dNui("generic_texture_renderer", "html/ui.html")
dui = _dui
dui:show(GetEntityCoords(PlayerPedId()))
end)
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.
Did you find an answer to this? I’m having the same issue where the borders are a gradient. it’s really annoying…
nope
news ?
no, for now
That’s weird - this should’ve been fixed as of fix(nui): correct for premultiplied alpha in DUI blit · citizenfx/fivem@39f2431 · 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
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