Skip to content

Commit

Permalink
small material fixes
Browse files Browse the repository at this point in the history
unlit hack option for submaterial. because unlit materials from pac weren't being correctly used. works by forcing pac.Material lookup to replace the default fallback "Fix" material created by the submaterial.

reapply the hide flag on material part on initialize. because the fact that hiding the part should prevent auto-applying the material on its parent wasn't being obeyed at weartime
  • Loading branch information
pingu7867 committed Jan 17, 2025
1 parent ba7dc80 commit ba54007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/pac3/core/client/parts/material.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ for shader_name, groups in pairs(shader_params.shaders) do
self.rotation_angle = Angle(0, 0, 0)
timer.Simple(0, function()
self:SetbasetexturetransformAngle(self:GetbasetexturetransformAngle())
self:SetHide(self:GetHide())
end)
end

Expand Down
7 changes: 7 additions & 0 deletions lua/pac3/core/client/parts/submaterial.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BUILDER:StartStorableVars()
return tbl
end,
})
BUILDER:GetSet("UnlitMaterialHack", false, {description = "hacky fix if the material comes from a material part with unlitgeneric shader.\nBut it will break raw url textures!"})
BUILDER:GetSet("RootOwner", false, { hide_in_editor = true })
BUILDER:EndStorableVars()

Expand Down Expand Up @@ -63,6 +64,7 @@ function PART:UpdateSubMaterialId(id, material)
ent.pac_submaterials = ent.pac_submaterials or {}

local mat = self.Materialm
if self.UnlitMaterialHack then mat = pac.Material(self.Material, self) end

if not material then
if self.Material and self.Material ~= "" and mat and not mat:IsError() then
Expand All @@ -79,6 +81,11 @@ function PART:UpdateSubMaterialId(id, material)
end
end

function PART:SetUnlitMaterialHack(b)
self.UnlitMaterialHack = b
self:UpdateSubMaterialId()
end

function PART:PostApplyFixes()
self:UpdateSubMaterialId()
end
Expand Down

0 comments on commit ba54007

Please sign in to comment.