3D2D with RenderScreenspaceEffects - Can it be done?

So I’ve heard you can use RenderScreenspaceEffects to draw 3D2D, but I’ve tried and tried to no avail.

Maybe I’m doing something wrong?

Here’s a simple test script I wrote up to test if it works at all, and I can’t get it to work.

[lua]function TestDraw()
if not Checkers then Checkers = surface.GetTextureID(“a_nil_texture”) end

local pos = Vector(0,0,0)
cam.Start3D2D(pos,Angle(0,0,90),0.4)
	surface.SetTexture(Checkers)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(0,0,128,128)
cam.End3D2D()	

cam.Start3D2D(pos,Angle(0,0,270),0.4)
	surface.SetTexture(Checkers)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(0,0,128,128)
cam.End3D2D()

end
hook.Add(“RenderScreenspaceEffects”,“TestDraw”,TestDraw)[/lua]

Most of it is copy-pasted from an entity I made for another gamemode of mine, which works just fine, so I’m almost positive its not something to do with the Start3D2D/End3D2D lines.

Any insight would be appreciated as to how to do this outside the usage of an entity’s Draw() function, since my ultimate goal of doing this is to draw sprites without having to use an entity.

Hey, I just did something like this about an hour ago…

[lua]local function RenderScreenspaceEffects()

for k,v in pairs(ents.FindByClass( "npc_turret_floor" )) do
	if v:GetModel() == "models/props/turret_01.mdl" then
		cam.Start3D(EyePos(), EyeAngles())

			local attach = v:GetAttachment(v:LookupAttachment("eyes"))
			local attachlight = v:GetAttachment(v:LookupAttachment("light"))

			local tr = {}
			tr.start = attachlight.Pos + attach.Ang:Forward() * -10
			tr.endpos = attach.Pos + ( attach.Ang:Forward() * 999999 )
			tr.filter = v
			tr.mask = MASK_SHOT
			local trace = util.TraceLine( tr )

			local TexOffset = CurTime( ) * 3
			local Distance = trace.HitPos:Distance( attachlight.Pos )

			--v:SetRenderBoundsWS( trace.HitPos, attachlight.Pos, Vector()*8 )

			render.SetMaterial(Material("trails/laser"))
			render.DrawBeam(attachlight.Pos, trace.HitPos, 16, TexOffset, TexOffset + Distance / 8, Color(255, 0, 0, 255))

			local Size = 8+(math.random()*25)
			render.SetMaterial(Material("Sprites/light_glow02_add"))
			render.DrawQuadEasy(trace.HitPos, (EyePos() - trace.HitPos):GetNormal(), Size, Size, Color(255,0,0,255), 0)
			
		cam.End3D()
	end
end

end
hook.Add(“RenderScreenspaceEffects”,“PortalTurret.RenderScreenspaceEffects”,RenderScreenspaceEffects)[/lua]

It produces this effect…

I don’t know, maybe it will help you.

Hmm.

So you use EyePos() and EyeAngles(), and draw quads rather than rects.

I might try that.

[editline]04:19AM[/editline]

Well fuck me sideways with a barbed rake. It works.

Thanks blackops.