Decals causing immense lag

I have a script, and it generates terrain with perlin noise, however, it generates 2.5x2.5x2.5 size blocks with 6 decals and 6 textures in them, to make grass (dirt layer and grass layer overtop to allow colour change), and when you play your mouse begins to stray away, and have weird acceleration issues.

I believe this is the decals and textures causing this, as I have had players say about lag issues on slower computers. Is there any workaround with this? Could anyone supply any examples on ways to fix this? Thanks!

Place in question: https://www.roblox.com/games/3169831004/Bloxels-Place

I have reduced it a lot with fog, removing a couple prints, and increasing the delay between checks for generating terrain. I would still appreciate some help with reducing lag still.

EDIT: Thanks to @Dysche for the help. Apparently decals are much less efficient than textures, and now roblox studio is running without the mouse acceleration issues (The fps is just because it is running out of ram from the terrain I assume.) I will test in game and if it works then I will mark as solved.

EDIT 2: It seems to be working amazingly, and on minimum settings I’m hitting 40+ frames with a lot of terrain loaded. Dysche also recommended converting some smaller blocks into larger blocks with the same texture, repeating, and that should allow the game to run smoothly. Thanks!

1 Like

I came up with something rather quickly so this may or may not be the best. What you should do is generate textures on the viewable surfaces. Raycast from all lookvectors and see if it hits a part. If the part distance is farther than right next to it, you should texture that face. I would call this update every time a part changes, but make sure to check and see if it’s position changed, went nil, etc. (however you get rid of mined blocks).

EDIT: Raycasting is rather inefficient so I would recommend doing it in chunks, kind of like Minecraft does it. (since that’s the game style you’re making)

1 Like

I actually have been doing it in chunks. What I could do is raycast from the block I placed to tell other blocks to hide their faces, and hide this blocks face if so, and before destroying, I could tell the blocks around to show again. The problem with this is that you can rotate all blocks, and would make it hide the wrong faces.

Is there anything you’re updating constantly?

Nope.
(30 character limit :frowning: )

I looked at the microprofiler output and…

Shadows are clearly the problem here, not decals/textures/etc. Turn off the day/night cycle and see if that improves performance.

Would have been worth mentioning that you’re updating the time…

1 Like

Thanks, I totally forgot about time!

I disabled it, and it improves performance, but still has the acceleration issues.

I checked and shadows are still the ones slowing you down…

Do you have any idea what this might be?

Visual2DHandler moves a lot of models around. That may trigger a lot of shadow updates.

Ah yes, I forgot about viewportframes!

Also, the follwing on is quality one (no shadowmap, basically). You have a lot of transparent parts somewhere:

I don’t see a lot of transparent parts, though…

Every grass block is 2 parts. One transparent, slightly larger one with the green grass (actually gray but with a Color3 variable set), and the visible part with dirt texture.

Making it one texture as a whole would be more performance friendly.

But I can’t see these parts anywhere on the map. Where are they?

Right over the dirt. The entire floor

Actually, what you should try to do (Not sure if it efficient but might as well try) is to make mesh cubes, then have textures UV wrapped. There, you have a texture as one whole piece, making it more performance friendly since it only has to load one single texture inside of 6.

1 Like

Here.
image
The grass is over the top of the dirt to make it have the ability for different grass colours.

1 Like

How about two mesh cubes, one with the grass texture as a UV Wrap, and the other just as dirt. That way, it only has to load a total of 2 textures instead of 12.

Transparent parts with textures on top are terrible for performance. You can just layer the grass texture on top of the dirt texture by applying it afterwards.

(just saying this for anyone reading the thread; I already told you this in-game)

Microprofiler output after the transparent parts were removed.

Moral of the story: Don’t use transparent parts with textures layered on top.

7 Likes

Late reply but the input delay your experiencing is a bug with Roblox, if your mouse polling rate is above 125hz it will suffer from what your experiencing.
You can see the thread here: Significant input delay ( Camera Lag )

Edit: I read the previous replies as May 19th rather than May 2019

1 Like