20
Shadow Volumes Shadow Volumes Revisited Revisited Stefan Roettger Stefan Roettger Alexander Irion Alexander Irion Thomas Ertl Thomas Ertl University of Stuttgart, University of Stuttgart, VIS Group VIS Group

Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Embed Size (px)

Citation preview

Page 1: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes RevisitedShadow Volumes Revisited

Stefan RoettgerStefan Roettger

Alexander IrionAlexander Irion

Thomas ErtlThomas Ertl

University of Stuttgart, VIS GroupUniversity of Stuttgart, VIS Group

Page 2: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Outline of the TalkOutline of the Talk

1. Motivation: Shadow volumes on PS21. Motivation: Shadow volumes on PS2

2. Shadow volumes by Crow (1977)2. Shadow volumes by Crow (1977)

3. Methods w/o stencil buffer3. Methods w/o stencil buffer

4. Demonstration movie4. Demonstration movie

5. Conclusion5. Conclusion

Page 3: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

MotivationMotivation

Shadow volumes:Shadow volumes:

+ Dynamic shadows in real-time+ Dynamic shadows in real-time

+ Utilization of graphics hardware (stencil buffer)+ Utilization of graphics hardware (stencil buffer)

Problem:Problem:

- Restricted to graphics accelerators of latest - Restricted to graphics accelerators of latest generation (no stencil buffer on Voodoo3 and generation (no stencil buffer on Voodoo3 and PS2 for example)PS2 for example)

Solution:Solution: Utilization of the screen buffer Utilization of the screen buffer

Result: Result: Shadow volumes supported by Voodoo1!Shadow volumes supported by Voodoo1!

Page 4: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

Step 1: Render scene Z-values

Page 5: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

Front face: +1

Step 2: Render shadow volume faces

Back face: -1

Page 6: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

Front face: ±0 (Depth test)Back face: ±0 (Depth test) = ±0

Page 7: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

Front face: +1Back face: ±0 (Depth test) = +1

±0

Page 8: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

Front face: +1Back face: -1 = ±0

±0+1

Page 9: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Volumes [Crow 77]

±0+1±0

Step 3: Apply shadow mask to scene

Page 10: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Methods w/o Stencil BufferMethods w/o Stencil Buffer

Idea:Idea: Compute shadow mask in screen buffer Compute shadow mask in screen buffer

Problem:Problem: dstColor := dstColor - 1 dstColor := dstColor - 1 not not available available

Solution:Solution: Instead Instead +1 +1 :: *2*2 (double values) (double values)

Instead Instead -1 -1 :: /2/2 (halve values) (halve values)

Blend functions for *2, /2:Blend functions for *2, /2:

ccdst dst := := ff**ccsrc src + + gg**ccdstdst

*2: *2: f=cf=cdstdst, c, csrcsrc=1, g=1 =1, g=1 c cdst dst := c:= cdstdst*1*1 + 1*c+ 1*cdstdst

/2: /2: f=0, g=0.5f=0, g=0.5 c cdst dst := 0 + c:= 0 + cdstdst*0.5*0.5

Page 11: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Pixel StatesPixel States

Initialize all pixels with color value 1/4Initialize all pixels with color value 1/4

1/41/4 1/21/2 11

*2*2

/2/2

*2*2

/2/2

*2 (Clamping!)*2 (Clamping!)

State changes:State changes: Point in shadow volume:Point in shadow volume: *2*2 Point in front of shadow volume:Point in front of shadow volume: no changeno change Point behind shadow solume:Point behind shadow solume: *2 , /2*2 , /2

Clamping does Clamping does notnot invalidate states! invalidate states!

States: States: 1/4 = lit, 1/2 & 1 = shadowed1/4 = lit, 1/2 & 1 = shadowed

Page 12: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Mask NormalizationShadow Mask NormalizationApply the following Apply the following operationsoperations to the shadow mask: to the shadow mask:

1/41/4 1/21/2 11

*2*2

1/21/2

1/21/2

11

11

00

00

*2*2

LightLight ShadowShadow

InvertInvert

(c:=1-c)(c:=1-c)

Page 13: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Shadow Mask ApplicationShadow Mask Application

• Black shadows:Black shadows: Multiply b/w shadow mask with Multiply b/w shadow mask with scene: render the scene with cscene: render the scene with cdst dst := c:= cdst dst * c* csrcsrc

• Ambient shadows:Ambient shadows: Render scene again to add Render scene again to add ambient lighting term with cambient lighting term with cdst dst := c:= cdstdst + c + csrcsrc

• QuickNDirty shadows:QuickNDirty shadows: Halve intensity of Halve intensity of shadowed pixels by means of normalization to shadowed pixels by means of normalization to 0.5/1 and with c0.5/1 and with cdst dst := c:= cdst dst * c* csrcsrc

Page 14: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Example: Shadow MaskExample: Shadow Mask

Page 15: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Example: NormalizationExample: Normalization

Page 16: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Example: Shadowed Scene

Page 17: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Extensions to the AlgorithmExtensions to the Algorithm

The shadow mask can also be computed in the alpha-The shadow mask can also be computed in the alpha-channel which performs even faster than the original channel which performs even faster than the original algorithm.algorithm.

Then the shadow mask can be copied efficiently into an Then the shadow mask can be copied efficiently into an alpha texture map and applied afterwards.alpha texture map and applied afterwards.

Advantages:Advantages:– Scene is rendered only once for quickndirty shadows.Scene is rendered only once for quickndirty shadows.– Computation of shadow mask with lower resolution than screen Computation of shadow mask with lower resolution than screen

buffer buffer shadow mask is rasterized much faster. shadow mask is rasterized much faster.

Page 18: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Demonstration MovieDemonstration Movie

Page 19: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

ConclusionConclusion• Efficient computation of dynamic shadows Efficient computation of dynamic shadows

possible without stencil buffer.possible without stencil buffer.• Shadow mask is computed either in screen buffer Shadow mask is computed either in screen buffer

(Voodoo1/2/3) or in alpha-channel (PS2).(Voodoo1/2/3) or in alpha-channel (PS2).• Idea:Idea: Utilize Utilize *2*2, , /2/2 operations instead of operations instead of +1+1, , -1-1..• Different modes of application: Black, ambient, or Different modes of application: Black, ambient, or

quickndirty shadows (scene rendered only once quickndirty shadows (scene rendered only once in the latter case).in the latter case).

• By copying the shadow mask into a alpha-texture By copying the shadow mask into a alpha-texture the shadow mask can be computed at lower the shadow mask can be computed at lower resoutions than the screen buffer resoutions than the screen buffer overcome overcome rasterization bottleneck.rasterization bottleneck.

Page 20: Shadow Volumes Revisited Stefan Roettger Alexander Irion Thomas Ertl University of Stuttgart, VIS Group

Thank you!Thank you!

Questions?Questions?