#Yeah. In fact: surface.* functions
1 messages · Page 1 of 1 (latest)
Saw that from some dude, then checked surface.* cpp code via some debates with another guy, and found that:
https://github.com/lua9520/source-engine-2018-hl2_src/blob/3bf9df6b2785fa6d951086978a3e66f49427166a/hammer/Render.cpp#L845
That's just wild
I mean, I guess that makes textured rects make sense
They're not re-inventing texturing and such, they're just re-using what's already there
A non-stenciled, non-masked, non-image-cornered rounded rectangle is honestly pretty big
Especially if it's faster
Yeah. You can also batch all drawRects/drawX into mesh, if you're making some simple HUD. and then draw that IMesh
so you will only make 1 draw call, not 100 for an example
and you won't need to make render targets to cache some stuff
I'm not necessarily suggesting that you take this up as a project, but that sounds exactly like a very valuable library that could be created
Yeah, i have some plans on that
If it's within the same realm of difficulty/performance, being able to union/intersection shapes would be especially useful
Union/intersection?
Well, that's hard....
@placid basin
local rainbowRT = GetRenderTarget('rainbowRT', 256, 256)
render.PushRenderTarget(rainbowRT)
render.Clear(0, 0, 0, 0, true, true)
cam.Start2D()
local x, y = 256, 256
render.SetMaterial(Material('vgui/white'))
mesh.Begin(MATERIAL_QUADS, 1)
mesh.Color(0, 0, 0, 255)
mesh.Position(Vector(0, 0))
mesh.AdvanceVertex()
mesh.Color(255, 0, 0, 255)
mesh.Position(Vector(x, 0))
mesh.AdvanceVertex()
mesh.Color(255, 255, 0, 255)
mesh.Position(Vector(x, y))
mesh.AdvanceVertex()
mesh.Color(0, 255, 0, 255)
mesh.Position(Vector(0, y))
mesh.AdvanceVertex()
mesh.End()
cam.End2D()
render.PopRenderTarget()
here's a gradient material creation. As you see, you could use meshes for gradient creation.
But you have to use IMeshes, because they cache meshes to C, so there won't be a C -> Lua overhead, and therefore you will achieve way better performance