18
Soft Particles Petter Börjesson, Mattias Thell

Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Embed Size (px)

Citation preview

Page 1: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Soft ParticlesPetter Börjesson, Mattias Thell

Page 2: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Particle Effects

• Smoke, fire, explosions, clouds, etc

• Camera-aligned 2D quads– Gives the illusion of a 3D volume

Page 3: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Illusion breakers

• Intersection with world geometry

Page 4: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

To the rescue!

• Soft Particles– Soften the edges

• Use depth information to blend the sprite with the background

Page 5: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Compare Z values

• Compare Sprite Z vs World Z

• Check distance and blendif needed

Page 6: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Blending

• Simple approach:D = saturate((Zscene – Zparticle) * scale)

• Can produce artifacts

• Better approach:D = 0.5 * saturate(2*X)Contrast

Where X =1 – input if input > 0.5

Input otherwise

Page 7: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Depth Values

• How do we get depth information?

• Paper presents two ways:– Access depth buffer in pixel shader (DX 10)– Use a render target to read depth information

Page 8: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Read Z in pixel shader

Vertex Shader

Geo. Shader

Pixel Shader

Depth Buffer

Color Buffer

Pass 1

Vertex Shader

Geo. Shadercreates sprites

Pixel Shader

Color Buffer

Pass 2

Sprite Z

Scene Z

Page 9: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Render target

Vertex Shader

Geo. Shader

Pixel Shader

Depth Buffer

Color Buffer

Pass 1

Vertex Shader

Geo. Shadercreates sprites

Pixel Shader

Color Buffer

Pass 2

Sprite Z

Scene Z

Render Target

Page 10: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

2D Particles with depth

• Store extra depth values in spritetexture

• During comparisonadd extra depth

Page 11: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

2D Particles with depth

Billboards Billboards with depth

Page 12: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Volumetric Particles

• Enclose sprite in an imaginary sphere and trace rays through each pixel.

Sprite

Sphere

Ray

Camera

Page 13: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Volumetric Particles

• Find intersections with the sphere and step through.

Sprite

Sphere

Ray

Camera

Page 14: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Volumetric Particles

• Stop if we collide with the depth buffer.• Do blending as before.

Ray

Camera

Depth buffer

Page 15: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Volumetric Particles

Billboards with depth Volumetric

Page 16: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Demo!

Page 17: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Performance

• FPS with GTX 260 – 1280x1024

SoftHard

Mountain 215 215

Billboard 480 360

Tank demo:

With depth 420 330

Volumetric 65 60

Page 18: Soft Particles Petter Börjesson, Mattias Thell. Particle Effects Smoke, fire, explosions, clouds, etc Camera-aligned 2D quads – Gives the illusion of

Questions?