-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML materials are not rendered on a transparent white background #5595
Comments
Have you tried testing |
no I only used the main branch, so I should give the 64bit beta a try? |
Yeah |
Hm, I tried the 64 bit version of GMod and then TTT2 and all its addons are so broken nothing works at all. So I can't test it I guess |
I just verified that the same TTT2 branch ist working perfectly fine in the normal GMod version. I tested |
It is generally helpful to post errors that you are getting, but I will try running your gamemode myself. |
These aren't helpful, they are all TTT2 related, most of them are because something is |
Further investigation shows that our gamemode is indeed working in the 64 bit branch, but my svg branch does not work. I will try to get to the bottom of the issue and report back |
I guess this has something to do with the chromium update? But it seems like it is an issue in GMod itself. local function GenerateHTMLElement(width, height, padding, strSVG)
-- make sure svg file has opening and closing tag
local open = stringFind(strSVG, "<svg%s(.-)>")
local _, close = stringFind(strSVG, "</svg>%s*$")
if not open or not close then return end
strSVG = stringSub(strSVG, open, close)
-- todo make sure that the svg size in combination witht the padding works here
strSVG = SetIfEmpty(strSVG, "width='(.-)'", 5, "width='' ")
strSVG = SetIfEmpty(strSVG, "height='(.-)'", 5, "height='' ")
strSVG = stringGSub(strSVG, "width='(.-)'", "width='" .. width - 2 * padding .. "'")
strSVG = stringGSub(strSVG, "height='(.-)'", "height='" .. height - 2 * padding .. "'")
local htmlElement = vgui.Create("DHTML")
htmlElement:SetVisible(false)
htmlElement:SetSize(width, height)
htmlElement:SetHTML(stringFormat(svgTemplate, padding, strSVG))
return htmlElement
end
local function GenerateHTMLMaterial(width, height, padding, strSVG)
width = math.floor(width)
height = math.floor(height)
local htmlElement = GenerateHTMLElement(width, height, padding, strSVG)
if not htmlElement then return end
-- the HTML element texture has to be updated once to generate a material
htmlElement:UpdateHTMLTexture()
-- then the material can be extracted from the HTML element
local materialInternal = htmlElement:GetHTMLMaterial()
local material = SetupMaterial(materialInternal:GetName(), width, height)
--htmlElement:Remove()
return material
end This works in the GMod main release. In the 64 brach it throws the following error:
This means that |
Could it be that you are trying to run |
I can give it a try, thanks. Maybe this is the cause, but I want to note that my implementation does work on the main release |
When adding SVG support to generate dynamic materials in GMod I ran into an issue with html materials. While it is working to generate materials with mipmapping, html elements render these on a transparent black background.
Here's some theory on the issue: https://www.adriancourreges.com/blog/2017/05/09/beware-of-transparent-pixels/
This is how my code is basically working:
DHTML
with visibility set tofalse
where I render a svg and update the HTML element::UpdateHTMLTexture()
GetHTMLMaterial
and store the result in a tableThe result can be seen here:
As you can see the svg has a hint of a black outline. This is most likely due to the background being
rgba(0,0,0,0)
which sounds fine on first though, but actaully should bergba(255,255,255,0)
Current state of the svg renderer: https://github.com/TTT-2/TTT2/blob/541390f14a9e4cd5068971a71d101f74a8def1e2/lua/ttt2/libraries/svg.lua
The text was updated successfully, but these errors were encountered: