             locations.push loc
 
         if (loc = gl.getUniformLocation program, 'unflodfactor')?
-            if not has_probe++
-                code.push var_probe
-            code.push "gl.uniform1f(locations[#{locations.length}],
+            probe_code.push "gl.uniform1f(locations[#{locations.length}],
                 probe&&probe.lodfactor);"
             locations.push loc
 

                gl.uniform4f(locations[#{locations.length}],
                v.x, v.y, v.z, v.w);"
            locations.push loc

        # detect presence of any of all the unhandled uniforms in the shader
        @unfs = {}

        # PBR uniforms are not given as parameters,
        # so we have to figure out if they're present
        # by getting their locations
        probe_code = []
        coeff_code = []

        for i in [0..8]
            unf = 'unfsh'+i
            loc = gl.getUniformLocation program, unf
            if loc?
                coeff_code.push "gl.uniform3fv(locations[#{locations.length}],
                    coefs[#{i}]);"
                locations.push loc

        if coeff_code.length != 0
            probe_code.push \
                # NOTE: If there's probe, there's ALWAYS a background probe
                'var cubemap = probe.cubemap||scene.background_probe.cubemap;',
                'if(cubemap!=null){',
                coeff_code...,
                '}'

        if (loc = gl.getUniformLocation program, 'unfbsdfsamples')?
            code.push "var samples = scene.bsdf_samples;"
