Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int y = 0; y < H; ++y) {
- for (int x = 0; x < W; ++x) {
- RTCRay ray;
- float j = x - W/2.0 + 0.5;
- float i = y - H/2.0 + 0.5;
- auto direction = camera_dir + j * dx + i * dy;
- memcpy(ray.org, &camera_pos, sizeof(camera_pos)); //ray.org = camera_pos;
- memcpy(ray.dir, &direction, sizeof(direction)); //ray.dir = camera_dir;
- ray.tnear = 0.00001f;
- ray.tfar = 100000000.0f;
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
- rtcIntersect(main_scene, ray);
- if (ray.geomID != RTC_INVALID_GEOMETRY_ID) {
- glm::vec3 norm(ray.Ng[0], ray.Ng[1], ray.Ng[2]);
- norm = glm::normalize(norm);
- norm = -norm;
- auto worldLight = 0.5f;
- auto intensity = -glm::dot(norm, light);
- intensity = glm::clamp(intensity, 0.0f, 1.0f);
- auto white = glm::vec3(255.0f, 255.0f, 255.0f);
- auto color = white * (worldLight + intensity) / (worldLight + 1.0f);
- //out << 255 << " " << 255 << " " << 255 << "\n";
- out << (int)color.x << " " << (int)color.y << " " << (int)color.z << "\n";
- //std::cout << color.x << " " << color.y << " " << color.z << " ";
- //out << depthmap.x << ' ' << depthmap.y << ' ' << depthmap.z << '\n';
- }
- else { out << 0 << " " << 130 << " " << 200 << "\n"; }
- }
Advertisement
Add Comment
Please, Sign In to add comment