         float num_levels = 1 + floor(log2(maxsize));
         float mip_level = clamp(pow(roughness, 0.25) * num_levels, 0.0, 10.0);
 
-        vec3 F_env = fresnel_schlick_roughness(max(dot(N, V), 0.0), F0, roughness);
+        vec3 F_env = fresnel_schlick_roughness(max(dot(normal, V), 0.0), F0, roughness);
         vec3 kS_env = F_env;
         vec3 kD_env = 1.0 - kS_env;
         kD_env *= 1.0 - metallic;
 
         vec3 filtered = textureLod(environment_samplers[i], corrected_r, mip_level).rgb;
-        vec2 brdf  = texture(brdf_lut, vec2(max(dot(N, V), 0.0), roughness)).rg;
+        vec2 brdf  = texture(brdf_lut, vec2(max(dot(normal, V), 0.0), roughness)).rg;
 
         float refractive_index = 1.5;
-        vec3 refracted_direction = refract(V, N, 1.0 / refractive_index);
+        vec3 refracted_direction = refract(V, normal, 1.0 / refractive_index);
         vec3 corrected_refract_direction = box_correct(environments[i].extent, environments[i].position, refracted_direction, fragment.position);
         vec3 refraction = textureLod(environment_samplers[i], corrected_refract_direction, mip_level).rgb * material.transmission;
 

            vec3 L = normalize(light.position - fragment.position);
            vec3 H = normalize(V + L);

            float NdotL = max(dot(N, L), 0.0);
            float cos_dir = dot(L, -light.direction);
            float spot_effect = smoothstep(cos(light.angle / 2.0), cos(light.angle / 2.0 - 0.1), cos_dir);


        discard;
    }

      vec3 V = normalize(camera.position - fragment.position);

    vec3 F0 = vec3(0.04);
    F0 = mix(F0, albedo, metallic);
