19
4.6 Real-Time Soft Shadows with Shadow Accumulation http://ohyecloudy.com http://cafe.naver.com/shader.cafe 2009.05.11

[shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

  • Upload
    -

  • View
    1.012

  • Download
    3

Embed Size (px)

Citation preview

Page 1: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

4.6 Real-Time Soft Shadows with Shadow Accumulation

http://ohyecloudy.com

http://cafe.naver.com/shader.cafe 2009.05.11

Page 2: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Soft Shadow

penumbra(반영) 표현이 핵심이다.

Page 3: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Soft Shadow Algorithm

• Multisample approaches

–여러 광원light source 샘플로부터 hard shadow 들을 만들어서 계산한다.

• Single-sample approaches

–하나의 광원 샘플과 씬scene으로 soft shadow에 필요한 정보를 만들고 이 정보를 광원의 모든 점에 적용한다.

Page 4: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Shadow map과 다른점

Shadow map

• 광원으로부터 시야 정보visibility information를 저장.

Soft-shadow generation

• 그림자가 진 점shaded point으로부터 시야 정보가 필요.

Page 5: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

The New Algorithm Overview

• Single-sample approach

• Shadow map morph

–그림자가 진 점으로부터 시야 정보 기록.

• 젂체 광원과 가려진occluded 광원의 입체각solid

angle을 계산.

Page 6: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Assumption

• 광원은 균일한 빛을 방출emission한다.

• 표면surface은 난반사diffuse하거나 적당한 광택glossy을 가졌다.

• 광원은 조명을 받을 표면에 지나치게 가깝지 않다.

Page 7: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

From assumption

• 가린occluded 부분과 가리지 않은nonoccluded 부분의 광채radiance의 비율은 가리지 않은 부분과 그림자 진 점으로부터 보이는 광원의 총합과의 비율과 같다.

바탕으로 Shadowing Factor 를 정의

Page 8: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Shadowing factor

Page 9: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Shadowing factor 그림자 진 곳이 두 caster의 영향을 받는다.

두 caster가 서로 가리지 않는다.

한 caster가 완젂히 가려버린다.

Page 10: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

계산에 필요한 재료

Directions Set

Visible Information

Page 11: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Directions Set

Light Space View

Page 12: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Directions Set

l과 lr의 변환식

Page 13: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Visible Information

caster 하나당 lexel 하나

그림자가 진 점에서 볼 수 있는 어림잡은 최대 lexel 개수

Page 14: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

algorithm pseudo-code

set obits to zero in D for each lexel l in D for each caster c of lexel l size = (r.z-n)/(r.z-c.z)*c.z/n; lr = (n-c.z)/(r.z-c.z)*r + size*l; for each lexel l’ closer to lr than size if (l’ is in D) obit[l’]=1; DcD = 0; for each lexel l’ in D if (obit[l’]) DcD++; s = DcD / number of lexels in D;

Page 15: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

구현이 어려운 이유

• 복잡한 조건 때문에 GPU에서 구현하기 어렵다.

• 하나의 lexel에 해당하는 여러 caster가 필요한데, shadow map은 가장 가까운 caster만 저장한다.

• 몇 가지 가정을 더해서 더 갂단하고 빠르게 만든다.

Page 16: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

추가 가정

• 광원은 반지름 R을 가지는 구체sphere

• 그림자 진 곳에서 K*K 개의 lexel을 볼 수 있다.

• K는 Kernel size

Page 17: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

추가 가정

• 각 lexel마다 가장 가까운 caster만 저장

• 광원에서 가장 가까운 caster끼리 서로 가리지 않는다.

• caster끼리 서로 가리지 않는다.

앞에서 봤던 shadowing factor 공식

Page 18: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

개선된 pseudo-code

R’ = R*(r.z-n)/r.z; s = 0; for each lexel l of square K*K size = (r.z-n)/(r.z-c.z)*c.z/n; lr = (n-c.z)/(r.z-c.z)*r + size*l; if (|lr – q|<R’) s += size * size; endfor s /= R’*R’*PI/K/K

Page 19: [shaderx5] 4.6 Real-Time Soft Shadows with Shadow Accumulation

Conclusion