Skip to content

Commit

Permalink
Merge pull request #105 from pajama/main
Browse files Browse the repository at this point in the history
some more hlsl fixes for unity
  • Loading branch information
patriciogonzalezvivo committed Oct 12, 2023
2 parents 0061a49 + 571b615 commit 0deb997
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions color/vibrance.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ float3 vibrance(in float3 color, in float v) {
float min_color = mmin(color);
float sat = max_color - min_color;
float lum = luma(color);
return lerp(float3(lum), color, 1.0 + (v * 1.0 - (sign(v) * sat)));
return lerp(float3(lum, lum, lum), color, 1.0 + (v * 1.0 - (sign(v) * sat)));

}

float4 vibrance(in float4 color, in float v) { return float4( vibrance(color.rgb, v), color.a); }
#endif
#endif
2 changes: 0 additions & 2 deletions filter/bilateral.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ options:
#define BILATERAL_KERNEL_MAXSIZE 20
#endif

#include "bilateral/2D.hlsl"

#ifndef FNC_BILATERALFILTER
#define FNC_BILATERALFILTER

Expand Down
16 changes: 11 additions & 5 deletions math/gaussian.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ use: <float4|float3|float2|float> gaussian(<float4|float3|float2|float> d, <floa
#ifndef FNC_GAUSSIAN
#define FNC_GAUSSIAN

inline __host__ __device__ float gaussian( float d, float sigma) { return exp(-(d*d) / (2.0 * sigma*sigma)); }
inline __host__ __device__ float gaussian(float2 d, float sigma) { return exp(-( d.x*d.x + d.y*d.y) / (2.0 * sigma*sigma)); }
inline __host__ __device__ float gaussian(float3 d, float sigma) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z ) / (2.0 * sigma*sigma)); }
inline __host__ __device__ float gaussian(float4 d, float sigma) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z + d.w*d.w ) / (2.0 * sigma*sigma)); }
inline float gaussian(float d, float sigma) { return exp(-(d * d) / (2.0 * sigma * sigma)); }

#endif
inline float gaussian(float2 d, float sigma) { return exp(-(d.x * d.x + d.y * d.y) / (2.0 * sigma * sigma)); }

inline float gaussian(float3 d, float sigma) { return exp(-(d.x * d.x + d.y * d.y + d.z * d.z) / (2.0 * sigma * sigma)); }

inline float gaussian(float4 d, float sigma)
{
return exp(-(d.x * d.x + d.y * d.y + d.z * d.z + d.w * d.w) / (2.0 * sigma * sigma));
}

#endif

0 comments on commit 0deb997

Please sign in to comment.