OpenGL Project

During my first year of university I took the Games Programming and Design course, however for my second year I swapped to the Games Programming course. In order to improve my pure programming skills, I worked on this project for a month which I would have had to complete if I had chosen to do Games Programming during my first year. In my project, I have implemented: bmp image loader, .obj mesh loader, camera movement, texturing stylistic reminiscent of the ps1, materials and lighting.

PS1 Styling Techniques

There are a few aspects of the rendering process used for the PS1 that give it a distinct styling which I attempted to emulate. Namely, these are: 256x256 texture resolution, rudimentary lighting and shading, texture warping and lack of Z-buffer. To emulate the texture resolution used on the PS1, I wrote some code that will convert any bitmap texture used into one of a reduced size.

    
	int downscaledWidth = 256;
	int downscaledHeight = 256;
	std::vector downscaledTextureData(downscaledWidth * downscaledHeight * 4);  
	float scaleX = static_cast(m_width) / downscaledWidth;
	float scaleY = static_cast(m_height) / downscaledHeight;

	for (int y = 0; y < downscaledHeight; ++y) {
		for (int x = 0; x < downscaledWidth; ++x) {
			int originalX = static_cast(x * scaleX);
			int originalY = static_cast(y * scaleY);
			for (int channel = 0; channel < 4; ++channel) {  
				downscaledTextureData[(y * downscaledWidth + x) * 4 + channel] = tempTextureData[(originalY * m_width + originalX) * 4 + channel];
			}
		}
	}
    
  

I also altered many glenable functions from their defaults as to enhance the aesthetic I was trying to achieve, such as dithering. There were two asepects of the PS1 which I was not able to emulate using OpenGL. These being the lack of Z-buffer and the texture warping that comes from the PS1s lack of sub-pixel precission. I considered diabling Z-buffer and altering the way in which my objects were drawn, however I decided this added little to the aesthetic I wanted to create compared to the work. I strongly desired to create the warping effect and tried many work arounds to achieve this including: faking a wobble effect with sin waves, using fixed point precission variables for the matrix transformation calculations and also using fixed point variables for my uv coordinates. None of these methods created the desired effect; to my understanding, this effect would be possible to create in newer versions of OpenGL using shaders (I did not have these available to me in this version however).

.Obj Mesh Loader

My .Obj loader works by loading in vertices, uvs, normals and their indices into vectors which are then pushed onto the mesh structure I have created. I initially struggled when creating this because I tried to adapt code I was using for a different approach, which led to odd results due to overflow errors. My current approach uses the glm library as to utilise its vector structures and math functions. The biggest problem I faced was understanding and effectively implementing the indices, however I was able to properly implement them after doing proper research and adjusting the drawing code to accomodate this method.

Who Did What?

Abandoned Cottage House by animatedheaven

When Was it Made?

This project was worked on independently from June to July 2023.

What Went Well?

I believe that I was able to somewhat succesfully capture the aesthetic I was looking for with this project. On a fundamental level, my code is structured well and my project is expandable due to my implementation of linked lists. I have achieved all the functional goals I wanted for this project and I spent only a month working on it. I am especially happy that I was able to implement obj and bmp file formats into my project as I felt I learnt a lot by doing so.

What Could Be Better?

If I did this project again I would not have used such an old version of OpenGL because I would have liked to achieved the texture warping effect which would be much easier to impelement on these newer versions of the library. Other than this, I think my time could have been spent more wisely if I had done all the research I needed to before attempting certain problems instead of creating more problems as I was trying to fix things.

 

Social Media

 

Rhys Elliott 2023. contact@rhyselliott.com