Changes to LocalTransparencyModifier in the core camera scripts causing low framerate and increased GPU usage

For some reason, in the particular game I am developing in, the following code within the Invisicam module causes a large drop in framerate and increase in GPU usage:

for hitPart, originalLTM in pairs(self.savedHits) do
	if currentHits[hitPart] then
		-- LocalTransparencyModifier gets whatever value is required to print the part's total transparency to equal perPartTransparency			
		hitPart.LocalTransparencyModifier = (hitPart.Transparency < 1) and ((partTargetTransparency[hitPart] - hitPart.Transparency) / (1.0 - hitPart.Transparency)) or 0
	else -- Restore original pre-invisicam value of LTM
		hitPart.LocalTransparencyModifier = originalLTM
		self.savedHits[hitPart] = nil
	end
end

The part where it actually causes the issue is the fourth line in the code above, where it sets the hitPart’s LocalTransparencyModifier using an inline conditional statement. Note that it still occurs if I set the LocalTransparency value to a constant value, such as 0.5, instead of using the conditional statement. The resetting of LocalTransparencyModifier on the sixth line doesn’t cause any issues for some reason.

It occurs on both my PC and the PCs of the two others working on the project with me.

Given the increase in GPU, not CPU usage, I would assume that this is an internal issue, however I am unsure what about the place I am working in is causing it to happen, and have failed at reproducing the bug in another place, so I cannot give a proper reproduction step.

Here’s a place file:
LocalTransparencyModifier.rbxl (2.9 MB)
To see the issue just run play solo and walk backwards into the castle wall so the camera is colliding with it. The script is in StarterPlayerScripts.

4 Likes

Seems about right – there’s a Humanoid right under workspace. You will probably want to remove that, your entirely place is basically a 21k part humanoid rig right now and that’s what is probably causing the performance drop.

image

6 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.