Skip to content

Commit

Permalink
Update bilateral_cleanup_pass.comp
Browse files Browse the repository at this point in the history
  • Loading branch information
WANG-Ruipeng committed Dec 6, 2024
1 parent 75b2db9 commit 1c7c1a5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions shaders/bilateral_cleanup_pass.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void main()
vec3 result = vec3(0.0,0.0,0.0);
float weightSum = 0.0;

if(length(centerColor) < 0.0001 || sqrt(variance) < 0.1){
if(length(centerColor) < 0.0001 || sqrt(variance) < 2.0){
imageStore(bilateralCleanupColor, imageCoords, vec4(0.0));
return;
}
Expand All @@ -66,17 +66,14 @@ void main()
if (neighborCoords.x < 0 || neighborCoords.y < 0 ||
neighborCoords.x >= imageRes.x || neighborCoords.y >= imageRes.y)
continue;
//if(imageCoords.x == 0)debugPrintfEXT("result %f, %f, %f\n",result.x,result.y,result.z);
vec4 neighborColor = imageLoad(filteredReflectionColor, neighborCoords);
if(length (neighborColor.rgb) < 0.001) continue;
//if(imageCoords.x == 0)debugPrintfEXT("neighborColor %f, %f, %f\n",neighborColor.x,neighborColor.y,neighborColor.z);
// Spatial weight
float dist2 = float(x * x + y * y);
float spatialWeight = exp(-dist2 / (2.0 * sigmaS * sigmaS));
// Range weight
float colorDiff = length(neighborColor.rgb - centerColor.rgb);
float rangeWeight = exp(-colorDiff * colorDiff / (2.0 * sigmaR * sigmaR));
//if(imageCoords.x == 0)debugPrintfEXT("rangeWeight %f\n",rangeWeight);
// Combined weight
float weight = spatialWeight * rangeWeight;
result += neighborColor.rgb * weight;
Expand All @@ -86,12 +83,8 @@ void main()
// Normalize result
if (weightSum > 0.001) {
result /= weightSum;
//debugPrintfEXT("%f/%f\n",result,weightSum);
//if(imageCoords.x == 0)debugPrintfEXT("result %f, %f, %f\n",result.x,result.y,result.z);
} else {
result = centerColor.rgb;
}
//if(imageCoords.x == 0 && length(result) > 0.001)debugPrintfEXT("%f, %f, %f\n",result.x,result.y,result.z);

imageStore(bilateralCleanupColor, imageCoords, vec4(result, 1.0));
}

0 comments on commit 1c7c1a5

Please sign in to comment.