• Weird graphical glitches with textured rectangles in cam.Start3D2D
    5 replies, posted
I'm experiencing a weird issue with the following code: [lua] local backgroundTexture = Material("models/props_combine/Combine_Citadel001"); function ENT:Draw() local p = self:GetPos(); local anotherAng = self:GetAngles(); anotherAng:RotateAroundAxis(self:GetForward(), 90); anotherAng:RotateAroundAxis(self:GetUp(), -45); cam.Start3D2D(p + self:GetRight()*-2 + self:GetUp()*18 + self:GetForward()*1, anotherAng, 0.25); surface.SetMaterial(backgroundTexture); surface.SetDrawColor(Color(255,255,255)); surface.DrawTexturedRect(0, 0, 22, 52); cam.End3D2D(); end; [/lua] It's drawn as expected, however, the texture appears to get glitched by dark patterns/lines at random times. Here are few screenshots that hopefully describe my issue better: [b]Good:[/b] [img]http://i.imgur.com/ItoDdjx.png[/img] [b]Glitched:[/b] [img]http://i.imgur.com/2gWBNiB.png[/img] [img]http://i.imgur.com/aoAXyzA.png[/img] [img]http://i.imgur.com/eJYlHNn.png[/img] I've noticed the problem no longer occurs when I drop the material/texture - i.e. when I surface.DrawRect instead of surface.DrawTexturedRect. Is it a problem of the material? If so, is there something I can do to prevent this glitch from happening? [b]Edited:[/b] It's not really well visible from the pictures, might record a video of it later. It looks like some weird shadow going through the texture diagonally or staying in it's corners.
I don't see it, but, if the cam screen is directly on top of the model I've had this issue before. Move the screen further out away from the model if when you set the model's alpha to 0 it stops occurring.
The problem will be seen in the following video once YouTube finishes processing it. The code in OP is called in ENT.Draw. It's a custom SENT. Omitting self:DrawModel() doesn't solve the issue. It doesn't do any difference when I call it after instead of before the custom camera code is executed. I have intentionally changed position of one of the two cameras to ensure it's not overlapping with the drawn model in any way. [video=youtube;7Slgvn1cxV4]http://www.youtube.com/watch?v=7Slgvn1cxV4[/video]
Maybe the material's shader is causing this issue.
Yeah, you must be using UnlitGeneric for 3D2D/HUD/VGUI elements.
If you want to draw "panels" you could use the render.DrawQuad function I guess.
Sorry, you need to Log In to post a reply to this thread.