GridCreator - Draw grids with whatever tradeoff you prefer

Inspired by GridModule by @brokenVectors, I decided to make a module that allows you to draw with WedgeParts, Beams, or SpecialMeshes.

Shoutout to @EgoMoose and @TheGrandBraker for help with various draw math.


This terrain grid took 15 lines to create, thanks to my module doing all the heavy lifting!

My module is designed to give you control over what tradeoff you want, and handle as much as possible for you to make this super simple to use.

Utilizing proxies, it knows when you update a point and will automatically update any tris/quads that are connected to that point. This way, you don’t have to concern yourself with drawing tris/quads and it also only alters the ones that need the change instead of all of them.

By using proxies, I also prevent you from changing things you shouldn’t so that you hopefully won’t break the points. Instead, I give you a descriptive error message.


Module usage is really straightforward.

function GridCreator.new(Settings)

Settings is a table with Position, Size, Resolution, and DrawType

  • Position (Vector3)
    Where the center of the grid will be
  • Size (Vector3)
    How big the grid will be (Y value is meaningless here)
  • Resolution (number)
    How many points per side of the grid
  • DrawType (string)
    Which method for rendering the grid should be used

returns Grid


Grid Properties

-- Read Only properties

Grid.Size -- The Vector3 you passed into GridCreator.new settings
Grid.Position -- The Vector3 you passed into GridCreator.new settings
Grid.Resolution -- The number you passed into GridCreator.new settings

-- Alterable properties

Grid.Points -- 2D array of Points | eg: Grid.Points[x][y].Y = HeightValue

-- Each Point in the 2D array is a table like so
local Point = {
	X = number;
	Y = number;
	Z = number;
	Color = Color3;
}

Example:

local GridCreator = require(script.GridCreator)

local Grid = GridCreator.new({
	Position = Vector3.new(0,0,0);
	Size = Vector3.new(200,5,200);
	Resolution = 60;
	DrawType = "WedgePart";
})


for x = 1, Grid.Resolution do
	for y = 1, Grid.Resolution do
		local Height = (math.noise(x/9,y/9)+1)*20
		Grid.Points[x][y].Y = Height
		Grid.Points[x][y].Color = Color3.fromRGB(17, 50, 0):Lerp(Color3.fromRGB(65, 90, 52), Height/10)
	end
end

DrawTypes:

"WedgePart"

  • Has collisions on the grid. Makes it the by far most expensive option but if you need collisions then this is your only option.

"SpecialMesh"

  • Has no collisions, so it’s a significantly faster version of WedgePart.

"Beam"

  • Has no collisions, no lighting, and draws quads instead of tris so updates far fewer Instances.
  • Gets throttled by Roblox if you make the grid too large and will look funky.

Hopefully this module makes it easy for you to do triangle terrain, audio visualizers, fluid sim, whatever.

Note that it’s a bit more expensive than handling it all yourself, you’re paying for the convenience and simplicity of my proxy backend.




Enjoying my work? I love to create and share with the community, for free.

I make loads of free and open source scripts and modules for you all to use in your projects!
You can find a lot of them listed for you in my portfolio. Enjoy!

If you’d like to help fund my work, check out my Patreon or PayPal!

63 Likes

Wow, boatbomber blesses us with a marvelous module once again!

I’m flabbergasted with the speed of the creation–the GridModule by @brokenVectors was released under 12 hours ago. So, you made this entire module with more customization within a matter of hours? Such work seems like it’d take me weeks or months, but you completed in hours…

PS: I’ve also seen your game jam game this year, and man, I’m surprised y’all made it in less than 24 hours!

As always, I’m impressed with your work,
Keep it up!

6 Likes

It took me about 90 minutes to make this because I’d already spent a week making grid stuff for my fluid simulation project, so it was more about putting it into neat user friendly packaging. I already had the math and hard parts solved.

7 Likes

Very cool, ill definitely be experimenting with this for terrain/water n in the future

1 Like

Wow, I could not resist at the beginning, with the GerstnerWaves and tried it myself. I found a tutorial and everything went well with points. But my only problem was how to connect the dots. This definitely helps me more. Before it was just a vague idea, but because of that I will definitely do something, that’s for sure.

Thanks @boatbomber and @brokenVectors

2 Likes