From ddd80c171528304dbe4d4fcc00638608d71568de Mon Sep 17 00:00:00 2001 From: samuncle Date: Thu, 14 Mar 2019 19:57:28 +0100 Subject: [PATCH] Fix bug with PBR roughness (was working in metal but not plastic materials --- data/shaders/combine_diffuse_color.frag | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/shaders/combine_diffuse_color.frag b/data/shaders/combine_diffuse_color.frag index 3afbec781..1d60e0792 100644 --- a/data/shaders/combine_diffuse_color.frag +++ b/data/shaders/combine_diffuse_color.frag @@ -21,6 +21,7 @@ void main() // Metallic map is stored in normal color framebuffer .w // Emit map is stored in diffuse color framebuffer.w float metallicMapValue = texture(normal_color, tc).w; + float specMapValue = texture(normal_color, tc).z; float emitMapValue = diffuseMatColor.w; float ao = texture(ssao_tex, tc).x; @@ -28,7 +29,7 @@ void main() vec3 SpecularComponent = texture(specular_map, tc).xyz; vec3 diffuse_color_for_mix = diffuseMatColor.xyz * 4.0; - vec3 metallicMatColor = mix(vec3(0.04), diffuse_color_for_mix, metallicMapValue); + vec3 metallicMatColor = mix(vec3(specMapValue), diffuse_color_for_mix, metallicMapValue); vec3 tmp = DiffuseComponent * mix(diffuseMatColor.xyz, vec3(0.0), metallicMapValue) + (metallicMatColor * SpecularComponent); vec3 emitCol = diffuseMatColor.xyz + (diffuseMatColor.xyz * diffuseMatColor.xyz * emitMapValue * emitMapValue * 10.0);