Browse Source

Update formula for albedo blending

Popov72 5 years ago
parent
commit
4a7d38a298

+ 2 - 1
src/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.fx

@@ -45,7 +45,8 @@ void albedoOpacityBlock(
     #endif
 
     #ifdef DETAIL
-        surfaceAlbedo.rgb = surfaceAlbedo.rgb * (saturate(vec3(detailColor.r) + vDetailInfos.y));
+        float detailAlbedo = 2.0 * mix(0.5, detailColor.r, vDetailInfos.y);
+        surfaceAlbedo.rgb = surfaceAlbedo.rgb * detailAlbedo * detailAlbedo; // should be pow(detailAlbedo, 2.2) but detailAlbedo² is close enough and cheaper to compute
     #endif
 
     #define CUSTOM_FRAGMENT_UPDATE_ALBEDO

+ 2 - 1
src/Shaders/ShadersInclude/pbrBlockReflectivity.fx

@@ -73,7 +73,8 @@ void reflectivityBlock(
         #endif
 
         #ifdef DETAIL
-            metallicRoughness.g = saturate(metallicRoughness.g + detailColor.b * vDetailInfos.w);
+            float detailRoughness = 2.0 * mix(0.5, detailColor.b, vDetailInfos.w);
+            metallicRoughness.g = saturate(metallicRoughness.g * detailRoughness);
         #endif
 
         #ifdef MICROSURFACEMAP

+ 1 - 1
src/Shaders/default.fragment.fx

@@ -219,7 +219,7 @@ void main(void) {
 #endif
 
 #ifdef DETAIL
-    baseColor.rgb = baseColor.rgb * (saturate(vec3(detailColor.r) + vDetailInfos.y));
+    baseColor.rgb = baseColor.rgb * 2.0 * mix(0.5, detailColor.r, vDetailInfos.y);
 #endif
 
 #define CUSTOM_FRAGMENT_UPDATE_DIFFUSE