From 16b94e7221ee3b779caff6acb1aae5d6c8145768 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Mon, 6 Jun 2022 15:23:41 +0200 Subject: [PATCH] IE shader compile fix (#4298) --- src/graphics/program-lib/chunks/common/frag/reproject.js | 6 +----- src/graphics/reproject-texture.js | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/graphics/program-lib/chunks/common/frag/reproject.js b/src/graphics/program-lib/chunks/common/frag/reproject.js index 89d11f1e0a3..abb1e393fb1 100644 --- a/src/graphics/program-lib/chunks/common/frag/reproject.js +++ b/src/graphics/program-lib/chunks/common/frag/reproject.js @@ -9,6 +9,7 @@ export default /* glsl */` // // When filtering: // NUM_SAMPLES - number of samples +// NUM_SAMPLES_SQRT - sqrt of number of samples // // SUPPORTS_TEXLOD - whether supports texlod is supported @@ -273,11 +274,6 @@ vec4 reproject() { vec2 sph = toSpherical(TARGET_FUNC()); vec2 sphu = dFdx(sph); vec2 sphv = dFdy(sph); - - // TODO: check this declaration works on old devices. - // might need to be placed globally or be made a #define - const float NUM_SAMPLES_SQRT = sqrt(float(NUM_SAMPLES)); - vec3 result = vec3(0.0); for (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) { for (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) { diff --git a/src/graphics/reproject-texture.js b/src/graphics/reproject-texture.js index 1df4aaead4f..501c7768876 100644 --- a/src/graphics/reproject-texture.js +++ b/src/graphics/reproject-texture.js @@ -467,6 +467,7 @@ function reprojectTexture(source, target, options = {}) { `#define SOURCE_FUNC ${sourceFunc}\n` + `#define TARGET_FUNC ${targetFunc}\n` + `#define NUM_SAMPLES ${numSamples}\n` + + `#define NUM_SAMPLES_SQRT ${Math.round(Math.sqrt(numSamples)).toFixed(1)}\n` + (device.extTextureLod ? `#define SUPPORTS_TEXLOD\n` : ''); let extensions = '';