I’m attempting to make a game where the world is made of blocks, and I made them all invisible (Transparency=1) and render them through decals instead, in order to optimize resources. So far, the script that deals with checking which decals have to be opaque is working, but since the blocks are transparent, the camera can go through them, which i obviously don’t want to happen.
I’ve seen this issue posted from 2019 which would solve my problem, except that the function it replaces canOcclude with
local function canOcclude(part)
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
if FFlagUserPoppercamLooseOpacityThreshold then
return
part.Transparency < 1 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part) and
not part:IsA('TrussPart')
else
return
part.Transparency < 1 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part)
end
end
mentions a variable FFlagUserPoppercamLooseOpacityThreshold which is not recognized.
The script provided is more a CoreGui related snippet. There is no definitive way to prevent the camera from passing through transparent parts. Except for casting a ray yourself from in front the cameras position to it’s back and editing the MaxCameraZoomDistance property of the Player Instance.
To fix this, you need copy roblox built-in camera scripts, and change it’s behavior to not ignore parts with transparency > 0.5. Other ways of doing this is bad, cuz they use additional resources, instead of fixing core issue.
Also, with transparent parts, occlusion culling won’t work, so I really reccomend you to make them fully opaque.
im going to try editing the core script, but about the opaque parts, wouldn’t that make the game render wayyyy more polygons and therefore take a hit on resources?
edit: nevermind i just googled what occlusion culling is, i’m just going to discard this approach altogether and make the blocks fully opaque instead. Thanks for your input
Do you think that using decals will solve that? No, it not works like that:
If part is transparent, then it’s ignored for rendering.
If decal is applied, it uses diffirent roblox copy of instance just for it to render
So, if you want to optimize your game, try using greedy meshing. (which can union alot of blocks into one)
Hi, I’m looking into greedy meshing and it doesn’t seem suitable to my game because the blocky map can be interacted with, and, say, a player breaks a block, then i’d have to run the whole algorythm again, wouldn’t i? I know a thing or two about coding but this is kind of complex so if you could walk me through a bit more of this i’d appreciate it so much