90
Edit this text to create a Heading This subtitle is 20 points Bullets are blue They have 110% line spacing, 2 points before & after Longer bullets in the form of a paragraph are harder to read if there is insufficient line spacing. This is the maximum recommended number of lines per slide (seven). Sub bullets look like this Screen Space Decals in Warhammer 40,000: Space Marine Pope Kim Sr. Graphics Programmer Relic Entertainment (past)

Screen Space Decals in Warhammer 40,000: Space Marine

  • Upload
    pope-kim

  • View
    22.171

  • Download
    1

Embed Size (px)

DESCRIPTION

My Siggraph 2012 presentation slides on Screen Space Decals in Warhammer 40,000: Space Marine. SSD is similar to Deferred Decals, so I focused more on the problems we had and how we solved(or avoided) them

Citation preview

Page 1: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Screen Space Decals in Warhammer 40,000: Space Marine

Pope Kim Sr. Graphics Programmer

Relic Entertainment (past)

Page 2: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Traditional Decals

Sometime between 2008 and 2009, I was given a task

to implement a decal system

So I researched what other games are doing

Quick 2 min review on shooting a bullet against a wall

Page 3: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

A Wall with 4 Verts

Page 4: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Bullet Hits Here

Page 5: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Want to Draw a Dent Texture

Page 6: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

But How?

Draw this texture at the collision point

To draw a texture, we need a mesh

So let’s draw a textured rectangle mesh

But how can we generate the rectangle mesh that fits?

Page 7: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Find Smallest Mesh Patch Covering It

Page 8: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Duplicate the Mesh Patch

Page 9: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

And Draw

Page 10: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Two Traditional Solutions

1. (very easy) Increase the resolution of underlying

geometry

2. (not so easy) Magically calculate correct UV for each

verts

Page 11: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

1. Wall with Many Verts

Page 12: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

2. Calculate Correct UVs

(-4.5, -3.2) (3.4, -3.2)

(-4.5, 4) (3.4, 4)

(0, 0)

(1, 1)

Page 13: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Still Problems

1. Increase the resolution of underlying geometry

– Slower to iterate

– More memory foot print

2. Wasted rasterized area = too much overdraw

– Edge of textures must be transparent

– Wasted rasterized area = too much overdraw

– UV calculation is tricky with complex geometries

Page 14: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

UV Calculation is Not Easy

How would you

calculate decals UVs

from this statue?

Page 15: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Brilliant Idea?

So you would think we made Screen Space Decal to

solve these problems?

Page 16: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Brilliant Idea?

So you would think we made Screen Space Decal to

solve these problems?

NO.

Page 17: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Brilliant Idea?

So you would think we made Screen Space Decal to

solve these problems?

NO.

The old way was simply too hard for me….

But SSD ended up solving these problems.

Page 18: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Screen Space Decals (SSD)

Similar techniques were introduced by other developers

in the recent years

Deferred Decals (Jan Krassnigg, 2010)

Volume Decals (Emil Persson, 2011)

SSD was developed independently, but the

implementation details is very similar

So a quick review

More on how we used SSD and solved the problems

with SSD

Page 19: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

SSDs in Space Marine

Not just for FX

It's literally used everywhere:

Blood splat on the wall or ground

Stone wall decoration

Burnt mark on concrete slate

Ork painting

Rubble piles on the ground

Bullet holes

Explosion damage

......and list goes on

Yup, environment artists loved it!

Page 20: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window SSD ON

Page 21: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window SSD OFF

Page 22: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Implementation Details

1. Draw underlying geometries onto scene

2. Rasterize a SSD box

3. Read the scene depth for each pixel

4. Calculate 3D position from the depth

5. If this position is outside of the SSD box, reject

6. Otherwise, draw the pixel with the decal texture

Page 23: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Given This Scene

Page 24: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window We Want to Draw This

Page 25: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 1. draw underlying geometries

Page 26: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 2. rasterizer a SSD Box

Page 27: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 2. rasterizer a SSD Box

No not this!

We want to use it as a

projection box

Page 28: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 3. read scene depth for each pixel

