What have I done this week?

As I wanted to last week, I did end up learning a few things about shaders. Unfortunately, as with every low-level subject, documentation is sparse. I also remembered I’m terrible at math, which is disappointing, since it’d be great if I could render some 3D stuff with the help of matrices.

With my newfound knowledge I updated my C++ Asteroids game to add a background rendered by a fragment shader. This is a parallax background of stars and nebulae clouds.

Nebulae

Unfortunately I’m not too proud of it – it is heavily based on this noise shader and I still don’t fully understand how it works. I have a lot to learn here. The starfield is created by running the function again, except this time it culls the noise by using smoothstep to filter values outside of a certain range. A parallax effect is created by offsetting the x space coordinate based on the current time:

vec2 st = gl_FragCoord.xy/u_resolution.xy;
vec3 color = vec3(0.0);

st.x += u_time*0.01;
color += starfield(st*1.000);
st.x += u_time*0.02;
color += nebulae(st*3.0);

gl_FragColor = vec4(color,1.0);

There was also a small bug with keyboard inputs, which was fixed.

On backpack.tf: Putting in the groundwork for a transition to PostgreSQL. I’m hoping to ditch MongoDB as our primary database software. I’m convinced we can significantly scale down our hardware requirements if we migrate.

MongoDB won’t be removed entirely. This will be slow and careful move where MongoDB and Postgres will run side-by-sid while collections are migrated. This will allow me to get accustomed to Postgres and Doctrine, since it’s been years since I’ve done something serious with a relational database, and I’ve never used Doctrine.

Classifieds and inventory cache will probably be the last things to be moved, if at all. This will also probably remove a lot of code from the repository – we have our own custom ActiveRecord-style system that wraps the MongoDB library, and it’s not very good.

This will keep me busy. I wish this was done sooner.

What should I try to improve?

I’m often very careful to avoid doing something unless I fully understand it. This is fine, but I’m too careful. I find I often take too long to put out a prototype for anything.

Not sure why this is. Lack of experience, maybe. Need to study more.

What am I going to do next?

I might return to my three-year-old 3D engine prototype I was working on. While working with shaders it became obvious I suck at 3D programming. Returning to this C++/SDL2 project and working to improve it should reinforce some concepts.