How to fix overlapping floor textures in procedural room generation

I removed the ceiling part so you can see how the hallway is supposed to look like.

Can the whole map share a ceiling and floor? so that there are no texture errors.

Some rooms vary in in height and some of them will have staircases going down or up so no can do.

hmmm… Maybe you could have a code that’s like, if overlapping parts then replace them both with a part that’s the size of both parts combined?

Wouldn’t that just cause more overlapping?

How so? It would be line unioning the parts as one except without the unioning. The two parts are replaced with one part that has one texture. if this part happens to overlap with another part then both are replaced with a part that’s the size of both of them combined. This would then make large parts of any generated map share the same ceiling without interfering with taller rooms (since their ceilings are too high to overlap.)

Wouldn’t that mean the big floor/ceiling part could clip into rooms that have lower floors/higher ceilings. For example, a room with a hole in the middle or a room with a tall ceiling.

Since its procedural if you can count how many floors have been made and multiply that by a miniscule number (.01) and then subtract the size in z by that multiplied value, it should fix all of the z fighting going on.

for example:

local GeneratedRoom = m.NewRoom()
local FloorCount = 0

for i,v in pairs(GeneratedRoom) do
   if CheckIfFloor() then FloorCount += 1 end
   v.Part.Size = Vector3.new(1, 1,1-(FloorCount*.01))
end

FloorCount = 0

no matter the position or size of it, the part should hopefully not have any z fighting if they are on the same y position.
if you want to do more with this you could have it count how many floors and walls there is in total and subtract from x y and z.
for example:

local GeneratedRoom = m.NewRoom()
local itemCount = 0

for i,v in pairs(GeneratedRoom) do
   itemCount += 1
   v.Part.Size = Vector3.new(1-(itemCount*.01), 1-(itemCount*.01),1-(itemCount*.01))
end

itemCount = 0

however with large rooms with many parts or floors the effects would get bigger and bigger until it becomes notifiable.

this is purely a hypothetical and i dont know how your script is made and if this would be a option on how to do it, and in all honestly i think i completely misunderstood your question but its to late to unwrite all this now.

Could you explain how subtracting the floor’s Z value fixes this issue? I don’t see how this would do anything. Only the script-generated floor and ceiling parts are causing this issue as shown from the images above so why is there a need to change all floor’s Z value?

if the textures are overlapping then changing the vector3 size of z/x/y (which ever is relevant) value tells the renderer which part will be over the other, for example here is a overlapping texture i made very fast:

Well you’re gonna have to compromise somewhere.
Best solution I can come up with is, make the floor one part, but for holes/stare cases, use code to negate a hole in the floor at that location. Then you have a not-too-complex union with very few parts.

If the player exceeds the bounds, generate a new part to be the floor at that zone, and make the unions for it.

Whenever a new floor part is needed, i suggest making every room which will be on it at once. This is because the texture on the part may visibly change offset whenever a new union operation is made on it, so generating a whole zone at once means any holes will have been generated, so you will likely not see the texture change.

This may even be more performant than having lots of small floors as the union is quite simple and will likely have very few holes.

I’m unsure how to handle the roofs but i believe they can be done in a similar light, using a part for the main roof and making holes at places where there will be a higher roof. A bit complex, but not impossible, and probably still more simple and performant than lots of separate roofs.

Observe this toxic planet’s acid puddles:

The acid part is one part, but observe:

Procedural caves, where a cylinder of similar radius to the cave radius is used to negate the acid puddle, allowing for a cave entrance.

I wouldn’t be surprised if there’s still some sorta trade-off, but as I said, you’ll probably have to compromise somewhere, and it’s better than overlapping textures, probably.

I finally found a way to do it, I just had to use Roblox’s material manager to make my textures (which got rid of the textures changing colour) and offsetted them by 0.001.
Thanks to everyone that gave me suggestions!

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