2010-08-21, 05:21 PM
I'm adding a do_rangefog option.
Range fog computes the true distance from the viewer instead of the using the pseudo-depth coordinate for fog. The benefits are when you turn around the fog doesn't change (as you'd expect) and you don't have a sweeping line, almost like a scanline delineating your fog. Which is especially apparent in 16bpp mode because the fog tends to manifest as thick bands of colour.
The cons are rangefog is not per pixel. You can implement per pixel fog in a shader, but it's generally not considered worthwhile (though I might add that as an option yet) expensiveness wise. Instead the distance of every vertex is computed and the fog gets interpolated across the triangle like everything else. In general the results are exactly what you'd expect. The distance however is not linear per say (imagine a circle of fog emanating from the player) but the interpolation is. So you can end up with a visual disconnect.
In practice it looks like better quality fog. But in theory like if you had a wide floor that was one polygon (say two triangles) then the fog across it would appear linear, but the fog across other things in the room would appear more "correct". If the scene is fairly detailed and full of natural polygons (the outdoor ground in Som is a pretty good example) things look good. But across very flat surfaces, I can't even say if busting it up into smaller polygons would help or not. But at worst hopefully the player isn't that focused on fog.
The only trick I can think of would be to bump things up to D3D10 for Geometry Shader support. If you could tessellate the polygons with respect to screen space that might look better. I've noticed modern games always have their surfaces very tessellated. Even when flat, mostly it seems for vertex color based shadows. All vertex color approaches end up with houndstooth patterns however. Another ubiquitous feature Geometry Shader support could bring to Som would be shadow volume extrusion. So with beefy enough hardware all objects could project shadows that match their silhouettes (versus the little fuzzball shadow) ...I generally prefer this kind of shadow, but it can be very hard edged. I think maybe modern games draw the shadows to the stencil buffer then sample the stencil buffer to produce the vertex colors for their tessellated geometry so that the hard shadows are softened that way. But with Som's more abstract look I think I'd rather have the hard edges than the houndstooth artifacts. ST:Abyss had some volumetric shadows going on here and there. The PSP has better support for this kind of effect than the PS2.
EDITED: The only real trick would be working out what light source would dictate the shadows. Another effect I want to add is to load a 2D map of each map up as a texture. With four color channels. I was thinking one channel for instance would be light. So you could make the squares inside a cave darker. And another might be sea level, which could be used for water effects... another temperature for feax effects. But probably it would be best to store the light intensity (a) and direction vectors (r,g,b) in their own map and that could drive the shadow volumes. Then you could just make a b/w 100x100 image and dob it with an airbrush effect in your paint program, then run that thru a normal map generator and use then copy the original image into the alpha channel, and you're done.
I guess you'd still want ambient light intensity in the effects map, or maybe better yet a whole other map for rgb+intensity ambient lighting.
Range fog computes the true distance from the viewer instead of the using the pseudo-depth coordinate for fog. The benefits are when you turn around the fog doesn't change (as you'd expect) and you don't have a sweeping line, almost like a scanline delineating your fog. Which is especially apparent in 16bpp mode because the fog tends to manifest as thick bands of colour.
The cons are rangefog is not per pixel. You can implement per pixel fog in a shader, but it's generally not considered worthwhile (though I might add that as an option yet) expensiveness wise. Instead the distance of every vertex is computed and the fog gets interpolated across the triangle like everything else. In general the results are exactly what you'd expect. The distance however is not linear per say (imagine a circle of fog emanating from the player) but the interpolation is. So you can end up with a visual disconnect.
In practice it looks like better quality fog. But in theory like if you had a wide floor that was one polygon (say two triangles) then the fog across it would appear linear, but the fog across other things in the room would appear more "correct". If the scene is fairly detailed and full of natural polygons (the outdoor ground in Som is a pretty good example) things look good. But across very flat surfaces, I can't even say if busting it up into smaller polygons would help or not. But at worst hopefully the player isn't that focused on fog.
The only trick I can think of would be to bump things up to D3D10 for Geometry Shader support. If you could tessellate the polygons with respect to screen space that might look better. I've noticed modern games always have their surfaces very tessellated. Even when flat, mostly it seems for vertex color based shadows. All vertex color approaches end up with houndstooth patterns however. Another ubiquitous feature Geometry Shader support could bring to Som would be shadow volume extrusion. So with beefy enough hardware all objects could project shadows that match their silhouettes (versus the little fuzzball shadow) ...I generally prefer this kind of shadow, but it can be very hard edged. I think maybe modern games draw the shadows to the stencil buffer then sample the stencil buffer to produce the vertex colors for their tessellated geometry so that the hard shadows are softened that way. But with Som's more abstract look I think I'd rather have the hard edges than the houndstooth artifacts. ST:Abyss had some volumetric shadows going on here and there. The PSP has better support for this kind of effect than the PS2.
EDITED: The only real trick would be working out what light source would dictate the shadows. Another effect I want to add is to load a 2D map of each map up as a texture. With four color channels. I was thinking one channel for instance would be light. So you could make the squares inside a cave darker. And another might be sea level, which could be used for water effects... another temperature for feax effects. But probably it would be best to store the light intensity (a) and direction vectors (r,g,b) in their own map and that could drive the shadow volumes. Then you could just make a b/w 100x100 image and dob it with an airbrush effect in your paint program, then run that thru a normal map generator and use then copy the original image into the alpha channel, and you're done.
I guess you'd still want ambient light intensity in the effects map, or maybe better yet a whole other map for rgb+intensity ambient lighting.