[small tutorial] How I fixed an incorrectly shaded mountain (terrain + meshparts)

My issue is MeshParts sunken into terrain to add detail, ends up making the lighting incorrectly remove the sky color from being applied to the MeshParts and surrounding area UNLESS I turn off cast shadow, which still ruins their look as they now don’t self-shadow.

I saw a bug report about this shading artifact a while ago, and saw a roblox staff member reply saying it was intentional. (if this is intentional, it’s ugly and looks and feels incorrect despite it maybe technically being correct, roblox aint photorealistic so there’s no reason for them to not fix this)

Has anyone every had to deal with this? And if so I’d love to know a potential fix to allow the MeshParts to cast their shadows while also not causing that weird unshaded-ness to it.

Any help towards fixing this would be very appreciated!

1 Like

I fixed my own issue in the weirdest way possible, turns out the CollisionFidelity of the meshpart was affecting the shading???

This was what it looked like before when it was set to Hull:


This is Default:

This is Precise:

This is it set to Box:

Box somehow completely fixed my issue??
So to also fix collisions now that its rendering properly, is stupidly simple:

I store a copy of each rock at the proper collision fidelity (I have 2 copies bc I didn’t wanna make them all Precise):


Then, at runtime (or in studio) you can simply run smth like this:

local function applyHitbox(rock)
	local hitbox = hitboxes:FindFirstChild(rock.Name)
	if not hitbox then return warn(`[setupRocks] failed to find collision mesh for rock "{rock.Name}" (rock will have box collision)`) end

	hitbox = hitbox:Clone()
	hitbox.Name = "Hitbox"
	hitbox.Size = rock.Size
	hitbox.CFrame = rock.CFrame
	hitbox.Parent = rock

	rock.AudioCanCollide = false
	rock.CanCollide = false
	rock.CanTouch = false
	rock.CanQuery = false
end

for _, rock in rocks:GetDescendants() do
	if rock:IsA("MeshPart") then
		applyHitbox(rock)
	end
end

This is supposed to be in Resources > Community Tutorials.

thx genius, if you acc read the post you’d see it was an actual issue I had which I fixed and turned into a small tutorial.

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