-
Notifications
You must be signed in to change notification settings - Fork 133
LightStorage
The render pipeline stores all lights and shadow sources into buffers on the GPU. This page describes the data layout used for storing the data into those buffers.
This data is stored in a texture buffer, one for the lights and one for the shadow source. The format of those buffers is RGBA32F, so the data is grouped in block of 4 floating point components (Thats what .x, .y, .z and .w refer to).
The data offset (written as +N, e.g. +5), determines the offset of the given value. An offset of +3 means that the data is stored as the fourth float after the base offset (equal to V0.w).
Each Light is stored in the LightBuffer with 4 vec4's = 16 floats
The data layout is:
[V0.x] +0: Light Type
[V0.y] +1: IES Profile Index (or -1 for no profile)
[V0.z] +2: First Shadow Source index (or -1 for no shadows)
[V0.w] +3: Max culling radius
[V1.x] +4: Position.x
[V1.y] +5: Position.y
[V1.z] +6: Position.z
[V1.w] +7: Color.r
[V2.x] +8: Color.g
[V2.y] +9: Color.b
+10-15: [Any additional properties depending on the light type]
Null lights have a light type of 0, to indicate there is no light at that slot. They don't have any additional properties, too.
+0-9: [see above]
[V2.z] +10: Sphere Radius
+11-15: [unused]
+0-8: [see above]
[V2.z] +10: Field of View
[V2.w] +11: Direction.x
[V3.x] +12: Direction.y
[V3.y] +13: Direction.z
+14-15: [unused]
+0-8: [see above]
[V2.z] +10: Up Vector.x
[V2.w] +11: Up Vector.y
[V3.x] +12: Up Vector.z
[V3.y] +13: Right Vector.x
[V3.z] +14: Right Vector.y
[V3.w] +15: Right Vector.z
+0-8: [see above]
[V2.z] +10: Tube radius
[V2.w] +11: Tube length
[V3.x] +12: Direction.x
[V3.y] +13: Direction.y
[V3.z] +14: Direction.z
+15: [unused]
Each Shadow source is stored in the SourceBuffer with 5 vec4's = 20 floats
The data layout is:
[V0.x - V3.w] +0-16: View-Projection Matrix
[V4.x] +17: uv-coordinate x
[V4.y] +18: uv-coordinate y
[V4.z] +19: uv-coordinate width
[V4.w] +20: uv-coordinate height
Commands have the layout:
+0: [Command ID]
+1-31: [Command Data]
There are several command types:
Does nothing, gets just skipped
Stores a new light into the light data, command layout:
+0: [Command ID]
+1: [Light ID]
+2-31: [Light Data, see above]
The light id is used to figure where to write the light into the global lights storage buffer. This command basically just takes the Light Data, and writes it to the specified location.
This command just sets all of the light data to zeroes, so that the light gets a NullLight, and ignored.
+0 [Command ID]
+1: [Light ID]
+2-31: [unused]
Stores a new shadow source into the shadow source data, command layout:
+0: [Command ID]
+1: [Light ID]
+2-31: [Source Data, see above]
This command sets all of the source data to zeroes, to indicate its not further used.
+0: [Command ID]
+1: [Source ID]
+2-31: [unused]
Rendering Pipeline by tobspr (c) 2014 - 2016
For developers: