rendering wounds in left 4 dead 2 - valve · pdf filerendering wounds in left 4 dead 2 alex...
TRANSCRIPT
![Page 1: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/1.jpg)
Rendering Wounds inLeft 4 Dead 2
Alex Vlachos, ValveMarch 9, 2010
![Page 2: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/2.jpg)
Outline
• Goals
• Technical Constraints
• Initial Prototype
• Final Solution
![Page 3: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/3.jpg)
Left 4 Dead 1 Wounds
• Built-in
• 5 variations only
• Requires texture support
• Always Fatal
![Page 4: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/4.jpg)
The PitchGray Horsfield lives for destruction
(Gray is a Visual Effects Artist at Valve, previously at Weta)
![Page 5: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/5.jpg)
Goals
• Accurate location of wounds
• Wounds match weapon strength
– Remove limbs, torso, head, half of body
• Separate wound geometry & textures
• Several active/visible wounds per model
– Shipped up to 2 active wounds
![Page 6: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/6.jpg)
Technical Constraints
• Already at memory limits on the Xbox 360
• Didn’t want heavy CPU setup
• Ideally wanted a GPU solution
• No additional base meshes except for wound geometry– Better for artists to author
– Share wound models among many infected
![Page 7: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/7.jpg)
Common Infected Variation
• Simplest infected has over 24,000 variations
• We didn’t want to add another variable to this
![Page 8: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/8.jpg)
Things We Didn’t/Couldn’t Do
• Model variations of each infected with all combinations of 1 and 2 wounds
• Use different index buffers to cull polygons –not friendly with LOD and low quality wound silhouettes
• Auto-generate new polygonal meshes with holes cut for wound models
• Author different body parts/sections with different wound variations
![Page 9: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/9.jpg)
Initial Prototype
• Use pose-space ellipsoids to cull pixels
• Fill hole with wound model
![Page 10: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/10.jpg)
Culling Inside an Ellipsoid
• Vertex Shader calculates relative distance
• Interpolate this value and clip / texkill
![Page 11: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/11.jpg)
Benefits
• No additional vertex buffer data
• Still only one draw call for full model
• Wounds are a separate draw call with their own textures:
![Page 12: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/12.jpg)
Problems
• Hard cut looked unnatural
• Wound models looked strange because they required a lip around the wound border
• Lacked blood on the clothes and skin near the border of the wound
• Required an exact geometric fit with the model
![Page 13: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/13.jpg)
Projected Texture Experiment
Try using a projected texture and use alpha to kill pixels
![Page 14: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/14.jpg)
Abdominal Wounds
• Projected texture will affect his back
• So let’s combine the texture and ellipsoid
![Page 15: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/15.jpg)
Blood Layer
• The texture projection is aligned with an axis of the ellipse
• We multiply the blood layer by a gradient to prevent the blood from spraying too far
![Page 16: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/16.jpg)
Vertex Shader Code// Subtract off ellipsoid center
float3 vLocalPosition = ( vPreSkinnedPosition.xyz - vEllipsoidCenter.xyz );
// Apply rotation and ellipsoid scale. Ellipsoid basis is the orthonormal basis
// of the ellipsoid divided by the per-axis ellipsoid size.
float3 vEllipsoidPosition;
vEllipsoidPosition.x = dot( vEllipsoidSide.xyz, vLocalPosition.xyz );
vEllipsoidPosition.y = dot( vEllipsoidUp.xyz, vLocalPosition.xyz );
vEllipsoidPosition.z = dot( vEllipsoidForward.xyz, vLocalPosition.xyz );
// Use the length of the position in ellipsoid space as input to texkill/clip
float fTexkillInput = length( vEllipsoidPosition.xyz );
// We use the xy of the position in ellipsoid space as the texture uv
float2 vTextureCoords = vEllipsoidPosition.xy;
![Page 17: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/17.jpg)
Other
• Depth-only and shadow render passes
– You don’t want phantom shadows
• Hi-Z performance issues
• Wound models are attached to base skeleton of infected model
![Page 18: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/18.jpg)
Multiple Wounds
We limited the final solution to 2 active wounds
![Page 19: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/19.jpg)
Upper & Lower Back
![Page 20: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/20.jpg)
Groin
![Page 21: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/21.jpg)
Arms & Legs
![Page 22: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/22.jpg)
Abdomen
![Page 23: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/23.jpg)
Head Wounds
![Page 24: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/24.jpg)
Half Body
![Page 25: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/25.jpg)
Axe & Sword Slashes
![Page 26: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/26.jpg)
Upper Body
![Page 27: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/27.jpg)
Stats
• Up to 54 unique wounds per model
• Each wound is only 13% of the memory cost of the old system in Left 4 Dead 1
• Vertex shader costs 15 instructions– Fill-bound, so rendering perf impacted
minimally
• Pixel Shader costs 7 instructions
![Page 28: Rendering Wounds in Left 4 Dead 2 - Valve · PDF fileRendering Wounds in Left 4 Dead 2 Alex Vlachos, Valve March 9, 2010. Outline •Goals •Technical Constraints •Initial Prototype](https://reader033.vdocuments.us/reader033/viewer/2022052708/5a771ce77f8b9ad22a8df474/html5/thumbnails/28.jpg)
Summary
• Wound models separate from base mesh
• Use pose-space ellipsoids for outer limiting cull volume
• Use projected texture for rough edges and blood layer
• Additional details about our rendering: http://www.valvesoftware.com/publications.html