 	surface.metalness = gbuffer2.a;
 	surface.ao = gbuffer2.g;
 	surface.matFlag = gbuffer2.r;
-	surface.Update();
+    updateSurface(surface);
 	return surface;
 }
 

	vec3 albedo;			// diffuse light absorbtion value (rgb)
	vec3 R;				// reflection vector
	vec3 F;				// fresnel term computed from f0, N and V
	void Update();
};

void Surface::Update()
{
	NdotV = abs(dot(N, V)) + 1e-5f; // avoid artifact

	albedo = baseColor.rgb * (1.0 - metalness);
	f0 = lerp(vec3(0.04), baseColor.rgb, metalness);
	R = -reflect(V, N);
	float f90 = saturate(50.0 * dot(f0, vec3(0.33,0.33,0.33)));
	F = F_Schlick(f0, f90, NdotV);
}
	
Surface createSurface(vec4 normDepth, sampler2D colorBuffer, sampler2D matInfoBuffer, in vec2 uv, in vec3 wsEyePos, in vec3 wsEyeRay, in mat4 invView)
{
	Surface surface;// = Surface();

  surface.ao = pbrProperties.g;
  surface.matFlag = pbrProperties.r;

    updateSurface(surface);
	return surface;
}

