fix divide by zero error with JINC; hat-tip to NAVras-Z

This commit is contained in:
hunterk 2019-08-01 15:48:39 -05:00
parent 3d694820d1
commit 7ee4fe8de0
7 changed files with 38 additions and 7 deletions

View file

@ -112,7 +112,10 @@ float3 max4(float3 a, float3 b, float3 c, float3 d)
{
float4 res;
res = (x==float4(0.0, 0.0, 0.0, 0.0)) ? float4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}

View file

@ -79,7 +79,12 @@ float max4(float a, float b, float c, float d)
vec4 resampler(vec4 x)
{
vec4 res;
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}

View file

@ -79,7 +79,12 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
vec4 resampler(vec4 x)
{
vec4 res;
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}

View file

@ -79,7 +79,12 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
vec4 resampler(vec4 x)
{
vec4 res;
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}

View file

@ -79,7 +79,12 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
vec4 resampler(vec4 x)
{
vec4 res;
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}

View file

@ -40,7 +40,10 @@ vec4 l(vec4 x)
{
vec4 res;
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(pi*floatpi) : sin(x*floatpi)*sin(x*pi)/(x*x);
res.x = (x.x==0.0) ? (pi*floatpi) : sin(x.x*floatpi)*sin(x.x*pi)/(x.x*x.x);
res.y = (x.y==0.0) ? (pi*floatpi) : sin(x.y*floatpi)*sin(x.y*pi)/(x.y*x.y);
res.z = (x.z==0.0) ? (pi*floatpi) : sin(x.z*floatpi)*sin(x.z*pi)/(x.z*x.z);
res.w = (x.w==0.0) ? (pi*floatpi) : sin(x.w*floatpi)*sin(x.w*pi)/(x.w*x.w);
return res;
}

View file

@ -84,7 +84,12 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
vec4 resampler(vec4 x)
{
vec4 res;
res = (x == vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
res.x = (x.x==0.0) ? (wa*wb) : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x);
res.y = (x.y==0.0) ? (wa*wb) : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y);
res.z = (x.z==0.0) ? (wa*wb) : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z);
res.w = (x.w==0.0) ? (wa*wb) : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w);
return res;
}