From 2c70074dd745b083cdc99f38fff89e5e5f0776b3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 10 Apr 2013 20:25:03 +0200 Subject: [PATCH] Fix combinedAlpha --- files/materials/terrain.shader | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/files/materials/terrain.shader b/files/materials/terrain.shader index de90a6cf6..58146118e 100644 --- a/files/materials/terrain.shader +++ b/files/materials/terrain.shader @@ -227,7 +227,8 @@ #if !IS_FIRST_PASS -float combinedAlpha = 0.f; +// Opacity the previous passes should have, i.e. 1 - (opacity of this pass) +float previousAlpha = 1.f; #endif // Layer calculations @@ -252,7 +253,7 @@ float combinedAlpha = 0.f; #else albedo = shLerp(albedo, shSample(diffuseMap@shIterator, UV * 10).rgb, blendValues@shPropertyString(blendmap_component_@shIterator)); #endif - combinedAlpha += blendValues@shPropertyString(blendmap_component_@shIterator); + previousAlpha *= 1.f-blendValues@shPropertyString(blendmap_component_@shIterator); #endif @shEndForeach @@ -344,7 +345,7 @@ float combinedAlpha = 0.f; #if IS_FIRST_PASS shOutputColour(0).a = 1; #else - shOutputColour(0).a = min(combinedAlpha, 1.f); + shOutputColour(0).a = 1.f-previousAlpha; #endif }