Skip to content
Snippets Groups Projects
Verified Commit 4886c220 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

insides of pentagons

parent d3579908
Branches
No related tags found
No related merge requests found
...@@ -80,6 +80,15 @@ struct ReflectiveMaterial: Material { ...@@ -80,6 +80,15 @@ struct ReflectiveMaterial: Material {
void trace(const Scene& scene, const Hit& hit, const Ray& ray, const std::vector<Light*>& lights, int depth, vec3& outRadiance) override; void trace(const Scene& scene, const Hit& hit, const Ray& ray, const std::vector<Light*>& lights, int depth, vec3& outRadiance) override;
}; };
struct PortalMaterial: ReflectiveMaterial {
PortalMaterial(): ReflectiveMaterial(0, 0){
F0 = 1;
}
void trace(const Scene& scene, const Hit& hit, const Ray& ray, const std::vector<Light*>& lights, int depth, vec3& outRadiance) override {
ReflectiveMaterial::trace(scene, hit, ray, lights, depth, outRadiance);
}
};
struct Hit { struct Hit {
float t; float t;
vec3 position, normal; vec3 position, normal;
...@@ -136,6 +145,7 @@ struct Pentagon : public Intersectable { ...@@ -136,6 +145,7 @@ struct Pentagon : public Intersectable {
vec3 r4; vec3 r4;
vec3 r5; vec3 r5;
Material* material; Material* material;
Material* portal = new PortalMaterial();
Pentagon(const vec3& _r1, const vec3& _r2, const vec3& _r3, const vec3& _r4, const vec3& _r5, Material* _material) { Pentagon(const vec3& _r1, const vec3& _r2, const vec3& _r3, const vec3& _r4, const vec3& _r5, Material* _material) {
r1 = _r1; r1 = _r1;
...@@ -168,6 +178,16 @@ struct Pentagon : public Intersectable { ...@@ -168,6 +178,16 @@ struct Pentagon : public Intersectable {
hit.normal = n; hit.normal = n;
hit.material = material; hit.material = material;
hit.position = p; hit.position = p;
if (
dot(cross(r2-r1, p-r1), n) > 0.1 &&
dot(cross(r3-r2, p-r2), n) > 0.1 &&
dot(cross(r4-r3, p-r3), n) > 0.1 &&
dot(cross(r5-r4, p-r4), n) > 0.1 &&
dot(cross(r1-r5, p-r5), n) > 0.1
) {
hit.material = portal;
}
} }
return hit; return hit;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment