GameLib Log: 2024

05/25/2024

I've been working on a major re-write of the library. For this newer version I've currently dropped support for PSP and Wii, as I wanted to work with systems that support shaders. Now, the current supported platforms are PC, PS3, PS Vita, and Switch. I'd also like to add support for the original XBox as that supports shaders also.

The previous version I've added a git tag for as v0.1.

The following improvements have been added compared to the previous version so far:

Missing features from v0.1:

Below shows the current shadow and scene graph/hierarchy in action: the ground is the root node, then sphere then cube as children, each transform affecting its children:

05/27/2024

Working on simplifying/unifying shaders between platforms. PC and Switch use GLSL while Vita and PS3 use Cg. Although the VitaGL github says there is experimental GLSL support, TODO look into that.

I'm not really too familiar with Cg so I spent some time looking at the following links: https://developer.download.nvidia.com/cg/Cg_3.1/Cg-3.1_April2012_ReferenceManual.pdf , https://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter01.html

While attempting to implement the shadow mapping shader for Vita, I found that glGetShaderInfoLog wasn't returning anything. Re-installed VitaGL from source, enabling error logging via "make HAVE_SHARK_LOG=1 LOG_ERRORS=2." and then I could see why the shader compilations were failing.

Vita doesn't have inverse function in shader, so defined one for float3x3 using the same logic from the HopsLib math source code.

VitaGL also doesn't support using a depth attachment to a framebuffer, so I attempted to calculate it and store it in the color attachment, using the following reference for calculation: https://stackoverflow.com/questions/10264949/glsl-gl-fragcoord-z-calculation-and-setting-gl-fragdepth, https://stackoverflow.com/questions/6408851/draw-the-depth-value-in-opengl-using-shaders#6409229

It kind-of works, but the objects themselves have some incorrect shading/ artifacts. Good enough for now though:

Am currently attempting to update and run the PS3 version. The same Cg shaders are compiling for ps3 as for Vita, but I think there are some code fixes needed for creation/usage of a framebuffer for rsx. The skybox is drawing and the game isn't crashing (at least in rpcs3), but the scene itself is not rendering.

05/28/2024

Updating the ps3 version - the cg shaders from the vita are compiling. While making a basic unlit shader for debugging, had to send the vertex normals to the fragment shader even though they were unused so that the cg compiler didn't optimize them away; this was causing the normals to be used as the color in the fragment shader.

Now that that's working, next is to get the framebuffer ps3 impl working.

06/01/2024

PS3 current shadow map impl working. I debugged the the shadow depth map generation by displaying the texture onscreen as a sprite. I noticed the PS3 version was flipped vertically compared to the PC and Vita versions. My workaround for this so far is to add a define during PS3 shader calculation to flip the uv y coordinate in the cg fragment shader. In Makefile.ps3, I added:

# Cg compiler flags
CGCFLAGS	:= -Wcg,-DHOPS_PS3_BUILD=1

Then in ShadowedFragment.fcg:

float2 uv = clamp(projCoords.xy,0,1);

    // set in Makefile.ps3
#ifdef HOPS_PS3_BUILD
    uv.y = 1.0 - uv.y;
#endif

I also needed to normalize the color attribute and the light space fragment position, and clamp the shadow map uv between 0 and 1; and to change the clear color for the color buffers to 1/white instead of 0/black in order to match the original PC depth buffer texture. These changes also had the benefit of getting rid of the artifacts the Vita version previously had.

Original PC shadow map using depth buffer:

Flipped ps3 shadow map texture, using color buffer: