return OutputType.RGBA;
}
private Vector4 performFilter(Vector4 out, TileCacheEntry[] caches, float u, float v) {
Vector4 val = new Vector4();
float r = radius.get()/100.0f;
float weightSum = 0.0f;
float rotU = FMath.cos(FMath.PI*angle.get()/180.0f);
float rotV = FMath.sin(FMath.PI*angle.get()/180.0f);
if (weightFunction.getEnumPos() == 0 && r > 0.0f) { // Gaussian
for (int i = 0; i < numSamples.get(); i++) {
float du = (FMath.radicalInverse_vdC(2, i)*2.0f - 1.0f)*r;
float dv = (FMath.radicalInverse_vdC(3, i)*2.0f - 1.0f)*r;
// apply anisotropy
du *= (1.0f - anisotropy.get());
float nu = du*rotU - dv*rotV;
float nv = dv*rotU + du*rotV;
du = nu;
dv = nv;
float l = FMath.sqrt(du*du + dv*dv);
float w = FMath.exp(-(l/r));
if (caches != null) val.add_ip(caches[0].sample_Normalized(du+u, dv+v).mult_ip(w));
else val.add_ip(inputChannels[0].valueRGBA(du+u, dv+v).mult_ip(w));
weightSum += w;
}
} else { // Box
for (int i = 0; i < numSamples.get(); i++) {
float du = (FMath.radicalInverse_vdC(2, i)*2.0f - 1.0f)*r;
float dv = (FMath.radicalInverse_vdC(3, i)*2.0f - 1.0f)*r;
// apply anisotropy
du *= (1.0f - anisotropy.get());
float nu = du*rotU - dv*rotV;
float nv = dv*rotU + du*rotV;
du = nu;
dv = nv;
if (caches != null) val.add_ip(caches[0].sample_Normalized(du+u, dv+v));
else val.add_ip(inputChannels[0].valueRGBA(du+u, dv+v));
weightSum += 1.0f;
}
}
val.mult_ip(1.0f/weightSum);
if (out != null) out.set(val);
return val;
}