Closed mkst closed 4 years ago
Just noticed this. It's simulated fog, right? The walls are supposed to be darker (until you get close enough) but the sky portion is supposed to be completely clear, right?
Edit: Somehow I remember there being a clearly visible alpha plane like this, but I guess that is also wrong
I guess I should fire up SM64 in an emulator to see how things are meant to look*; it's been a while.
Currently fog is implemented by drawing the triangles twice, once with colour, once as fog. citro3d has some fog functionality which might yield better results (and performance?) if I (or someone) figures it out.
I read up about alpha tests and this is my understanding: This condition triggers when the shader is processing an alpha layer and a hard edge texture with alpha for the same texel at the same time. A shadow and a tree, for example, or in the case of JRB, the fog and the crag tops. The alpha test then calculates, based on how this function is set, all texels with combined alpha values less than 77 (of 255) and culls them. That is where the visible fog gradient (the fog "wall" as I was calling it) is coming from. Alpha values above 77 remain, so you get the darker fog in the distance, but the thinner fog in the foreground has been culled, which is incorrect.
There is likely also a depth test, which I suspect is what's screwing the trees up in combination with an alpha test somewhere, that basically functions based on the Z buffer position instead of alpha level. The correct function is bound to be loads more nuanced, this looks like something someone was writing and then stopped half way.
This is an issue with the fog branch only: I guess your fog function is not respecting the parameters of the RDP's scissoring and/or viewport? Probably the only place in the game where it happens, JRB is too dark to notice it, but you never know when these underlying issues crop up somewhere else as a glitch.
Also, a potential hint: Enabling 3D removes the fog from the scene, just like JRB fog disappears, but the credits background color change does NOT disappear. Seems to suggest you might be right with your fog being rendered at very high Z levels, so it's being clipped.
This is an issue with the fog branch only:
I've just rebased 3ds-fog
off of 3ds-port
and beaten the game, TTC credits looked correct for me:
... no closer to solving Fog + 3D as yet.
The tops of the walls should be transparent.
3DS:
N64: TODO
More info to be added as it's discovered.
Edit 1
Increasing the threshold for alpha affects this: