New Voxel API to work with Shorelines

will this allow developers to emulate global illumination in some way? i am asking bcuz i doubt roblox will add their own gi.

1 Like

As someone who has been working on shorelines a few months ago and had issues and the shoreline just bothered me so much. These fixes look very nice!

1 Like

Hi just a side request. Can you stop asking me to upgrade shorelines on games that don’t have any terrain or shorelines, thank you :smiley:

4 Likes

Looks like a cool update! Love to see updates for developers.

Using these channel functions is much nicer than the old functions since you can specify only what you want. Hopefully a channel could be added for custom terrain materials so we can have as many different terrain types as we’d like rather than being limited to editing the set amount provided for us as of now.

I’ve been working on a Terrain module that generates shapes such a spheroid, torus, cone, etc, alongside the default ones. As well as copying, cutting, pasting and storing chunks of terrain data. I’m also currently implementing chunk generation, however it’s not finished so I won’t share it here. But here’s some useful utility functions:

local function Create3DArray(size: Vector3, value: any): Array3
	local array: Array3 = {}
	
	for xIndex = 1, size.X do
		array[xIndex] = {}
		
		for yIndex = 1, size.Y do
			array[xIndex][yIndex] = table.create(size.Z, value)
		end
	end
	
	return array
end
local function GenerateRegion3(position: Vector3, size: Vector3, resolution: number?): Region3
	local offset = (size * 0.5)
	
	return Region3.new((position - offset), (position + offset)):ExpandToGrid(resolution or 4)
end
local function ExpandVector3ToGrid(vector3: Vector3, resolution: number?): Vector3
	local factor = (resolution or 4)
	
	return ((vector3 / factor):Floor() * factor)
end
local VoxelReadAndWriteLimit = (2 ^ 22)
local VoxelGenerationLimit = (2 ^ 26)

local function IsRegionTooBig(region: Region3, mode: ("ReadWrite" | "Generate"), resolution: number?): boolean
	local size = (region.Size / (resolution or 4))
	local voxels = (size.X * size.Y * size.Z)
	
	local check = if (mode == "ReadWrite") then VoxelReadAndWriteLimit else VoxelGenerationLimit
	
	return (voxels > check)
end

By new types, do you mean they’re defined by default, or do we have to define them ourselves and you’re just providing the types for us to use in this post?

image

Also, the code example provided is using the old channel names:

Great update, and can’t wait to see what’s next for Terrain! :smile:

4 Likes

It already exists… And has existed for over a year now…

1 Like

They were mainly talking about how you could only override Grass for terrain thus allowing for only one material. What if you wanted 3 different kinds of grass for different areas? You can’t really do that effectively w/ the current system since you would be overriding more than just the grass material to get the desired effect. One use case would be for an open world map with different biomes. Think minecraft and how each biome has different grass. Of course, if you have a segmented map, you could mask the swapping of materials out with a loading screen and manually set the overrides via script but, it would be far more effective to just allow us to paint the terrain in multiple materials.

2 Likes

Support for Material Variants on Terrain is something we’re currently investigating and we have improving water flow direction on our radar. However, we are not ready to share more details about these at this time.

5 Likes

It will become available in the future and will allow you to set the resolution of the voxels you are writing to. We have more work to do on our terrain architecture before being able to make resolution flexible but it’s in the making!

3 Likes

We build many of Studio’s tools with our public APIs. Releasing this API allowed us to improve the Terrain Editor tools and make them write Water directly to the LiquidOccupancy channel. This allows our brushes more precise editing of water and solid materials as they can directly write in the corresponding channels.

3 Likes

We are in the process of rebuilding our terrain system architecture to improve significantly performance and memory costs. More announcements to come! :slight_smile:

8 Likes

Is there any particular reason why you don’t just upgrade them? Because that would stop asking you then.

If they have no terrain this should be a very quick and non-destructive operation. It will only mean that if you do add some terrain later, it will use proper shorelines. And all placefiles will have to be upgraded at some point in the future anyway, as the old buggy method will be deprecated and later removed.

4 Likes

Thank you for flagging!! :pray: I updated the post with the corrections.

The new types are provided as part of this API release (defined by default). You don’t have to redefine them.

2 Likes

I appreciate your reply Jakey, and I completely understand that it will impact performance - but that should be my decision to make, not Roblox’s.

It is almost certainly the case that the engineers at Roblox decided that 4x4x4 was the best trade-off for resolution & performance, and while 4x4x4 should be the default for sure, it isn’t ideal for all experiences.

Additionally, the ability to change voxel size would help with performance on games that don’t require that much voxel resolution (they would be able to make them larger that 4x4x4).

I just think it should be a variable we could control. What would be really cool is if voxel density changed depending on complexity of terrain (like Dynamic Topology in blender) - although I admit that I don’t know if this would be doable or not.

3 Likes

We use lots of types in the plugins we ship! Our C++ APIs don’t do the best job of telling you what an input table actually contains, so I figured including a Luau type would help make the intent a bit clearer!

Before the shorelines update, each voxel had both a material and an occupancy. Water voxels were defined as having the material Enum.Material.Water with the associated occupancy. This has now changed, and as we have added a third value to voxels, that being liquid occupancy (alongside specifying the other channels as referring to solid matter). A voxel can be filled with both a solid material (like grass or sand) and an amount of water. The original Read and WriteVoxels APIs were really only meant to account for those solid channels, and this new API gives you better control over this new liquid channel.

5 Likes

I think proper fluid animation whether that be actual water bodies or something like droplets from faucets would change roblox’s “outdoor experience” in general.

It’s one thing with the entire terrain system which has bugged many developers as water just looks flat and lifeless, the few properties you can customize water with aren’t actually useful either.

1 Like

Yes exactly I wouldn’t have any specific reason. In fact I do upgrade them. But I open archive files of different maps, place, etc. all the time, and I get the pop-up all the time. It’s just a small obtrusive thing to the workflow. It’s completely irrelevant to me and won’t be relevant to me so it’s just bothersome that I have to see and check it in the first place

3 Likes

This is Nice and All the things in the comments section that people are suggesting are things Id like to see such as custom material variants and such. but would it be possible to ever see a Update with the clouds setting with more customizability with things like different cloud shapes being possible and or possibly rain/snow or other kinds of storms? this might be alot to ask considering its roblox but I would love to see this for more pretty looking games in the future. And might Better Character modeling be more custom in the future? would love to see something like create human for roblox characters so we wouldn’t have to use blender to design our own unique player models.

3 Likes

Please add a quick way to scale all available terrain. Would be really nice if you can scale a 10kx10k terrain.

1 Like