Projects
Table of contents
2017
Procedural Generation using WCF
Image Primitives
Thread Pool
Multi-threading matrix multiplication
Software Rasterizer
2016
Memory allocators
Basic OpenGL project
Software Raytracer
MSc. thesis: AI system to simulate combat behaviors in FPS
2015
Bug0 navigation algorithm for Turtlebot 2.0
Android app to vote for the 9N Catalonian referendum
2017
Procedural Generation using WCF (in progress)
C#, Unity, WCF, Voxel Art
This is my last project and it’s currently under development. I wanted to do something with Unity and Procedural Generation so I am implementing a Wave Collapse Function to procedurally generate buildings.
By now, I’ve managed to implement an algorithm that takes a set of arbitrary models and combines them to generate buildings. It automatically, scans the meshes of these models to generate symmetric models and detect constraints on which models can be combined together. I am currently learning Maya in order to create more and prettier models to generate bigger buildings and cities.
The following gif is just an example of how the algorithm combines simple models to create a simple building:
The algorithm, however, can be used to create bigger and more complex things. Checkout this youtube video (click on the image):
Try the demo
Image Primitives
C++, Multi-threading, Geometry, Hill Climb
This project aims to reproduce an image using geometric primitives (triangles or ellipses). The algorithm takes an input image and tries to minimize the difference between the input image (or target) and the generated image (or current) by adding geometric shapes.
In order to find a good primitive that minimizes the difference, I generate several random shapes and I pick the best of them. Then, I mutate the primitive using a Hill Climb approach to improve even more the difference.
The algorithm can run using a Thread-pool to improve the results and the speed.
This cute dog was generated using around 1000 triangles.
Thread Pool
C++, Multi-threading, Semaphores, Futures
After the multi-threading matrix multiplication project I decided to dig deeper into this topic and try to create something cool and useful. I ended up with the idea of a Thread Pool.
From Wikipedia:
In computer programming, a thread pool is a software design pattern for achieving concurrency of execution in a computer program. […] A thread pool maintains multiple threads waiting for tasks to be allocated for concurrent execution by the supervising program. By maintaining a pool of threads, the model increases performance and avoids latency in execution
And that’s what I did. I created a generic thread pool in C++11 that can take a function with an arbitrary signature and returns a future. This future will be solved with the result of the function as soon as the thread pool has an available thread to execute it.
Multi-threading matrix multiplication
C++, Multi-threading
In order to review my multi-threading skills and learn about the “new” thread class in C++11 I decided to implement this simple program.
My idea was to compare two different implementations, one sequential vs one multi-thread to see how much improvement there is. The problem I choose was matrix multiplication.
The sequential algorithm is quite straightforward. The multi-threading one is a little bit tricky. The idea is to split the matrix in independent parts that can be handled by one unique thread avoiding syncronization and increasing performance.
Software rasterizer
C++, 3D Graphics, Rendering
After a small OpenGL project I decided to implement my own OpenGL rendering pipeline in the CPU in order to understand how it works. The goal of this project was not to create a next generation renderer but to understand how the rendering algorithms transforms a set of vertices that make up a 3D World into a 2D image of that World.
For this project I started by implementing a very basic rasterizer to render a simple triangle and then I added more and more features like:
- Camera and Object transformations using 4x4 homogeneous matrices
- Rotations using Euler angles and Quaternions
- Affine and Perspective corrected mapping for textures
- Orthographic and Perspective camera
- Phong and Blinn-Phong shading given material phong coefficients
- Phong and Blinn-Phong shading given material diffuse and specular textures
- Normal mapping
- Simple optimizations
- A depth-buffer to solve the visibility surface problem
- Two rendering paths: Forward and deferred
- Sha
- dow mapping for directional lights with PCF
2016
Memory allocators
C++, Memory Management
After talking about memory management in games with a fellow RC during my time in New York I decided to research about it and I ended up implementing serveral memory allocators (linear, stack, pool and free list).
Developing a custom allocator was quite tricky because I had to implement by myself how memory was stored and managed with the allocate and free operations. Meta data must be kept to a minimum and data must be always aligned.
After implementing all of this, I compared the performance of my allocators against malloc using custom benchmarks. It turned out that all my allocators were way better than malloc.
Checkout also the slides I used for a 5-min presentation I gave at the RC
Basic OpenGl project
C++, OpenGL, 3D Graphics, Rendering
Very basic project based on a series of tutorials. It was useful for me as an introduction to OpenGL. I implemented some simple features like Gouraud, Phong and Blinn-Phong Shading, Rim lighting, normal mapping and shadow mapping.
Software raytracer
C++, 3D Graphics, Rendering
The goal of this project was to become familiar with C++ and graphics stuff while having fun. It was a really amazing project and I encourage everyone to do it if you like graphics. My raytracer is a backwards raytracer. Is quite basic and simple and includes the following features:
- Basic shapes: Planes and Spheres.
- Shadows: Simulate shadows using Shadow Rays to multiple light sources. The shadows can be softer or harder depending on the number of lights that illuminate them.
- Phong illumination model to simulate simulate ambient, colored diffuse and colored specular illumination.
- Mirror reflection: Perfect reflection for mirrors.
- Refraction: Refraction of light depending on the refraction index of the materials.
- Anti-aliasing: Regular sampling technique.
- Multiple cameras: perspective and orthogonal.
- Easy to extend. I took care to design the raytracer folowing the software principles. It is very to modify or extend any of the previous features, for example, to add another material, camera or sampling method.
MSc. thesis: AI system to simulate combat behaviors in FPS
C++, Unreal Engine 4, Artificial Intelligence, Behavior Trees
The aim of this project was to build an AI system for an existing game. To do so, I replaced the AI system of the Shooter Game provided by the Library of Unreal Engine 4 with my own AI system.
This system was based on UE4 Behavior Trees with many custom nodes created in C++ and also in modifications on to add interesting features:
- Tactical pathfinding. I modified the A* navigation algorithm of UE4 to modify the cost heuristic based on the the areas that were visible by the player (I implemented a custom visibility algorithm to determine this).
- Player prediction. In order to calculate the most probable position of the player after a certain time without seeing him, I implemented my custom Influence Maps.
- Group behavior. I shared some information between the different bots to attack from different sides or spreading out on the map when searching.
- Positioning. I created custom EQS queries to test whether a position was good cover or a good attack position, or if it was close to an obstacle…
2015
Bug0 navigation algorithm for Turtlebot 2.0
Python, Navigation
I developed this project along with two students as the final project for a Robotics and VIsion subject in the university.
We developed a Bug0 navigation algorithm for a Turtlebot 2 in Python that was able to move from the initial position to the goal position (in local space).
We used the odometry sensors of the Turtlebot to update and correct the current position. We also took advantage of the depth sensor of the XBOX Kinect to detect obstacles. Once an obstacle was detected, the robot tried to surround it. After that, the robot re-calculated the trajectory to the goal and repetead the process.
Android app to vote for the 9N Catalonian referendum
Android, Java, Databases
Two weeks before the referendum for the independence of Catalonia I met with five friends and we developed an Android application to let people vote through their smartphone and forecast the results of the referendum. We also generated basic demographics statistics to see how votes were distributed across Catalonia, age and genres.
The app is on the Playstore. However, we no longer maintain it.