Showreel of the projects and games I worked upon in my undergraduate years when I got time off my official degree in Mechanical Engineering.
We made a game called Two Opposites for the Brackeys Game Jam 2021.1. The game was made in a week and out of the 10k+ people participated worldwide, it ranked #22 in the innovation category. You can play it in your browser here.
Upon initial analysis, we decided that the atmosphere should be given the most priority while developing this game. And the visual appeal of the game played a significant role in that. Back when we started working on this project, Unity didn’t have any rendering pipeline that supported 2D lighting. So my task was to develop a 2D lighting system for the game.
for (float i = 0; i < theta; i += steps)
{
GL.Begin(GL.LINES);
GL.Color(col); // Initializing GL Library with white color as input
GL.Vertex3(player.transform.position.x, player.transform.position.y, 0); //strating point
GL.Vertex3(player.transform.position.x +
Mathf.Cos(i * Mathf.Deg2Rad) * maxVisiblityDistance,
player.transform.position.y +
Mathf.Sin(i * Mathf.Deg2Rad) * maxVisiblityDistance,
0); //ending point
GL.End(); //clearing garbage
}Adjusting steps Adjusting theta
theta.steps.col.maxVisiblityDistance.OnPostRender() method so that the lines are rendered as soon as the camera finishes rendering the scene.GL.Begin(GL.LINES);
lineMat.SetPass(0);
GL.Color(new Color(lineMat.color.r,
lineMat.color.g,
lineMat.color.b,
lineMat.color.a));
With transparency controls, the rays looked more natural
RaycastHit2D hit = Physics2D.Raycast(player.transform.position,
new Vector2(Mathf.Cos(i * Mathf.Deg2Rad),
Mathf.Sin(i * Mathf.Deg2Rad)),
maxVisiblityDistance);
if (hit)
{
GL.Vertex3(player.transform.position.x, player.transform.position.y, 0);
GL.Vertex3(hit.point.x, hit.point.y, 0);
}
else
{
GL.Vertex3(player.transform.position.x, player.transform.position.y, 0);
GL.Vertex3(player.transform.position.x +
Mathf.Cos(i * Mathf.Deg2Rad)* maxVisiblityDistance,
player.transform.position.y +
Mathf.Sin(i * Mathf.Deg2Rad)* maxVisiblityDistance,
0);
} SpriteRenderer sp = hit.transform.GetComponent<SpriteRenderer>();
if (sp != null)
{
sp.color = new Color(1 / Mathf.Pow(Vector3.Distance(
hit.transform.position, player.transform.position),
1.5f),
1 / Mathf.Pow(Vector3.Distance(hit.transform.position, player.transform.position),
1.5f),
1 / Mathf.Pow(Vector3.Distance(hit.transform. position, player.transform. position),
1.5f));
} int numRays = Caster.LightContour.Count - 1;
LightMesh.mesh.vertices = Caster. LightContour. ToArray();
int[] triangles = new int[numRays * 3];
for (int i = 0; i < numRays * 3; i += 3)
{
triangles[i] = (i / 3 + 1) % numRays;
triangles[i + 1] = numRays;
triangles[i + 2] = (i7 3 + 2) % numRays;
}
LightMesh.mesh.triangles = triangles;This 2D lighting system that I incorporated in the project was implemented by Unity in the later versions as a Package in URP Render Pipeline.