373:. There is another situation where the eye may be in the shadow of a volume cast by an object behind the camera, which also has to be capped somehow to prevent a similar problem. In most common implementations, because properly capping for depth-pass can be difficult to accomplish, the depth-fail method (see below) may be licensed for these special situations. Alternatively one can give the stencil buffer a +1 bias for every shadow volume the camera is inside, though doing the detection can be slow.
225:
leaves a rough shadow artifact near the silhouette edge which is difficult to correct. Increasing the polygonal density will minimize the problem, but not eliminate it. If the front of the shadow volume is capped, the entire shadow volume may be offset slightly away from the light to remove any shadow self-intersections within the offset distance of the silhouette edge (this solution is more commonly used in
259:
36:
696:
133:
224:
There is also a problem with the shadow where the faces along the silhouette edge are relatively shallow. In this case, the shadow an object casts on itself will be sharp, revealing its polygonal facets, whereas the usual lighting model will have a gradual change in the lighting along the facet. This
329:
Heidmann proposed that if the front surfaces and back surfaces of the shadows were rendered in separate passes, the number of front faces and back faces in front of an object can be counted using the stencil buffer. If an object's surface is in shadow, there will be more front facing shadow surfaces
189:
below), whereas the accuracy of a shadow map depends on the texture memory allotted to it as well as the angle at which the shadows are cast (at some angles, the accuracy of a shadow map unavoidably suffers). However, the technique requires the creation of shadow geometry, which can be CPU intensive
537:
Since the depth-fail method only offers an advantage over depth-pass in the special case where the eye is within a shadow volume, it is preferable to check for this case, and use depth-pass wherever possible. This avoids both the unnecessary back-capping (and the associated rasterization) for cases
403:
Around the year 2000, several people discovered that
Heidmann's method can be made to work for all camera positions by reversing the depth. Instead of counting the shadow surfaces in front of the object's surface, the surfaces behind it can be counted just as easily, with the same end result. This
314:
Shadow volumes tend to cover large portions of the visible scene, and as a result consume valuable rasterization time (fill time) on 3D graphics hardware. This problem is compounded by the complexity of the shadow casting objects, as each object can cast its own shadow volume of any potential size
207:
with respect to the light source. The edges forming the silhouette are extruded away from the light to construct the faces of the shadow volume. This volume must extend over the range of the entire visible scene; often the dimensions of the shadow volume are extended to infinity to accomplish this
368:
This approach has problems when the eye itself is inside a shadow volume (for example, when the light source moves behind an object). From this point of view, the eye sees the back face of this shadow volume before anything else, and this adds a −1 bias to the entire stencil buffer, effectively
508:
that has a far clipping plane that extends to infinity in order to accommodate those points, accomplished by using a specialized projection matrix. This technique reduces the accuracy of the depth buffer slightly, but the difference is usually negligible. See 2002 paper "Practical and Robust
198:
In order to construct a shadow volume, project a ray from the light source through each vertex in the shadow casting object to some point (generally at infinity). These projections will together form a volume; any point inside that volume is in shadow, everything outside is lit by the light.
190:(depending on the implementation). The advantage of shadow mapping is that it is often faster, because shadow volume polygons are often very large in terms of screen space and require a lot of fill time (especially for convex objects), whereas shadow maps do not have this limitation.
404:
solves the problem of the eye being in shadow, since shadow volumes between the eye and the object are not counted, but introduces the condition that the rear end of the shadow volume must be capped, or shadows will end up missing where the volume points backward to infinity.
214:
below.) To form a closed volume, the front and back end of this extrusion must be covered. These coverings are called "caps". Depending on the method used for the shadow volume, the front end may be covered by the object itself, and the rear end may sometimes be omitted (see
262:
Illustration of shadow volumes. The image above at left shows a scene shadowed using shadow volumes. At right, the shadow volumes are shown in wireframe. Note how the shadows form a large conical area pointing away from the light source (the bright white
202:
For a polygonal model, the volume is usually formed by classifying each face in the model as either facing toward the light source or facing away from the light source. The set of all edges that connect a toward-face to an away-face form the
475:
variation, which does not deal properly with intersecting shadow volumes, but saves one rendering pass (if not fill time), and only requires a 1-bit stencil buffer. The following steps are for the depth pass version:
364:
After this is accomplished, all lit surfaces will correspond to a 0 in the stencil buffer, where the numbers of front and back surfaces of all shadow volumes between the eye and that surface are equal.
163:
implementation of shadow volumes is generally considered among the most practical general purpose real-time shadowing techniques for use on modern 3D graphics hardware. It has been popularized by the
311:
The difference between these three methods occurs in the generation of the mask in the second step. Some involve two passes, and some only one; some require less precision in the stencil buffer.
330:
between it and the eye than back facing shadow surfaces. If their numbers are equal, however, the surface of the object is not in shadow. The generation of the stencil mask works as follows:
156:
in 1977 as the geometry describing the 3D shape of the region occluded from a light source. A shadow volume divides the virtual world in two: areas that are in shadow and areas that are not.
376:
There is another potential problem if the stencil buffer does not have enough bits to accommodate the number of shadows visible between the eye and the object surface, because it uses
430:
The depth fail method has the same considerations regarding the stencil buffer's precision as the depth pass method. Also, similar to depth pass, it is sometimes referred to as the
691:, Bilodeau, William & Songy, Michael, "Method for rendering shadows using a shadow volume and a stencil buffer", published 2002-05-07, assigned to
496:
One method of speeding up the shadow volume geometry calculations is to utilize existing parts of the rendering pipeline to do some of the calculation. For instance, by using
183:. The main advantage of shadow volumes is that they are accurate to the pixel (though many implementations have a minor self-shadowing problem along the silhouette edge, see
437:
William
Bilodeau and Michael Songy discovered this technique in October 1998, and presented the technique at Creativity, a Creative Labs developer's conference, in 1999.
305:
Render the scene again as if it were completely lit, using the stencil buffer to mask the shadowed areas. Use additive blending to add this render to the scene.
621:
881:
771:"GPU Gems 3: Chapter 11. Efficient and Robust Shadow Volumes Using Hierarchical Occlusion Culling and Geometry Shaders | NVIDIA Developer Zone"
516:
Rasterization time of the shadow volumes can be reduced by using an in-hardware scissor test to limit the shadows to a specific onscreen rectangle.
302:
Using the depth information from that scene, construct a mask in the stencil buffer that has holes only where the visible surface is not in shadow.
1270:
1243:
369:
inverting the shadows. This can be remedied by adding a "cap" surface to the front of the shadow volume facing the eye, such as at the front
280:
to render shadows with shadow volumes quickly enough for use in real time applications. There are three common variations to this technique,
1286:
890:
1010:
119:
874:
1133:
934:
57:
53:
526:
that is designed to remove parts of shadow volumes that do not affect the visible scene. (This has been available since the
100:
1258:
1248:
1138:
957:
72:
1253:
1118:
1058:
603:
538:
where depth-fail is unnecessary, as well as the problem of appropriately front-capping for special cases of depth-pass.
663:
711:
79:
449:
for the technique the same year entitled "Method for rendering shadows using a shadow volume and a stencil buffer".
1046:
867:
531:
442:
801:
770:
552:
can also be used to create shadow volumes by selectively extruding vertices that already reside within GPU memory.
832:
692:
583:
86:
445:
in March 1999, and at
Creativity in late 1999. A few months later, William Bilodeau and Michael Songy filed a
802:"Chapter 11 "Efficient and Robust Shadow Volumes Using Hierarchical Occlusion Culling and Geometry Shaders""
497:
46:
1265:
1215:
1180:
1158:
1153:
68:
1108:
1087:
1031:
472:
377:
688:
991:
977:
921:
642:
530:
FX 5900 model.) A discussion of this capability and its use with shadow volumes was presented at the
149:
254:
to each surface to form a closed volume (may not be necessary, depending on the implementation used)
1123:
1051:
939:
809:
381:
438:
273:
1185:
1173:
1020:
1015:
967:
348:
Set the stencil operation to increment on depth pass (only count shadows in front of the object).
179:
Shadow volumes have become a popular tool for real-time shadowing, alongside the more venerable
1235:
1128:
1113:
929:
504:-coordinate may be set to zero to extend a point to infinity. This should be accompanied by a
342:
1307:
1220:
1210:
1092:
1080:
414:
Set the stencil operation to increment on depth fail (only count shadows behind the object).
258:
153:
93:
1041:
906:
898:
562:
542:
505:
450:
446:
237:
1190:
573:
567:
549:
370:
277:
226:
180:
160:
1301:
1069:
999:
17:
351:
Render the shadow volumes (because of culling, only their front faces are rendered).
172:, and a particular variation of the technique used in this game has become known as
1200:
1163:
1148:
1143:
1063:
1004:
510:
392:
1168:
1036:
972:
578:
454:
335:
35:
164:
509:
Stenciled Shadow
Volumes for Hardware-Accelerated Rendering", C. Everitt and
741:
483:
Set the stencil operation to XOR on depth pass (flip on any shadow surface).
667:
321:
below for a discussion of techniques used to combat the fill time problem.
718:
132:
1026:
457:
independently discovered the algorithm in 2000 during the development of
1075:
778:
527:
243:
Extend all silhouette edges in the direction away from the light-source
1205:
962:
519:
459:
168:
138:
859:
1225:
911:
257:
131:
715:
Practical and Robust Shadow
Volumes page of NVIDIA Developer Zone
949:
240:(edges which separate front-facing faces from back-facing faces)
152:
to add shadows to a rendered scene. They were first proposed by
863:
360:
Render the shadow volumes (only their back faces are rendered).
29:
800:
Stich, Martin; Carsten Wächter; Alexander Keller (2007).
742:"Advanced Stencil Shadow and Penumbral Wedge Rendering"
808:. archive.org: nVidia / Addison-Wesley. Archived from
471:
Either of the above types may be approximated with an
423:
Set the stencil operation to decrement on depth fail.
357:
Set the stencil operation to decrement on depth pass.
296:
Render the scene as if it were completely in shadow.
1279:
1234:
1101:
990:
948:
920:
897:
60:. Unsourced material may be challenged and removed.
548:On systems that do not support geometry shaders,
522:has implemented a hardware capability called the
232:The basic steps for forming a shadow volume are:
833:"Shadow Volume Extrusion using a Vertex Shader"
643:"Stencil Shadows Patented!? WTF! - GameDev.net"
480:Disable writes to the depth and color buffers.
408:Disable writes to the depth and color buffers.
384:instead, the problem would be insignificant.)
875:
666:. The Tech Report. 2004-07-29. Archived from
8:
608:Computer Graphics (SIGGRAPH '77 Proceedings)
545:can be used to generate the shadow volumes.
945:
882:
868:
860:
136:Example of Carmack's stencil shadowing in
120:Learn how and when to remove this message
292:, but all of them use the same process:
604:Shadow Algorithms for Computer Graphics
595:
622:"The Theory of Stencil Shadow Volumes"
395:is often referred to as the z-buffer.
717:. archive.org: NVIDIA. Archived from
7:
1287:List of computer graphics algorithms
664:"Creative patents Carmack's reverse"
570:, an alternative shadowing algorithm
387:Depth pass testing is also known as
58:adding citations to reliable sources
712:"John Carmack on shadow volumes..."
25:
441:presented this technique at both
317:
210:
185:
513:, for a detailed implementation.
34:
749:Game Developers Conference 2005
217:
173:
45:needs additional citations for
541:On more recent GPU pipelines,
268:Stencil buffer implementations
1:
1244:3D computer graphics software
710:Kilgard, Mark; John Carmack.
1059:Hidden-surface determination
27:Computer graphics technique
1324:
610:, vol. 11, no. 2, 242–248.
532:Game Developers Conference
486:Render the shadow volumes.
426:Render the shadow volumes.
417:Render the shadow volumes.
693:Creative Technology Ltd.
584:List of software patents
1271:Vector graphics editors
1266:Raster graphics editors
620:Yen, Hun (2002-12-03).
498:homogeneous coordinates
411:Use front-face culling.
354:Use front-face culling.
299:For each light source:
148:is a technique used in
1154:Checkerboard rendering
420:Use back-face culling.
334:Disable writes to the
276:showed how to use the
264:
142:
1109:Affine transformation
1088:Surface triangulation
1032:Anisotropic filtering
447:US patent application
378:saturation arithmetic
261:
135:
18:Stencil shadow volume
775:developer.nvidia.com
272:After Crow, in 1991
150:3D computer graphics
54:improve this article
1124:Collision detection
1052:Global illumination
721:on January 27, 2009
602:Crow, Franklin C: "
382:arithmetic overflow
1174:Scanline rendering
968:Parallax scrolling
958:Isometric graphics
338:and color buffers.
265:
143:
1295:
1294:
1236:Graphics software
1129:Planar projection
1114:Back-face culling
986:
985:
930:Alpha compositing
891:Computer graphics
524:depth bounds test
343:back-face culling
174:Carmack's Reverse
130:
129:
122:
104:
16:(Redirected from
1315:
1221:Volume rendering
1093:Wire-frame model
946:
884:
877:
870:
861:
850:
849:
847:
846:
837:
831:Brennan, Chris.
828:
822:
821:
819:
817:
797:
791:
790:
788:
786:
777:. Archived from
767:
761:
760:
758:
756:
746:
737:
731:
730:
728:
726:
707:
701:
700:
699:
695:
685:
679:
678:
676:
675:
660:
654:
653:
651:
650:
639:
633:
632:
630:
629:
617:
611:
600:
543:geometry shaders
391:testing, as the
380:. (If they used
238:silhouette edges
125:
118:
114:
111:
105:
103:
62:
38:
30:
21:
1323:
1322:
1318:
1317:
1316:
1314:
1313:
1312:
1298:
1297:
1296:
1291:
1275:
1230:
1097:
1042:Fluid animation
982:
944:
916:
907:Diffusion curve
899:Vector graphics
893:
888:
854:
853:
844:
842:
835:
830:
829:
825:
815:
813:
812:on May 16, 2011
799:
798:
794:
784:
782:
769:
768:
764:
754:
752:
744:
740:Lengyel, Eric.
739:
738:
734:
724:
722:
709:
708:
704:
697:
687:
686:
682:
673:
671:
662:
661:
657:
648:
646:
641:
640:
636:
627:
625:
619:
618:
614:
601:
597:
592:
563:Silhouette edge
559:
506:viewing frustum
493:
469:
401:
327:
270:
196:
126:
115:
109:
106:
69:"Shadow volume"
63:
61:
51:
39:
28:
23:
22:
15:
12:
11:
5:
1321:
1319:
1311:
1310:
1300:
1299:
1293:
1292:
1290:
1289:
1283:
1281:
1277:
1276:
1274:
1273:
1268:
1263:
1262:
1261:
1256:
1251:
1240:
1238:
1232:
1231:
1229:
1228:
1223:
1218:
1213:
1208:
1203:
1198:
1193:
1191:Shadow mapping
1188:
1183:
1178:
1177:
1176:
1171:
1166:
1161:
1156:
1151:
1146:
1136:
1131:
1126:
1121:
1116:
1111:
1105:
1103:
1099:
1098:
1096:
1095:
1090:
1085:
1084:
1083:
1073:
1066:
1061:
1056:
1055:
1054:
1044:
1039:
1034:
1029:
1024:
1018:
1013:
1007:
1002:
996:
994:
988:
987:
984:
983:
981:
980:
975:
970:
965:
960:
954:
952:
943:
942:
937:
932:
926:
924:
918:
917:
915:
914:
909:
903:
901:
895:
894:
889:
887:
886:
879:
872:
864:
858:
857:
852:
851:
823:
792:
781:on 16 May 2011
762:
732:
702:
680:
655:
634:
612:
594:
593:
591:
588:
587:
586:
581:
576:
574:Stencil buffer
571:
568:Shadow mapping
565:
558:
555:
554:
553:
550:vertex shaders
546:
539:
535:
517:
514:
492:
489:
488:
487:
484:
481:
468:
465:
428:
427:
424:
421:
418:
415:
412:
409:
400:
397:
371:clipping plane
362:
361:
358:
355:
352:
349:
346:
339:
326:
323:
315:onscreen. See
309:
308:
307:
306:
303:
297:
278:stencil buffer
269:
266:
256:
255:
244:
241:
227:shadow mapping
195:
192:
181:shadow mapping
161:stencil buffer
128:
127:
42:
40:
33:
26:
24:
14:
13:
10:
9:
6:
4:
3:
2:
1320:
1309:
1306:
1305:
1303:
1288:
1285:
1284:
1282:
1278:
1272:
1269:
1267:
1264:
1260:
1257:
1255:
1252:
1250:
1247:
1246:
1245:
1242:
1241:
1239:
1237:
1233:
1227:
1224:
1222:
1219:
1217:
1214:
1212:
1209:
1207:
1204:
1202:
1199:
1197:
1196:Shadow volume
1194:
1192:
1189:
1187:
1184:
1182:
1179:
1175:
1172:
1170:
1167:
1165:
1162:
1160:
1157:
1155:
1152:
1150:
1147:
1145:
1142:
1141:
1140:
1137:
1135:
1132:
1130:
1127:
1125:
1122:
1120:
1117:
1115:
1112:
1110:
1107:
1106:
1104:
1100:
1094:
1091:
1089:
1086:
1082:
1079:
1078:
1077:
1074:
1071:
1070:Triangle mesh
1067:
1065:
1062:
1060:
1057:
1053:
1050:
1049:
1048:
1045:
1043:
1040:
1038:
1035:
1033:
1030:
1028:
1025:
1022:
1019:
1017:
1014:
1012:
1008:
1006:
1003:
1001:
1000:3D projection
998:
997:
995:
993:
989:
979:
976:
974:
971:
969:
966:
964:
961:
959:
956:
955:
953:
951:
947:
941:
940:Text-to-image
938:
936:
933:
931:
928:
927:
925:
923:
919:
913:
910:
908:
905:
904:
902:
900:
896:
892:
885:
880:
878:
873:
871:
866:
865:
862:
856:
855:
841:
834:
827:
824:
811:
807:
803:
796:
793:
780:
776:
772:
766:
763:
750:
743:
736:
733:
720:
716:
713:
706:
703:
694:
690:
684:
681:
670:on 2010-01-31
669:
665:
659:
656:
644:
638:
635:
624:. GameDev.net
623:
616:
613:
609:
605:
599:
596:
589:
585:
582:
580:
577:
575:
572:
569:
566:
564:
561:
560:
556:
551:
547:
544:
540:
536:
533:
529:
525:
521:
518:
515:
512:
507:
503:
499:
495:
494:
490:
485:
482:
479:
478:
477:
474:
466:
464:
462:
461:
456:
452:
448:
444:
440:
435:
433:
425:
422:
419:
416:
413:
410:
407:
406:
405:
398:
396:
394:
390:
385:
383:
379:
374:
372:
366:
359:
356:
353:
350:
347:
344:
340:
337:
333:
332:
331:
324:
322:
320:
319:
312:
304:
301:
300:
298:
295:
294:
293:
291:
287:
283:
279:
275:
267:
260:
253:
249:
245:
242:
239:
235:
234:
233:
230:
228:
222:
220:
219:
213:
212:
206:
200:
193:
191:
188:
187:
182:
177:
175:
171:
170:
166:
162:
157:
155:
151:
147:
146:Shadow volume
141:
140:
134:
124:
121:
113:
102:
99:
95:
92:
88:
85:
81:
78:
74:
71: –
70:
66:
65:Find sources:
59:
55:
49:
48:
43:This article
41:
37:
32:
31:
19:
1201:Shear matrix
1195:
1164:Path tracing
1149:Cone tracing
1144:Beam tracing
1064:Polygon mesh
1005:3D rendering
843:. Retrieved
839:
826:
814:. Retrieved
810:the original
805:
795:
783:. Retrieved
779:the original
774:
765:
753:. Retrieved
748:
735:
723:. Retrieved
719:the original
714:
705:
683:
672:. Retrieved
668:the original
658:
647:. Retrieved
645:. 2004-07-29
637:
626:. Retrieved
615:
607:
598:
579:Depth buffer
523:
501:
491:Optimization
473:exclusive-or
470:
467:Exclusive-or
458:
451:John Carmack
439:Sim Dietrich
436:
431:
429:
402:
393:depth buffer
388:
386:
375:
367:
363:
328:
318:optimization
316:
313:
310:
290:exclusive-or
289:
285:
281:
274:Tim Heidmann
271:
251:
247:
231:
223:
216:
211:optimization
209:
204:
201:
197:
194:Construction
186:construction
184:
178:
167:
158:
145:
144:
137:
116:
107:
97:
90:
83:
76:
64:
52:Please help
47:verification
44:
1216:Translation
1169:Ray casting
1159:Ray tracing
1037:Cel shading
1011:Image-based
992:3D graphics
973:Ray casting
922:2D graphics
455:id Software
1280:Algorithms
1134:Reflection
845:2018-02-14
816:18 October
806:GPU Gems 3
785:12 January
755:18 October
725:18 October
689:US 6384822
674:2010-09-12
649:2012-03-28
628:2010-09-12
590:References
511:M. Kilgard
399:Depth fail
325:Depth pass
286:depth fail
282:depth pass
218:depth pass
205:silhouette
165:video game
154:Frank Crow
80:newspapers
1259:rendering
1249:animation
1139:Rendering
248:front-cap
236:Find all
110:July 2024
1302:Category
1254:modeling
1181:Rotation
1119:Clipping
1102:Concepts
1081:Deferred
1047:Lighting
1027:Aliasing
1021:Unbiased
1016:Spectral
557:See also
534:in 2005.
434:method.
252:back-cap
221:below).
1308:Shading
1186:Scaling
1076:Shading
528:GeForce
263:point).
250:and/or
94:scholar
1206:Shader
978:Skybox
963:Mode 7
935:Layers
751:. 2005
698:
520:NVIDIA
500:, the
460:Doom 3
432:z-fail
389:z-pass
288:, and
246:Add a
169:Doom 3
139:Doom 3
96:
89:
82:
75:
67:
1226:Voxel
1211:Texel
912:Pixel
836:(PDF)
745:(PDF)
336:depth
208:(see
101:JSTOR
87:books
950:2.5D
818:2012
787:2022
757:2012
727:2012
341:Use
159:The
73:news
840:AMD
606:",
453:of
443:GDC
229:).
56:by
1304::
838:.
804:.
773:.
747:.
463:.
284:,
176:.
1072:)
1068:(
1023:)
1009:(
883:e
876:t
869:v
848:.
820:.
789:.
759:.
729:.
677:.
652:.
631:.
502:w
345:.
123:)
117:(
112:)
108:(
98:·
91:·
84:·
77:·
50:.
20:)
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.