• Muhammed Favas

Procedural modeling.

The leading platform for creating interactive, real-time content

Unity 3D is an all-in-one platform for mobile game development and is the registered trademark of Unity Technologies. It has gained tremendous attention from the game developers community with its quirky features, supportive pricing, and strong capabilities for video gaming. With its ability to function as a cross-platform game development tool, it saves developers time that would otherwise be spent in developing games for individual platforms.

Unity is so much more than the world’s best real-time development platform – it’s also a robust ecosystem designed to enable your success. Join our dynamic community of creators so you can tap into what you need to achieve your vision.

This is the starting of the series on procedural modelling. it helps to create procedural models in unity.

This tutorial is made with Unity 2020.3.7f1.

1. Bezier curve in unity

We begin by introducing the Bezier curve in unity, the concepts, and the underlying mathematics behind the curve. let me start with linearly interpolating between two points unity using lerp function.

Vector3 result =Vector3.Lerp(green, red, t);

Interpolation of white ball between red and

green ball based on t value

(value of result will be green if t=0, red when t=1.).

If we lerp between two lerped results we get a quadratic lerp.

 Vector3 QuadraticLerp(Vector3 a, Vector3 b, Vector3 c, float t)
   lerp1= Vector3.Lerp(a, b, t);
   lerp2 = Vector3.Lerp(b, c, t);
   return Vector3.Lerp(lerp1, lerp2, t)

Quadratic lerp

Now if we lerp again between two quadratic lerped values we get a cubic lerp.

 Vector3 CubicLerp(Vector3 a,Vector3 b,Vector3 c,Vector3 d,float t)
   Vector3 lerp1=QuadraticLerp(a, b, c, t);
   Vector3 lerp2= QuadraticLerp(b, c, d, t); 
   return Vector3.Lerp(lerp1, lerp2, t);

cubic lerp

If we join plot the trajectory of the blue ball we get a cubic bezier curve. first and the last point(green) are called anchors and the middle two points(green) are handles.

we can draw a cubic bezier curve using DrawBezier function in unity.

Handles.DrawBezier(a, b, c,d, Color.green,null,2f);

Bezier curve in unity.

We will explore more on unity bezier curve and its implementation to create procedurally generated roads in unity in upcoming sections.

So until then bye.

For Unity projects and trainings contact

Palmate Technologies L7, Al Murjanah Tower,Prince Sultan St Ar Rawdah,PO Box 10113 Jeddah 21433 Jeddah,Kingdom of Saudi Arabia Call Us : +966 12 601 7649

Email : hello@palmate.biz