 #ifdef ENVMAP_TYPE_CUBE_UV
 
-const float cubeUV_textureSize = 1024.0;
+#define cubeUV_textureSize (1024.0)
 
 int getFaceFromDirection(vec3 direction) {
 	vec3 absDirection = abs(direction);

	return base + s * ( scale - 2.0 * texelOffset );
}

float cubeUV_maxLods3 = log2(cubeUV_textureSize*0.25) - 3.0;

vec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {
	float roughnessVal = roughness* cubeUV_maxLods3;

	return vec2(floor(mipLevel), fract(mipLevel));
}

#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)
#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)

vec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {
	mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;
