Posts

Recovery programming

Image
Sorry! Hello, sorry I haven't posted in a long while I have been super busy with some personal things. Here are some things I have made over the past couple of weeks while getting back on my feet!
LANChat While learning how to make LANHelper I made another program where you can chat to people on your LAN and send files to them. From making this i learned how to create a udp networking system using headers to describe the data being send.


https://github.com/Bambofy/LANChat

LANHelper A simple utility so that programs can be networked locally really easily, check out the Program.cs for a test case and an example chat program. From this I learned how to abstract the udp networking system to be used for generic applications.

https://github.com/Bambofy/LANHelper

WindowsFormsGraphicsAnother simple program so that you can create animations using windows forms as a render target. See "FontsGalore.cs" for an example of how to use it. https://github.com/Bambofy/WindowsFormsGraphi…

Project 6: Marching cubes algorithm and metaballs.

The marching cubes algorithm is a way of creating polygons from volumes of data. The data it works on is varied such as 1 / R^2 (the one used to produce metaballs) and a noise function like perlin noise.

My implementation of marching cubes in a nutshell is initially the scene is split into a 3d grid of voxels, then at the corners and center of each voxel an isovalue is calculated (to form the isosurface).
Then using the comparison between the isovalue at each vertex with a threshold value, a table of indices which tell you which edges have been intersected and how each edge is connected to form the triangle facets is referenced.

To generate metaballs from this technique, i used the function 1 / distance^2 to calculate the isovalues at vertices.

Calculating the normal at each triangle facet was done through assuming that each point charge in the scene was a sphere, and the triangle was sitting on the surface of each sphere, individually taking the normals each time. I then took the ave…

University work: The Column.

Image
This assignment for 3d graphics and simulation module involves rendering a scene from scratch using opengl and simulating physics with collisions between different shapes.

Here's what I have so far:


I still have a bunch of work to do with the portals (you can see that they disappear and reappear), the collision responses between the objects (it is kind of `glitchy` and I want to implement proper prediction and intersection calculations) and attenuation of the light sources.

I'm pretty happy with what I have so far, but with projects like these I feel like I could add a million things and never feel like it is fully completed!



Graphics Work

Image
A quick update on what I've been working on recently.

For one of my modules Simulations and 3D Graphics, we were set a task to learn lighting and materials. So far I have implemented a single light, using ADS and blinn-phong (again).


The camera can rotate, move forward/backward. The armadillo can be rotated on it's pedestal and the whole scene can be rotated.

Project 5: Stanford dragon rendering

Image
This dragon is one of the many models which the Stanford University Computer Graphics Laboratory scanned. More info http://graphics.stanford.edu/data/3Dscanrep/. I used this to practice for an upcoming module, it is made in OpenTK and uses OpenGL 4.5.

Work for this included:
Loading vertex and normal data from .OBJ.Parsing material file for Blinn-Phong attributes.Blinn-Phong glsl shaders.Setting model/view/projection matrices.Configuring camera and light positions.

Project 4: Ray casting with a 2d graphics library.

Image
Implementing this using one of my favorite frameworks (https://love2d.org/) in Lua was a lot of fun!

This is heavily inspired by Wolfenstein 3D.

It involved simple trigonometry, calculating ray/shape intersections, figuring out how to map textures and lighting effects.

A problem I encountered was a fisheye lens effect, because for each ray projected into the world, I would map the intersection distance directly to the height a wall (which is a group of line slices). However what I needed to do was calculate the perpendicular distance of the intersection using the projection plane as a reference.



Here's a great image which helped me understand the problem a lot, originally my raycasting method resembled the one of the far right.


Here are the resources I used:
http://permadi.com/1996/05/ray-casting-tutorial-table-of-contents/ - Help with the projection plane/intersection distance calculation.https://en.wikipedia.org/wiki/Linear_interpolation - How I map the texture coordinates onto…

Project 3: Grass Sim

Image
Overview One of the main problems with rendering lots of primitives, is each one requires its own draw call/position definition.
A solution to this is instanced rendering, where you give opengl a set of vertices and tell it to render it X amount of times. Since it computes everything internally from then on the cost of it is near 0.

Instanced rendering does this (pseudo code):
for 0, X do Set Instance ID DrawArrays/DrawElements.etc
In the form of this:
GL.DrawArraysInstanced(PrimitiveType.Triangles, 0, 3, X);
So now the fun part involves the shaders because each instance cannot be given a unique uniform value (which is what I do normally).
Each instance has an ID from 0->X, utilising this in interesting ways allows you to produce cool effects for practically free.

Here's what I came up with after playing around with it:


Video after adding a time uniform:

Vertex Shader Details To distribute the triangles uniformly given a number from 0 -> 10,000.
int x = int( mod( gl_Instan…