Skip to content

Commit ac3a76a

Browse files
committed
computeLight_fp: fix compilation when r_highPrecisionRendering is disabled
1 parent 4e2df0f commit ac3a76a

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/engine/renderer/glsl_source/computeLight_fp.glsl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,30 +167,34 @@ void computeLight(in vec3 lightColor, vec4 diffuseColor, inout vec4 color) {
167167
#if defined(r_realtimeLighting) && r_realtimeLightingRenderer == 1
168168
#if defined(HAVE_EXT_texture_integer) && defined(r_highPrecisionRendering)
169169
const int lightsPerLayer = 16;
170-
uniform usampler3D u_LightTilesInt;
170+
#define lightTilesSampler_t usampler3D
171+
#define lightTilesUniform u_LightTilesInt
171172
#define idxs_t uvec4
172-
idxs_t fetchIdxs( in vec3 coords, in usampler3D u_LightTilesInt ) {
173-
return texture3D( u_LightTilesInt, coords );
173+
idxs_t fetchIdxs( in vec3 coords, in lightTilesSampler_t lightTilesUniform ) {
174+
return texture3D( lightTilesUniform, coords );
174175
}
175176
int nextIdx( inout idxs_t idxs ) {
176177
uvec4 tmp = ( idxs & uvec4( 3 ) ) * uvec4( 0x40, 0x10, 0x04, 0x01 );
177178
idxs = idxs >> 2;
178179
return int( tmp.x + tmp.y + tmp.z + tmp.w );
179180
}
180-
#else // !HAVE_EXT_texture_integer
181+
#else // !HAVE_EXT_texture_integer || !r_highPrecisionRendering
181182
const int lightsPerLayer = 4;
182-
uniform sampler3D u_LightTiles;
183+
#define lightTilesSampler_t sampler3D
184+
#define lightTilesUniform u_LightTiles
183185
#define idxs_t vec4
184-
idxs_t fetchIdxs( in vec3 coords ) {
185-
return texture3D( u_LightTiles, coords ) * 255.0;
186+
idxs_t fetchIdxs( in vec3 coords, in lightTilesSampler_t lightTilesUniform ) {
187+
return texture3D( lightTilesUniform, coords ) * 255.0;
186188
}
187189
int nextIdx( inout idxs_t idxs ) {
188190
vec4 tmp = idxs;
189191
idxs = floor(idxs * 0.25);
190192
tmp -= 4.0 * idxs;
191193
return int( dot( tmp, vec4( 64.0, 16.0, 4.0, 1.0 ) ) );
192194
}
193-
#endif // HAVE_EXT_texture_integer
195+
#endif // !HAVE_EXT_texture_integer || !r_highPrecisionRendering
196+
197+
uniform lightTilesSampler_t lightTilesUniform;
194198

195199
const int numLayers = MAX_REF_LIGHTS / 256;
196200

@@ -246,10 +250,11 @@ void computeDynamicLight( int idx, vec3 P, vec3 normal, vec3 viewDir, vec4 diffu
246250

247251
#if defined(USE_REFLECTIVE_SPECULAR)
248252
void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4 material,
249-
inout vec4 color, in usampler3D u_LightTilesInt, in samplerCube u_EnvironmentMap0, in samplerCube u_EnvironmentMap1 )
253+
inout vec4 color, in lightTilesSampler_t lightTilesUniform,
254+
in samplerCube u_EnvironmentMap0, in samplerCube u_EnvironmentMap1 )
250255
#else // !USE_REFLECTIVE_SPECULAR
251256
void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4 material,
252-
inout vec4 color, in usampler3D u_LightTilesInt )
257+
inout vec4 color, in lightTilesSampler_t lightTilesUniform )
253258
#endif // !USE_REFLECTIVE_SPECULAR
254259
{
255260
vec2 tile = floor( gl_FragCoord.xy * (1.0 / float( TILE_SIZE ) ) ) + 0.5;
@@ -260,7 +265,7 @@ void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4
260265
#endif
261266

262267
for( int layer = 0; layer < numLayers; layer++ ) {
263-
idxs_t idxs = fetchIdxs( tileScale * vec3( tile, float( layer ) + 0.5 ), u_LightTilesInt );
268+
idxs_t idxs = fetchIdxs( tileScale * vec3( tile, float( layer ) + 0.5 ), lightTilesUniform );
264269
for( int i = 0; i < lightsPerLayer; i++ ) {
265270
int idx = numLayers * nextIdx( idxs ) + layer;
266271

src/engine/renderer/glsl_source/lightMapping_fp.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ void main()
188188
// Blend dynamic lights.
189189
#if defined(r_realtimeLighting) && r_realtimeLightingRenderer == 1
190190
#if defined(USE_REFLECTIVE_SPECULAR)
191-
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTilesInt,
191+
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, lightTilesUniform,
192192
u_EnvironmentMap0, u_EnvironmentMap1);
193193
#else // !USE_REFLECTIVE_SPECULAR
194-
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTilesInt);
194+
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, lightTilesUniform);
195195
#endif // !USE_REFLECTIVE_SPECULAR
196196
#endif
197197

0 commit comments

Comments
 (0)