Gonetz
Plugin Developer (GlideN64)
I'm trying to implement fog, using fog coordinate instead of Q.
I use linear fog table, created as guFogGenerateLinear (rdp.fog, 0, fog_multiplier + fog_offset),
where fog_multiplier and fog_offset are values set by moveword command. fog_offset is negative, and fog_multiplier + fog_offset ~ 255
Fog coordinate is calculated as follow:
v.fog = 1.0f/max(0.01f, v.z/v.w* fog_multiplier + fog_offset), where v.z and v.w are coordinates in homogeneous space.
I’ve got correct fog thickness with this method, but I have one serious problem. When values of fog_multiplier and fog_offset are large (~20000), fog is not smooth. Look at the screen shots. First screen, fog is quite correct. Second screen – I moved camera to the right just a bit, and got right wall fogged wrongly. It happens because 2 0f 3 vertices have fog coordinate set to minimal. When fog_multiplier and fog_offset are large, v.z/v.w must be very close to 1 to (v.z/v.w* fog_multiplier + fog_offset) be positive. Vertices had fog coordinate ~100, camera was moved, and fog coordinates became minimal -> fog became discontinuous. I don’t know, how to fix it. Afaik, other plugins use similar methods for fog emulation, why only I have this problem?
I use linear fog table, created as guFogGenerateLinear (rdp.fog, 0, fog_multiplier + fog_offset),
where fog_multiplier and fog_offset are values set by moveword command. fog_offset is negative, and fog_multiplier + fog_offset ~ 255
Fog coordinate is calculated as follow:
v.fog = 1.0f/max(0.01f, v.z/v.w* fog_multiplier + fog_offset), where v.z and v.w are coordinates in homogeneous space.
I’ve got correct fog thickness with this method, but I have one serious problem. When values of fog_multiplier and fog_offset are large (~20000), fog is not smooth. Look at the screen shots. First screen, fog is quite correct. Second screen – I moved camera to the right just a bit, and got right wall fogged wrongly. It happens because 2 0f 3 vertices have fog coordinate set to minimal. When fog_multiplier and fog_offset are large, v.z/v.w must be very close to 1 to (v.z/v.w* fog_multiplier + fog_offset) be positive. Vertices had fog coordinate ~100, camera was moved, and fog coordinates became minimal -> fog became discontinuous. I don’t know, how to fix it. Afaik, other plugins use similar methods for fog emulation, why only I have this problem?