MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RenderFogFaces

Function RenderFogFaces

Descent3/render.cpp:1558–1619  ·  view source on GitHub ↗

Render a fog layer on top of a face

Source from the content-addressed store, hash-verified

1556
1557// Render a fog layer on top of a face
1558void RenderFogFaces(room *rp) {
1559 int vn;
1560 float eye_distance;
1561 g3Point *pointlist[MAX_VERTS_PER_FACE];
1562 g3Point pointbuffer[MAX_VERTS_PER_FACE];
1563 rend_SetOverlayType(OT_NONE);
1564 rend_SetTextureType(TT_FLAT);
1565 rend_SetLighting(LS_NONE);
1566 rend_SetColorModel(CM_MONO);
1567 rend_SetAlphaType(AT_VERTEX);
1568 rend_SetAlphaValue(255);
1569 rend_SetZBufferWriteMask(0);
1570 rend_SetCoplanarPolygonOffset(1);
1571
1572 rend_SetFlatColor(GR_RGB((int)(rp->fog_r * 255.0), (int)(rp->fog_g * 255.0), (int)(rp->fog_b * 255.0)));
1573 for (int i = 0; i < Num_fog_faces_to_render; i++) {
1574 face *fp = &rp->faces[Fog_faces[i]];
1575 for (vn = 0; vn < fp->num_verts; vn++) {
1576 pointbuffer[vn] = World_point_buffer[rp->wpb_index + fp->face_verts[vn]];
1577 g3Point *p = &pointbuffer[vn];
1578 pointlist[vn] = p;
1579
1580 float mag = 0;
1581
1582 if (Room_fog_plane_check == 0) {
1583 // Outside of the room
1584 vector *vec = &rp->verts[fp->face_verts[vn]];
1585 // Now we must generate the split point. This is simply
1586 // an equation in the form Origin + t*Direction
1587
1588 float dist = (*vec * Room_fog_plane) + Room_fog_distance;
1589
1590 vector subvec = *vec - Viewer_eye;
1591 float t = Room_fog_eye_distance / (Room_fog_eye_distance - dist);
1592 vector portal_point = Viewer_eye + (t * subvec);
1593
1594 eye_distance = -(vm_DotProduct(&Viewer_orient.fvec, &portal_point));
1595 mag = vm_DotProduct(&Viewer_orient.fvec, vec) + eye_distance;
1596 } else if (Room_fog_plane_check == 1) {
1597 // In the room, distance from
1598 vector *vec = &rp->verts[fp->face_verts[vn]];
1599 mag = vm_DotProduct(&Room_fog_plane, vec) + Room_fog_distance;
1600 }
1601 float scalar = mag / rp->fog_depth;
1602 if (scalar > 1)
1603 scalar = 1;
1604 if (scalar < 0)
1605 scalar = 0;
1606 p->p3_a = scalar * Room_light_val;
1607
1608 p->p3_flags |= PF_RGBA;
1609 }
1610 if (fp->flags & FF_TRIANGULATED)
1611 g3_SetTriangulationTest(1);
1612 g3_DrawPoly(fp->num_verts, pointlist, 0);
1613 if (fp->flags & FF_TRIANGULATED)
1614 g3_SetTriangulationTest(0);
1615 }

Callers 2

DrawPostrenderFaceFunction · 0.85
RenderRoomFunction · 0.85

Calls 13

g3_SetTriangulationTestFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetOverlayTypeFunction · 0.50
rend_SetTextureTypeFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50
rend_SetZBufferWriteMaskFunction · 0.50
rend_SetFlatColorFunction · 0.50
GR_RGBFunction · 0.50

Tested by

no test coverage detected