• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
[GEG2] 4. Screen-Space Classification for Efficient Deferred Shading
 

[GEG2] 4. Screen-Space Classification for Efficient Deferred Shading

on

  • 739 views

 

Statistics

Views

Total Views
739
Views on SlideShare
739
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    [GEG2] 4. Screen-Space Classification for Efficient Deferred Shading [GEG2] 4. Screen-Space Classification for Efficient Deferred Shading Presentation Transcript

    • Screen-Space Classification for Efficient Deferred Shading cafe.naver.com/shader 인성민
    • Screen-Space Classification forTile based Deferred Shading Efficient
    • Overview ! GPU side G-buffer renderDepth related classification Pixel classification CPU side GPU callback Wake Index buffer generation Wait on signal Signal Tile render Sleep
    • 4x4Pixel tiles
    • 1280x720(HD) 57,600(320x180) tiles
    • classify 1. Solid shadow 2. Soft shadow 3. Shadow fade4. Light scattering 5. Sky 6. Sun light 7. Antialiasing
    • classify 1. Solid shadowDepth-Related 2. Soft shadowClassification 3. Shadow fade 4. Light scattering 5. Sky 6. Sun light 7. Antialiasing
    • classify 1. Solid shadowDepth-Related 2. Soft shadowClassification 3. Shadow fade 4. Light scattering 5. Sky Pixel 6. Sun lightClassification 7. Antialiasing
    • classify 1. Solid shadowDepth-Related 2. Soft shadowClassification 3. Shadow fade 4. Light scattering 5. Sky 6. Sun light 7. Antialiasing
    • Shadow Maps Screen Depths Screen space shadow edge(1/4 size) Screen space shadow edge(1/16 size) Screen space shadow mask
    • Shadow Maps Screen Depthspass. 1 Shadow type, Light Scattering, Shadow fade Screen space shadow edge(1/16 size) Screen space shadow mask
    • float shadowType = CalcShadowType(worldPos, depth);float lightScattering = (depth > scatteringStartDist) ? 1.0 : 0.0;float shadowFade = (depth > shadowFadeStartDist) ? 1.0 : 0.0;output.color = float4(shadowType, lightScattering, shadowFade, 0.0); Codes page 59. Listing 4.1
    • Shadow Maps Screen Depths Screen space shadow edge(1/4 size)pass. 2 Depth-related classification Screen space shadow mask
    • // Read 4 texels from 1st pass with sample offsets of 1 texel#define OFFSET_X (1.0/640.0)#define OFFSET_Y (1.0/320.0)float3 rgb = tex2D(tex, uv, float2(-OFFSET_X, -OFFSET_Y).rgb;rgb += tex2D(tex, uv, float2( OFFSET_X, -OFFSET_Y).rgb;rgb += tex2D(tex, uv, float2(-OFFSET_X, OFFSET_Y).rgb;rgb += tex2D(tex, uv, float2( OFFSET_X, OFFSET_Y).rgb;// Pack classification bits together Codes#define RAW_SHADOW_SOLID(1 << 0)#define RAW_SHADOW_SOFT(1 << 1)#define RAW_SHADOW_FADE(1 << 2)#define RAW_SHADOW_SCATTERING(1 << 3) page 59-60. Listing 4.2float bits = 0.0;if (rgb.r == 0.0) bits += RAW_SHADOW_SOLID / 255.0;else if (rgb.r == 4.0) bits += RAW_SHADOW_SOFT / 255.0;if (rgb.b != 0.0) bits += RAW_SHADOW_FADE / 255.0;if (rgb.g != 0.0) bits += RAW_SHADOW_SCATTERING / 255.0;output.color = float4(bits, 0.0, 0.0, 0.0);
    • classify 1. Solid shadow 2. Soft shadow 3. Shadow fade4. Light scattering 5. Sky Pixel 6. Sun lightClassification 7. Antialiasing
    • // Separate motion IDs and MSAA edge fragments from normals.float2 edgeAndID_frags = float2(gb1_frag0.w, gb1_frag1.w);// Classify MSAA edge (marked in high bit).float2 msaaEdge_frags = (edgeAndID_frags > (128.0 / 255.0));float msaaEdge = any(msaaEdge_frags);float3 normalDiff = gb1_frag0.xyz - gb1_frag1.xyz;msaaEdge += any(normalDiff);// Classify sky (marked with motion ID of 0 - MSAA edge bit will also be 0. Codesfloat2 sky_frags = (edgeAndID_frags == 0.0);float sky = any(sky_frags);// Classify sunlight (except in sky).float2 sunlight_frags;sunlight_frags.x = sky_frags.x ? 0.0 : -dot(normal_frags0, 4.3 page 61. Listing sunDir);sunlight_frags.y = sky_frags.y ? 0.0 : -dot(normal_frags1, sunDir);float sunlight = any(sunlight_frags);// Pack classification bits together.#define RAW_MSAA_EDGE (1 << 4)#define RAW_SKY (1 << 5)#define RAW_SUN_LIGHT (1 << 6)float bits = msaaEdge ? (RAW_MSAA_EDGE / 255.0) : 0.0;bits += sky ? (RAW_SKY / 255.0) : 0.0;bits += sunlight ? (RAW_SUN_LIGHT / 255.0) : 0.0;
    • combineDepth-Related Pixel
    • combine 32 32 64 645 32 32 96 96 …
    • combine + OR
    • index buffer Pass. 1각 타일별 사용하는 shader의 수를 구한다
    • index buffer [0] 0 0 1 3 1 … [1] 0 … [2] 0 … … … … … … …[127] 0 …ShaderTileCount Tiles (320x180)
    • index buffer [0] 1 0 1 3 1 … [1] 0 … [2] 0 … … … … … … …[127] 0 …
    • index buffer [0] 1 0 1 3 1 … [1] 1 … [2] 0 … … … … … … …[127] 0 …
    • index buffer [0] 1 0 1 3 1 … [1] 1 … [2] 0 … … … … … … …[127] 0 …
    • index buffer [0] 1 0 1 3 1 … [1] 2 … [2] 0 … … … … … … …[127] 0 …
    • index buffer Pass. 2각 shader별 index buffer의 크기를 구한다
    • index buffer [0] … [1] … [2] … … … … … … … …[127] … IBOffsets (left) Index Buffer IBPointers (right) (320x180xINDICES_PER_PRIM)
    • index buffer [0] 0 * … [1] … [2] … … … … … … … …[127] …
    • index buffer [0] 0 * … [1] n * … [2] … … … … … … … …[127] …
    • index buffer Pass. 3index buffer에 index값을 넣는다
    • Render ! Pixel tiles
    • 끝(?)
    • Optimize#1. Reduce shader count
    • 128→32 Before & After
    • 7bit→5bitSolid Shadow ↔ Soft Shadow Sky ↔ Sun Light
    • Optimize#2. Tile Coalescing
    • 10 10 18 1034 34 34 3434 18 10 1010 10 10 10
    • 10 10 18 10 3434 18 10 10 10
    • PerformanceTask PS3 PS3 Xbox360 Xbox360 Naive Classification Naive ClassificationDepth-related 0.00 1.29 0.00 0.70Pixel 0.00 ~0.00 0.00 0.69Global light pass 13.93 4.82 8.30 2.69Total(ms) 13.93 6.11 8.30 4.08
    • PerformanceTask PS3 PS3 Xbox360 Xbox360 Naive Classification Naive ClassificationDepth-related 0.00 1.29 0.00 0.70Pixel 0.00 ~0.00 0.00 0.69Global light pass 13.93 4.82 8.30 2.69Total(ms) 13.93 -7.82 6.11 8.30 4.08
    • PerformanceTask PS3 PS3 Xbox360 Xbox360 Naive Classification Naive ClassificationDepth-related 0.00 1.29 0.00 0.70Pixel 0.00 ~0.00 0.00 0.69Global light pass 13.93 4.82 8.30 2.69Total(ms) 13.93 6.11 8.30 -4.22 4.08