Page 29: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

4. calculate 3D position from depth

float2 screenPosition = clipPosition.xy / clipPosition.w;

float2 depth_uv = screenPosition * float2(0.5f, -0.5f)

+ float2(0.5f, 0.5f);

depth_uv += ScreenDimension.zw;

float sceneDepth = tex2D(DepthMap, depth_uv).r;

float4 scenePosView = float4(clipPosition.xy * sceneDepth

/ (Deproject.xy * clipPosition.w), -depth, 1);

Half-pixel Offset Basically

Deproject.X = ProjectionMatrix.M11;

Deproject.Y = ProjectionMatrix.M22;

Page 30: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window

INSIDE

OUTSIDE

OUTSIDE

5. if outside of SSD box, reject

Page 31: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

5. if outside of the SSD box, reject

• Simply transform the position to object space

• Then anything bigger than 0.5 is outside

position = mul(scenePosView, InvWorldView);

clip(0.5f - abs(position.xyz));

Page 32: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 6. Otherwise, draw decal

// Decal Texture UV

float2 uv = position.xz;

uv += 0.5f;

Page 33: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Now Lighting is Free

Without SSD

Page 34: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Now Lighting is Free

With SSD

Page 35: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window and combiner pass is same

Page 36: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window and combiner pass is same

Page 37: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window and combiner pass is same

Page 38: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Mix-n-Match

Artists can choose not to draw decals either in Gbuffer

or combiner pass

Another free gift from light-prepass renderer

Page 39: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Both Gbuffer and Combiner

Page 40: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Only Gbuffer

Page 41: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Only Combiner

Page 42: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (both)

Page 43: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (both)

Page 44: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (GBuffer)

Page 45: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (GBuffer)

Page 46: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (Combiner)

Page 47: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

More Examples (Combiner)

Page 48: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Artist Control

Artists make *.ssdecal file,

which is just an XML

In level editor, artists can

drag and drop any SSD

From there, it’s

WYSIWYG & tweakable

per instance

Page 49: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Problems & Our Solutions

1. Alpha Blending

2. Dynamic Objects

3. Side Stretching

4. Clipped Decals

5. Performance

Page 50: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

1. Alpha Blending(Normal)

• Transparent objects in combiner pass are fine

• Transparent objects in Gbuffer are NOT

– Originally just alpha test

– Later enabled with Best Fit Normal by Crytek

– 3 months later, found a bug in our implementation of Best Fit

Normal: just same as our old normal buffer

– Artists never complained about weird normal blending. So we are

still doing it

– Mathematically wrong, but whatever

Page 51: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

1. Alpha Blending(Spec Power)

• Alpha channel of Gbuffer is specular power

• Cannot simply use normal alpha blending

– alpha output from SSD shader is used for RGB(normal) blending

– Solution: Blend Factor!

AlphaBlendFunction = BlendFunction.Add;

AlphaSourceBlend = Blend.BlendFactor;

AlphaDestinationBlend = Blend.InverseSourceAlpha;

BlendFactor = ssd.SpecularPower / 255.0f;

Page 52: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 1. Alpha Bleding(Spec Power)

Page 53: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 1. Alpha Bleding(Spec Power)

Power = 128

Page 54: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 1. Alpha Bleding(Spec Power)

Power = 128

Power = 40

Page 55: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 2. Dynamic Objects

Page 56: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 2. Dynamic Objects

Page 57: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

2. Dynamic Objects

• We could’ve attached the decal on moving objects

• But skinned mesh(e.g, ork arms) is still a problem

• So we simply didn’t draw any decals on dynamic objects

• Used a simple stencil buffer technique

Page 58: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window Stencil

Page 59: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 2. Dynamic Objects

Page 60: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 3. Side Stretching

Page 61: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

3. Side Stretching

• Happens when SSD box’s projection surface is not

completely inside of underlying geometry

• Tried different ways

• But ended up doing rejection based on the angle

difference between decal box and underlying normal

from GBuffer

Page 62: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 3. Side Stretching

90 degree

Page 63: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

3. Side Stretching

Anything above this

degree will be clipped

