Right. In this tutorial, I'm just fixing up a minor issue involving the way ID chose to render flashblends, and fovs higher than 90. First I'll explain the theory, then I'll show you the fix i implemented: (you can skip this part if you don't care)
The flashblend effect, known to the more technically minded as the
orange balls of glowy stuff around explosions and muzzleflashes in
glquake, when gl_flashblend is set to 0, is not rendered as a sphere,
nor is it a circle. It's basically a cone, made out of a triangle fan,
with one point in the middle with a higher alpha, and those around the
edge with zero alpha. OpenGL smooths them out to look like a spherical
glow. So that they cover the entire model that theyre surrounding, and
to give them a bit more depth, the centre point must be moved a little
nearer to the view. ID software chose to move the centre point along the
line called 'vpn', which is a vector that points in the direction the
player is looking - perpendicular to the screen. The result is that
flashblends which are further from the centre of the screen look like
their centre point is further away from the centre of the screen than
the actual centre of the blend's perimeter. This is because the centre
point is moved along a line perpendicular to the screen, and not one
which points towards the viewpoint. This is all fine and dandy with
a fov of 90, which is why i think ID left it at that - it does look
quite cool. However, at higher fovs, the centrepoint can appear outside
the perimeter, and by strafing you can see how they actually are cones.
THIS IS ABSOLUTELY HEADWRECKING if you have a lot of glows in the map,
particularly with the model glow effects tutorial, where all the torches
in the map get the glow effect. Now here's the actual code: For gl_flashblend, find r_RenderDlight, in gl_rlight.c, and add this line after all the other variable definitions:vec3_t vp2;//dave - slight fix glBegin (GL_TRIANGLE_FAN); VectorSubtract (light->origin, r_origin, vp2); VectorNormalize(vp2); for (i=0 ; i<3 ; i++) v[i] = light->origin[i] - vpn[i]*rad; for (i=0 ; i<3 ; i++) v[i] = light->origin[i] - vp2[i]*rad; Now for model glows. I'm assuming here that you haven't messed around with it any, because if you have, you can probably work out the changes you will need. Go to gl_rmain.c and find R_DrawAliasModel. Add this to the variable definitions at the top:vec3_t vp2; VectorSubtract(lightorigin, r_origin, v); // See if view is outside the light. distance = Length(v); if (distance > radius) { VectorSubtract(lightorigin, r_origin, vp2); // See if view is outside the light. distance = Length(vp2); if (distance > radius) { VectorNormalize(vp2); for (i=0 ; i<3 ; i++) v[i] = lightorigin[i] - vpn[i]*radius; for (i=0 ; i<3 ; i++) v[i] = lightorigin[i] - vp2[i]*radius; This peace of mind was brought to you by KrimZon. |