Grass Using DirectX11 in Port
Grass Using DirectX11 in Port
u s i n g D i r e c t X 11 i n
GRID Autosport
Richard Kettlewell
Codemasters
M O T I VAT I O N
High density
Keep all data on GPU, for efficiency
Interaction
Wind
Deformation
OUR APPROACH
Generate
Populate Append Buffer with blades of grass
Render
Read Append Buffer
Construct geometry in Vertex Shader
Rasterise using Alpha-To-Coverage
No sorting required
ART PROCESS
Wastes resolution
Simplest approach given time constraints
UV mapping onto terrain would be better
Doesn’t scale well for large point-to-point tracks
G E N E R AT I N G G R A S S
Scissor Rectangle
Create bounding box from circle segment
View position
2 extents
LODs
Vital for performance
Distance based
Each LOD discards increasing amounts of grass
Remaining blades are scaled up to fill gaps
G E N E R AT I N G G R A S S
LODs
Feather distances randomly, to break up transitions
Randomise distance calculation
Fade grass height towards zero over last 15%
R A N D O M I S AT I O N
Used for
Rotation
Position
Scale
Varying Albedo
Etc
APPEND BUFFER
// buffer
RWBuffer<uint> g_drawInstancedBuffer : register( u0 );
[numthreads( 1, 1, 1 )]
void cp()
{
g_drawInstancedBuffer[ 0 ] = 6u; // vertexCountPerInstance
g_drawInstancedBuffer[ 1 ] = numInstances; // instanceCount
g_drawInstancedBuffer[ 2 ] = 0u; // startVertexLocation
g_drawInstancedBuffer[ 3 ] = 0u; // startInstanceLocation
}
DrawInstancedIndirect
// buffer
RWBuffer<uint> g_drawInstancedBuffer : register( u0 );
[numthreads( 1, 1, 1 )]
void cp()
{
g_drawInstancedBuffer[ 0 ] = 6u * numInstances;// vertexCountPerInstance
g_drawInstancedBuffer[ 1 ] = 1u; // instanceCount
g_drawInstancedBuffer[ 2 ] = 0u; // startVertexLocation
g_drawInstancedBuffer[ 3 ] = 0u; // startInstanceLocation
}
I N I T I A L R E S U LT S
GEOMETRY OR FINS?
Solution
Read shadow cascades directly
SSAO
Solution
Use depth buffer to compare 2 sample points
Read SSAO from sample with furthest depth value
Solves car occluding grass
SELF OCCLUSION
Flowers
Meshes
Gravel / small rocks
Improve art authoring pipeline
World space map is naïve, wastes texture space
Translucency
WE ARE HIRING!
http://www.codemasters.com/uk/working-for-us/southam/
THANKS FOR LISTENING!
Questions?