#code thread
1 messages · Page 1 of 1 (latest)
local rt = GetRenderTarget("rt", w, h)
local mat = CreateMaterial("mat", "VertexLitGeneric", {
["$basetexture"] = rt:GetName(),
["$vertexcolor"] = "1",
["$translucent"] = "1",
})
render.PushRenderTarget(rt, 0, 0, w, h)
cam.Start2D()
render.Clear(0, 0, 0, 0, true, true)
draw.SimpleText("text", "fnt", w/2, h/2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
cam.End2D()
render.PopRenderTarget()
ENT.Material = mat
-- snipped some ent code
function ENT:GetRenderMesh()
local mx = Matrix()
mx:Rotate(Angle(0, 0, -90))
return {Mesh = self.Mesh, Material = self.Material, Matrix = mx}
end
function ENT:CreateMesh()
self.Mesh = Mesh(self.Material)
local scale = self.Mins:Distance(self.Maxs)
-- reference points
local points = {
{pos = Vector(-scale/2, -scale/2, 0), u = 0, v = 1}, -- top left
{pos = Vector(-scale/2, scale/2, 0), u = 0, v = 0}, -- top right
{pos = Vector(scale/2, scale/2, 0), u = 1, v = 0}, -- bottom right
{pos = Vector(scale/2, -scale/2, 0), u = 1, v = 1}, -- bottom left
}
local tris = {
points[1], points[2], points[3],
points[3], points[4], points[1],
}
for k, v in ipairs(points) do
debugoverlay.Text(self:LocalToWorld(v.pos), k, 0, false)
end
self.Mesh:BuildFromTriangles(tris)
end
function ENT:Draw()
self:CreateMesh() -- debug
self:DrawModel()
end
Because that's how vertexlit works, by shading vertices
To fix that, you should increase it resolution by a lot (10 subdivs would be good enough) and then it will utilize a smooth light
Also for vertex lit, you need to provide tangent and normals to your mesh which always will be the direction of your panel and the direction it aims to