DModelPanel changes color based on map

Hi,

Title says it all. My DModelPanel gets darker (less ambient lighting on the model, perhaps?) and this varies on different maps. I’ve tried the DModelPanel:SetAmbientLight and Panel:SetDirectionalLight, these don’t seem to have any effect.

Any ideas on why the map itself could be affecting this?

Photo (I’ve lightened this in paint.net, it’s actually even darker in-game):

What does your SetDirectionalLight and SetAmbientLight code look like? Might be not enough.
I find it odd how it changes depending on the maps, did you remember to set the draw color or draw texture before drawing the panel? Might be getting the last value that was used, not sure without code.

Ah, I just remembered that this technically isn’t a normal DModelPanel; I’ve overridden it’s Paint() function to integrate PAC3 by calling

pac.DrawEntity2D()

And I suppose that function, and the fact that I’m overriding Paint(), is causing this.
I understand that it’s getting to be a more niche issue now, so I posted about it in the PAC3 discord. Thank you for your help so far. I will update this thread with any info they give me, for future reference for those who may come across this post.

Try looking at how pointshop does it

This piece of code in particular:

function PANEL:Paint()
	if ( !IsValid( self.Entity ) ) then return end

	local x, y = self:LocalToScreen( 0, 0 )

	self:LayoutEntity( self.Entity )

	local ang = self.aLookAngle
	if ( !ang ) then
		ang = (self.vLookatPos-self.vCamPos):Angle()
	end

	local w, h = self:GetSize()
	cam.Start3D( self.vCamPos, ang, self.fFOV, x, y, w, h, 5, 4096 )
	cam.IgnoreZ( true )

	render.SuppressEngineLighting( true )
	render.SetLightingOrigin( self.Entity:GetPos() )
	render.ResetModelLighting( self.colAmbientLight.r/255, self.colAmbientLight.g/255, self.colAmbientLight.b/255 )
	render.SetColorModulation( self.colColor.r/255, self.colColor.g/255, self.colColor.b/255 )
	render.SetBlend( self.colColor.a/255 )

	for i=0, 6 do
		local col = self.DirectionalLight[ i ]
		if ( col ) then
			render.SetModelLighting( i, col.r/255, col.g/255, col.b/255 )
		end
	end

	self.Entity:DrawModel()

	self:DrawOtherModels()
	
	render.SuppressEngineLighting( false )
	cam.IgnoreZ( false )
	cam.End3D()

	self.LastPaint = RealTime()
end

Might be helpful to achieve what you’re looking for.