Skip to content

LightStorage

tobspr edited this page Nov 24, 2015 · 22 revisions

LightStorage

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: Position.x
[V0.w] +3: Position.y
[V1.x] +4: Position.z
[V1.y] +5: Color.r
[V1.z] +6: Color.g
[V1.w] +7: Color.b
       +8-15: [Any additional properties depending on the light type]

NullLights

Null lights have a light type of 0, to indicate there is no light at that position. They don't have any additional properties, too.

PointLights

       +0-7: [see above]
[V2.y] +8: Radius
[V2.z] +9: Inner Radius (For area PointLights)
       +10-15: [unused]

SpotLights

       +0-7: [see above]
[V2.y] +8:   Radius
[V2.z] +9:   Angle
[V2.w] +10:  Direction.x
[V3.x] +11:  Direction.y
[V3.y] +12:  Direction.z
       +13-15: [unused]

GPU Commands:

Commands have the layout:

+0:    [Command ID]
+1-31: [Command Data]

There are several command types:

CMD_INVALID

Does nothing, gets just skipped

CMD_STORE_LIGHT

Stores a new light into the light data, command layout:

+0:    [Command ID]
+1:    [Light ID]
+2-17: [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.

CMD_REMOVE_LIGHT

+0     [Command ID]
+1:    [Light ID]

This command just sets all of the light data to zeroes, so that the light gets a NullLight, and ignored.