Funky render.DrawSprite issue

– This was posted in H&S as well but didn’t get much traction there. Thought I’d try here.

So I’m not really sure where to start with this problem.

The problem appears in sandbox using the gmod_light ent as well

I attach the sprite (or ent) to a car and drive it around. The sprite will become invisible or blocked by the vehicle at random places.

(yes i am drawing a fuckton of sprites right now, it is just for testing purposes, will be lowered as soon as i figure out wtf is going on)

http://puu.sh/aZhBv/a4d8d6e11d.jpg[/t]
[t]http://puu.sh/aZCti/a63804c193.jpg

Any ideas as to why this happens? Anyone can reproduce this in sandbox.

Should note, it happens with all of SGM’s crown vics, but does not happen with LW’s suburban.

I’m at a loss.

BTW - I’m using essentially the same code from the gmod_light ent in my ent to do this.

As I already said, use the code from gmod_lamp ( with the pixvis thing ), not from gmod_light.

oh shit- misread

I’ll go try that now, thanks!

No go. Almost the same behavior.

I think there is something wrong with these models as they seem to take precedent over the sprites when viewing them at certain angles in relation to the skybox.

What hook are you using to draw the sprites?

I am drawing the sprites under DrawTranslucent

[lua]
self.LED = self.LED + 1

local truePos = self:GetParent():LocalToWorld( pos )

if not self.PixVis[ self.LED ] then
self.PixVis[ self.LED ] = util.GetPixelVisibleHandle()
end

local LightNrm = self:GetAngles():Forward()
local ViewNormal = self:GetPos() - EyePos()
local Distance = ViewNormal:Length()
ViewNormal:Normalize()
local ViewDot = ViewNormal:Dot( LightNrm )
local LightPos = truePos

render.SetMaterial( matLight )
local Visibile = util.PixelVisible( LightPos, 4, self.PixVis[ self.LED ] )

if (!Visibile) or Visibile == 0 then return end

local Size = math.Clamp( Distance * Visibile * 2, 32, 256 ) * percChange

Distance = math.Clamp( Distance, 32, 800 )
local Alpha = math.Clamp( math.Clamp( ( 1000 - Distance ) * Visibile, 0, 75 ) * percChange, 0, 255 )

render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, 240), Visibile )
render.DrawSprite( LightPos, 64, 64, Color( col.r, col.g, col.b, Alpha ), Visibile )
[/lua]

Are you actually creating entities for your lights?

Yes

Well, that probably is the problem, I am doing it in the PostDrawTranslucentRenderables hook.

[editline]22nd August 2014[/editline]

What your ENT.RenderGroup is?

ENT.RenderGroup = RENDERGROUP_BOTH

[editline]21st August 2014[/editline]

Placing the render.DrawSprite section in the PostDrawTranslucentRenderables has fixed the problem!!

Thanks!