180 degree means no

clipping based on angle

We found 60 degree

works generally great

Page 64: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

3. Side Stretching

1. Find box’s orientation In Vertex Shader:

output.Orientation = normalize(WorldView[1].xyz);

2. gNormalThreashold is cos(degree)

3. Read GBufferNormal and clip in Pixel Shader

float3 normal = DecodeGBufferNormal( tex2D(

GNormalMap, depth_uv ) );

clip(dot(normal, orientation) - gNormalThreshold);

Page 65: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

3. Side Stretching

• Alternatives we tried instead of hard clip

– smoothly fade away based on angle between box orientation and

vertex normal: looks horrible on “round” pipes

– smoothly fade away based on angle between box orientation and

Gbuffer normal

• makes everything a bit too faint for existing arts

• With noisy gbuffer, artists liked hard clip more

• Still worth trying for your games

Page 66: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

4. Clipped Decals

• Doesn’t happen often environment decals

– Thin decals carefully placed for performance reason

• Happens often with big FX explosion craters

– When camera is inside of a decal box

– No rasterization

Page 67: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (OK)

Page 68: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (OK)

Page 69: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (BAD)

Page 70: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (BAD)

Page 71: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

4. Clipped Decals(Solution)

• When camera is colliding with a decal

• We draw backface with flipped z-test, instead

• Bad for Performance

– No Hi-Z

– But mostly problem with FX decals and we have an “amazing” way

of solving this (see next slides)

Page 72: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (Drawing Backface)

Page 73: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 4. Clipped Decal (Drawing Backface)

Page 74: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

5. Performance

• Avoid rasterizing pixels that will be rejected

• Avoid turning off early-Z with flipped Z-test

• So basically make decals very thin

– Environmental Decals are easy to solve

– FX Decals are not so easy

• As a result, Space Marine always runs at 30+ FPS

except when FX Decals go crazy

Page 75: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

Two ways of drawing this

Page 76: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

Thick

Page 77: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

And Thin

Page 78: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

PS Operations Wasted

Page 79: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

A lot of Orks throw explosive stuff

Page 80: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

Which leaves large decals like this

Page 81: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

Which leaves large decals like this

Sometimes 5 of them

stacked together

Page 82: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

Which leaves large decals like this

Sometimes 5 of them

stacked together

Almost 5 fullscreen passes

= only time we go down to

25 FPS

Our Solution?

Page 83: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

THIS!

Page 84: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

THIS!

So much overlay!

So many particles!

Page 85: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

THIS!

So much overlay!

So many particles!

don’t even notice it’s slow!

Page 86: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window 5. Performance

THIS!

So much overlay!

So many particles!

don’t even notice it’s slow!

Was not intentional,

but saved us

Page 87: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Special Thanks

• Relic Entertainment for allowing me to present this

• Space Marine rendering programmers

• Space Marine artists for producing amazing content and

pushing us to do more work!

Page 88: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

References

• ENGEL, W. 2009, Designing a Renderer for Multiple Lights –

The Light Pre-Pass Renderer. In ShaderX7: Advanced

Rendering Techniques, Charles River Media

• KAPLANYAN A. 2010, CryEngine 3: Reaching the Speed of

Light, Siggraph 2011

• KRASSNIGG, J. 2010. A Deferred Decal Rendering

Technique. In Game Engine Gems 1, Jones and Barlett

• PERSSON, E. 2011. Volume Decal. In GPU Pro 2, A K Peters

Page 89: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

Got Questions?

• More info on Space Marine rendering engine:

http://www.popekim.com/2011/11/slides-rendering-

tech-of-space-marine.html

• Twitter: @BlindRenderer

• E-mail: [email protected]

Page 90: Screen Space Decals in Warhammer 40,000: Space Marine

Edit this text to create a Heading

This subtitle is 20 points

Bullets are blue

They have 110% line spacing, 2 points before & after

Longer bullets in the form of a paragraph are harder to

read if there is insufficient line spacing. This is the

maximum recommended number of lines per slide

(seven).

Sub bullets look like this

This slide has a 16:9 media window