Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualAshaman73

Posted 18 September 2012 - 06:58 AM

Bilateral filtering considers samples depending on two weights (often the secondary weight is more or less a boolean function).

I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the centerif(abs(depth_0-depth_4) < threshold){  color += color_0 * weight_0;  weight_sum += weight_0;}if(abs(depth_1-depth_4) < threshold){  color += color_1 * weight_1;  weight_sum += weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

You can optimize this (ie. comparing 4 samples at once).

#7Ashaman73

Posted 18 September 2012 - 06:55 AM

Bilateral filtering only considers a certain samples and not all (a secondary weight which depends on some other input). I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the centerif(abs(depth_0-depth_4) < threshold){  color += color_0 * weight_0;  weight_sum += weight_0;}if(abs(depth_1-depth_4) < threshold){  color += color_1 * weight_1;  weight_sum += weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

You can optimize this (ie. comparing 4 samples at once).

#6Ashaman73

Posted 18 September 2012 - 06:52 AM

Bilateral filtering only considers a certain samples and not all (a secondary weight which depends on some other input). I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the current texelif(abs(depth_0-depth_4) < threshold){  color += color_0 * weight_0;  weight_sum += weight_0;}if(abs(depth_1-depth_4) < threshold){  color += color_1 * weight_1;  weight_sum += weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

You can optimize this (ie. comparing 4 samples at once).

#5Ashaman73

Posted 18 September 2012 - 06:51 AM

Bilateral filtering only considers a certain samples and not all. I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the current texelif(abs(depth_0-depth_4) < threshold){  color += color_0 * weight_0;  weight_sum += weight_0;}if(abs(depth_1-depth_4) < threshold){  color += color_1 * weight_1;  weight_sum += weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

You can optimize this (ie. comparing 4 samples at once).

#4Ashaman73

Posted 18 September 2012 - 06:50 AM

Bilateral filtering only considers a certain samples and not all. I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the current texelif(abs(depth_0-depth_4) < threshold){  color += color_0 * weight_0;}if(abs(depth_1-depth_4) < threshold){  color += color_1 * weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

#3Ashaman73

Posted 18 September 2012 - 06:49 AM

Bilateral filtering only considers a certain samples and not all. I.e. when using a gaussin blur on a SSAO map, you can make it depending on the depth buffer, that is, only pixels which are on a similar depth level then the target pixel are considered for blurring. Therefor you need more or less two filter criteria (both are more or less functions). Here's some pseudo code with a simple threshold function for depth:

[source lang="cpp"]// all weights should sum up to 1.0float weight_sum = 0;// result colorvec3 color = vec3(0);// sample depth and color for 0...7, where 4 is the current texelif(abs(depth_0-depth_4)%lethreshold){  color += color_0 * weight_0;}if(abs(depth_1-depth_4)%lethreshold){  color += color_1 * weight_1;}...// consider weight sumcolor *= 1/weight_sum;[/source]

PARTNERS