@@ -59,16 +59,16 @@ uniform sampler2D u_DepthMap;
59
59
uniform int u_lightLayer;
60
60
uniform vec3 u_zFar;
61
61
62
- const int lightsPerLayer = 16 ;
62
+ const uint lightsPerLayer = 16u ;
63
63
64
64
#define idxs_t uvec4
65
65
66
66
DECLARE_OUTPUT(uvec4 )
67
67
68
68
// 8 bits per light ID
69
69
void pushIdxs( in uint idx, in uint count, inout uvec4 idxs ) {
70
- idxs[count / 4 ] <<= 8 ;
71
- idxs[count / 4 ] |= idx & 0xFFu;
70
+ idxs[count / 4u ] <<= 8u ;
71
+ idxs[count / 4u ] |= idx & 0xFFu;
72
72
}
73
73
74
74
#define exportIdxs( x ) outputColor = ( x )
@@ -114,13 +114,13 @@ void main() {
114
114
115
115
idxs_t idxs = uvec4 ( 0 , 0 , 0 , 0 );
116
116
117
- uint lightCount = 0 ;
117
+ uint lightCount = 0u ;
118
118
119
119
/* Dynamic lights are put into 4 layers of a 3D texture. Since checking if we already added some light is infeasible,
120
120
only process 1 / 4 of different lights for each layer, extra lights going into the last layer. This can fail to add some lights
121
121
if 1 / 4 of all lights is more than the amount of lights that each layer can hold (16). To fix this, we'd need to either do this on CPU
122
122
or use compute shaders with atomics so we can have a variable amount of lights for each tile. */
123
- for ( uint i = u_lightLayer; i < u_numLights; i += NUM_LIGHT_LAYERS ) {
123
+ for ( uint i = uint ( u_lightLayer ) ; i < uint ( u_numLights ) ; i += uint ( NUM_LIGHT_LAYERS ) ) {
124
124
Light l = GetLight( i );
125
125
vec3 center = ( u_ModelMatrix * vec4 ( l.center, 1.0 ) ).xyz;
126
126
float radius = max ( 2.0 * l.radius, 2.0 * 32.0 ); // Avoid artifacts with weak light sources
@@ -136,7 +136,7 @@ void main() {
136
136
if ( radius > 0.0 ) {
137
137
/* Light IDs are stored relative to the layer
138
138
Add 1 because 0 means there's no light */
139
- pushIdxs( ( i / NUM_LIGHT_LAYERS ) + 1 , lightCount, idxs );
139
+ pushIdxs( ( i / uint ( NUM_LIGHT_LAYERS ) ) + 1u , lightCount, idxs );
140
140
lightCount++ ;
141
141
142
142
if ( lightCount == lightsPerLayer ) {
0 commit comments