13 __device__
virtual bool scatter(
const ray &r_in,
const hit_record& rec,
vec3 &att,
ray &scat, curandState* local_rand_state)
const=0;
22 __device__
virtual bool scatter(
const ray& r_in,
const hit_record& rec,
vec3& att,
ray& scat, curandState* local_rand_state)
const {
23 vec3 rand_V=(rec.n+rec.p+random_unit_sphere(local_rand_state));
24 scat =
ray(rec.p,(rand_V-rec.p));
35 __device__
metal(
const vec3 &a,
float f) {
43 __device__
virtual bool scatter(
const ray &r_in,
const hit_record& rec,
vec3& att,
ray& scat, curandState* local_rand_state)
const {
44 vec3 ref = reflect(r_in.direction.normalize(),rec.n);
45 scat =
ray(rec.p, ref + random_unit_sphere(local_rand_state) * fuzz);
47 return rec.n.dot(scat.direction) > 0.0f;
58 __device__
virtual bool scatter(
const ray& r_in,
const hit_record& rec,
vec3& att,
ray& scat, curandState* local_rand_state)
const {
61 att =
vec3(1.0, 1.0, 1.0);
62 vec3 reflected = reflect(r_in.direction, rec.n);
66 if (r_in.direction.dot(rec.n) > 0.0f) {
67 norm_out = rec.n * -1.0f;
69 cos = (idx * ((r_in.direction.dot(rec.n)) / (r_in.direction.magnitude())));
74 cos = (((r_in.direction.dot(rec.n)) / (r_in.direction.magnitude())) * -1.0f);
77 if (refraction(r_in.direction, norm_out, ni_nt, refracted)) {
78 prob_ref = schlick(cos, idx);
84 if (curand_uniform(local_rand_state) < prob_ref) {
85 scat =
ray(rec.p, reflected);
88 scat =
ray(rec.p, refracted);
Definition: material.h:52
Definition: material.h:11
Definition: material.h:16