Why am I getting a render glitch using render.DrawSprite?

Fix to the problem: The VMT was set to ‘LightmappedGeneric’, when it should have been ‘UnlitGeneric’.

I am getting an odd rendering glitch whenever I try to use render.DrawSprite; the sprites rendered by sent_ball.lua are showing up just fine, but the sprite I am trying to render using sent_marker.lua show up like this:

The lower ball renders perfectly, the upper arrow has a weird black clipping issue. It should look like the quest arrow from Skyrim (I am using this only as a placeholder, won’t release or host anything while the placeholders are in).

The VTF and VMTs are, as far as I can tell, identically set up compared to Garry’s sent_ball.vmt and sent_ball.vtf, so I can’t quite find where I’ve gone wrong. For those who may be able to help, to create the texture, I grabbed the picture of the Skyrim arrow and surrounded it in full black on the RBG layer. Then I created an Alpha layer and made it so that only the arrow part showed. The alpha is working properly in this picture, but it’s as though there’s a black plane clipping through the sprite when it’s rendered. In the VMT, I have $vertexcolor 1 and $vertexalpha 1, and in the VTF, Clamp S, Clamp T, Anisotropic, SRGB, and Eight Bit Alpha are turned on.

Here is the code that is rendering the sprite; I’ve found that including or omitting the cam.Start3D and cam.End3D makes zero difference.

EDIT: Code


AddCSLuaFile( "sent_marker.lua" )

DEFINE_BASECLASS( "base_anim" )

ENT.PrintName   = "Marker Test"
ENT.Author      = "Gerhard"
ENT.Information = "Testing!"
ENT.Category    = "Fun + Games"

ENT.Spawnable   = true
ENT.AdminSpawnable = true
ENT.RenderGroup     = RENDERGROUP_TRANSLUCENT

function ENT:SpawnFunction( ply, tr )
    if (!tr.Hit) then return end
    local SpawnPos = tr.HitPos + tr.HitNormal * 16
    local ent = ents.Create("sent_marker")
        ent:SetPos( SpawnPos )
    ent:Spawn()
    ent:Activate()
    
    return ent
    
end

function ENT:Initialize()
    if( SERVER ) then
        self:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
	end
end

if ( CLIENT ) then
    local matMarker = Material("sprites/marker")
    
    function ENT:Draw()
    
        local targets = ents.FindByClass("sent_ball")
		
        for k,v in pairs(targets) do
		
        local pos = v:GetPos()
		local col = Color(255,255,255,255)
		cam.Start3D(EyePos(),EyeAngles())
			render.SetMaterial(matMarker)
			render.DrawSprite(pos+Vector(0,0,32),32,32,col)
		cam.End3D()
		
        end
    end
end

Post the code.

My god, I can’t believe I actually pulled off that big of a stupid move and forgot to paste the code. It’s in the OP now as well as this post.


AddCSLuaFile( "sent_marker.lua" )

DEFINE_BASECLASS( "base_anim" )

ENT.PrintName   = "Marker Test"
ENT.Author      = "Gerhard"
ENT.Information = "Testing!"
ENT.Category    = "Fun + Games"

ENT.Spawnable   = true
ENT.AdminSpawnable = true
ENT.RenderGroup     = RENDERGROUP_TRANSLUCENT

function ENT:SpawnFunction( ply, tr )
    if (!tr.Hit) then return end
    local SpawnPos = tr.HitPos + tr.HitNormal * 16
    local ent = ents.Create("sent_marker")
        ent:SetPos( SpawnPos )
    ent:Spawn()
    ent:Activate()
    
    return ent
    
end

function ENT:Initialize()
    if( SERVER ) then
        self:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
	end
end

if ( CLIENT ) then
    local matMarker = Material("sprites/marker")
    
    function ENT:Draw()
    
        local targets = ents.FindByClass("sent_ball")
		
        for k,v in pairs(targets) do
		
        local pos = v:GetPos()
		local col = Color(255,255,255,255)
		cam.Start3D(EyePos(),EyeAngles())
			render.SetMaterial(matMarker)
			render.DrawSprite(pos+Vector(0,0,32),32,32,col)
		cam.End3D()
		
        end
    end
end

Looks like some render override is active, gonna try around myself.

Any results?

What shader are you using in your vmt?

I figured it out. The file was set to ‘LightmappedGeneric’, it should be ‘UnlitGeneric’.

Thought so.