• How does one scale a material to fit the entire space ?
    0 replies, posted
Hey, I need your help guys, i can't figure out how to re-size properly my HtmlMaterial so it fits the entire textured rect... I really don't understand how should I do, my code is only working fine with 1920 * 1080... Here is the draw method : function ENT:Draw()   if self.Panel && self.Panel:GetHTMLMaterial() then     local htmlMat = self.Panel:GetHTMLMaterial()     local scaleX, scaleY = ScrW()/htmlMat:Width(),ScrH()/htmlMat:Height()     local matData = {       ["$basetexture"] = htmlMat:GetName(),       ["$basetexturetransform"] = "center 0 0 scale " .. scaleX .. " " .. scaleY .. " rotate 0 translate 0 0",       ["$model"] = 1     }     local uid = string.Replace(htmlMat:GetName(), "__vgui_texture_", "")     self.Mat = CreateMaterial("WebMaterial_" .. uid, "UnlitGeneric", matData)   end   self:DrawModel()   local DrawPos = self:LocalToWorld(Vector(1, -111, 58))   local DrawAngles = self:GetAngles()   DrawAngles:RotateAroundAxis(self:GetAngles():Forward(), 90)   DrawAngles:RotateAroundAxis(self:GetAngles():Up(), 90)   if self.Mat then     cam.Start3D2D(DrawPos, DrawAngles, 0.4)         surface.SetDrawColor(255,255,255, 255)         surface.SetMaterial(self.Mat)         surface.DrawTexturedRect(0, 0, 554, 290)     cam.End3D2D()   else     cam.Start3D2D(DrawPos, DrawAngles, 0.4)         surface.SetDrawColor(0, 0, 0, 255)         surface.DrawRect(0, 0, 554, 290)     cam.End3D2D()   end end I don't understand at all how am i supposed to re-size it properly, i tough drawTexturedRect would make my material fill the whole rect but i was wrong... Can someone give me some tips ? Merry xmas...
Sorry, you need to Log In to post a reply to this thread.