0 votes

I am generating a mesh and applying a shader material using code only. I am able to create the plane mesh and apply the material but I cannot curve the edges of the mesh. The idea is to create an island with a flat surface with curved edges into the water.
Should this be done using a script or shader?

func _ready() -> void:

var size = _rand_int()
print('size :', size)

var surface_tool = SurfaceTool.new()
var plane_mesh = PlaneMesh.new()
var data_tool = MeshDataTool.new()

plane_mesh.size = Vector2(size, size)
plane_mesh.subdivide_depth = size * MULTIPLIER
plane_mesh.subdivide_width = size * MULTIPLIER

surface_tool.create_from(plane_mesh, 0)
var array_mesh = surface_tool.commit()
data_tool.create_from_surface(array_mesh, 0)

var mesh_instance = MeshInstance.new()
mesh_instance.mesh = array_mesh

var ground_material = preload('res://Materials/Ground.tres')

mesh_instance.material_override = ground_material

asked Jun 8 in Engine by amit (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.