@@ -59,16 +59,16 @@ uniform sampler2D u_DepthMap;
5959uniform int u_lightLayer;
6060uniform vec3 u_zFar;
6161
62- const int lightsPerLayer = 16 ;
62+ const uint lightsPerLayer = 16u ;
6363
6464#define idxs_t uvec4
6565
6666DECLARE_OUTPUT(uvec4 )
6767
6868// 8 bits per light ID
6969void 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;
7272}
7373
7474#define exportIdxs( x ) outputColor = ( x )
@@ -114,13 +114,13 @@ void main() {
114114
115115 idxs_t idxs = uvec4 ( 0 , 0 , 0 , 0 );
116116
117- uint lightCount = 0 ;
117+ uint lightCount = 0u ;
118118
119119 /* Dynamic lights are put into 4 layers of a 3D texture. Since checking if we already added some light is infeasible,
120120 only process 1 / 4 of different lights for each layer, extra lights going into the last layer. This can fail to add some lights
121121 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
122122 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 ) ) {
124124 Light l = GetLight( i );
125125 vec3 center = ( u_ModelMatrix * vec4 ( l.center, 1.0 ) ).xyz;
126126 float radius = max ( 2.0 * l.radius, 2.0 * 32.0 ); // Avoid artifacts with weak light sources
@@ -136,7 +136,7 @@ void main() {
136136 if ( radius > 0.0 ) {
137137 /* Light IDs are stored relative to the layer
138138 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 );
140140 lightCount++ ;
141141
142142 if ( lightCount == lightsPerLayer ) {
0 commit comments