浏览代码

Add missing term to metallic roughness formula

Gary Hsu 8 年之前
父节点
当前提交
94e083855a
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/Shaders/pbr.fragment.fx

+ 3 - 3
src/Shaders/pbr.fragment.fx

@@ -302,13 +302,13 @@ void main(void) {
 	// Diffuse is used as the base of the reflectivity.
 	// Diffuse is used as the base of the reflectivity.
 	vec3 baseColor = surfaceAlbedo.rgb;
 	vec3 baseColor = surfaceAlbedo.rgb;
 
 
-	// Drop the surface diffuse by the 1.0 - metalness.
-	surfaceAlbedo.rgb *= (1.0 - metallicRoughness.r);
-
 	// Default specular reflectance at normal incidence.
 	// Default specular reflectance at normal incidence.
 	// 4% corresponds to index of refraction (IOR) of 1.50, approximately equal to glass.
 	// 4% corresponds to index of refraction (IOR) of 1.50, approximately equal to glass.
 	const vec3 DefaultSpecularReflectanceDielectric = vec3(0.04, 0.04, 0.04);
 	const vec3 DefaultSpecularReflectanceDielectric = vec3(0.04, 0.04, 0.04);
 
 
+	// Compute the converted diffuse.
+	surfaceAlbedo.rgb = mix(baseColor.rgb * (1.0 - DefaultSpecularReflectanceDielectric.r), vec3(0., 0., 0.), metallicRoughness.r);
+
 	// Compute the converted reflectivity.
 	// Compute the converted reflectivity.
 	surfaceReflectivityColor = mix(DefaultSpecularReflectanceDielectric, baseColor, metallicRoughness.r);
 	surfaceReflectivityColor = mix(DefaultSpecularReflectanceDielectric, baseColor, metallicRoughness.r);