Codebase

A lot of stuff in the Manifold Garden codebase finally clicked for me tonight.

Feels great to finally get a good grasp of what’s going on.

Code Cleanup

More code clean up. Been streaming a lot lately.

Very little motivation these days. Finding it’s all just discipline now.

Keep a very strict and regular routine so as not to lose momentum.

Streaming helps.

Saving Image

Worked on optimizing saving today.

At the start of the day, it was 1000 ms as it was running in the main thread.

Had it run in a separate thread, and also split up texture2D.ReadPixels to happen over multiple frames.

I’m saving a small screenshot of the game to use in the load game screen.

Intead of doing ReadPixels all at once, I read it in chunks over the course of several frames. Much better performance.

Code here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Saving by one slice each frame
        screenshot.ReadPixels(new Rect(0, 0, width / 4, height), 0, 0);
        yield return null;

        for (int i = 1; i < 4; i++)
        {
            current_tex = RenderTexture.active;
            RenderTexture.active = renderTex;
            screenshot.ReadPixels(new Rect(width * ((float)i / 4), 0, width * ((float)i / 4), height), (int) (width * ((float)i / 4)), 0);
            RenderTexture.active = current_tex;
            screenshotCamera.targetTexture = null;

            yield return null;
        }

screenshotCamera.targetTexture = null clears the player camera.

Took a while to figure this one out. Without it, the screen kept going black momentarily.

Opening Seconds

It’s important to make a good first impression.

Here’s what the first opening seconds of Manifold Garden looks like (w/out the choppy frame rate of course)

Opening Seconds