File size: 1,023 Bytes
e78b7eb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <math.h>
#include <stdio.h>
float fresnelReflectanceAtNormal_f(float index) {
float partial = (1.0f - index) / (1.0f + index);
return partial * partial;
}
double fresnelReflectanceAtNormal_d(double index) {
double partial = (1.0 - index) / (1.0 + index);
return partial * partial;
}
float blinToBeckmann_f(float alpha) {
return sqrtf(2.0f / (alpha + 2.0f));
}
float beckmannToBlinn_f(float slope) {
return 2.0f / (slope * slope) - 2.0f;
}
double blinToBeckmann_d(double alpha) {
return sqrtf(2.0 / (alpha + 2.0));
}
double beckmannToBlinn_d(double slope) {
return 2.0 / (slope * slope) - 2.0;
}
int main() {
float xf;
double xd;
int l;
l = scanf("%f", &xf);
l = scanf("%lf", &xd);
printf("%f\n", fresnelReflectanceAtNormal_f(xf));
printf("%lf\n", fresnelReflectanceAtNormal_d(xd));
printf("%f\n", blinToBeckmann_f(xf));
printf("%lf\n", blinToBeckmann_d(xd));
printf("%f\n", beckmannToBlinn_f(xf));
printf("%lf\n", beckmannToBlinn_d(xd));
}
|