raytracing

Rotating a pinhole camera in 3D

自作多情 提交于 2019-12-12 03:24:12
问题 I am trying to rotate a pinhole camera in 3D space. I have previously raytraced a room. As good practice I have first done the maths and the tried to program the maths in c++. // Camera position vec3 cameraPos(0, 0, -19); // Rotate camera float& yaw; vec3 c1(cos(yaw), 0, sin(yaw)); vec3 c2(0, 1, 0); vec3 c3(-sin(yaw), 0, cos(yaw)); glm::mat3 R(c1, c2, c3); What I have done to rotate the camera is this: if (keystate[SDLK_LEFT]) { //cameraPos.x -= translation; if (yaw > 0) { yaw = 0.01; } cout

Detecting light projections in 2D space using C#

微笑、不失礼 提交于 2019-12-12 02:43:50
问题 A light source is an entity in 2D space that sits in a single coordinate. There are multiple light sources around in various locations and each gives off 8 rays of light in directions N, S, E, W, NW, NE, SW, SE . The coordinates of all lights are known. Given a random point (x, y) , I need to determine if it is being hit by a ray of light. int width = 10000; int height = 10000; List<Point> lights = a bunch of randomly placed light sources. Point position = new Point(8888, 5555); Now I need to

Ray tracer reflections grainy

左心房为你撑大大i 提交于 2019-12-11 10:39:42
问题 I just implemented reflections in my ray tracer, here is the code that handles the reflections, however i have all my code uploaded to a github repository for better reading: Color finalColor = closestObjectMaterial.GetColor() * AMBIENTLIGHT; // Add ambient light to the calculation // Reflections if(closestObjectMaterial.GetSpecular() > 0 && closestObjectMaterial.GetSpecular() <= 1) { Vector scalar = closestObjectNormal * (closestObjectNormal.Dot(intersectingRayDir.Negative())); Vector

Pointers to Derived Class Objects Losing vfptr

可紊 提交于 2019-12-11 10:01:55
问题 To begin, I am trying to write a run-of-the-mill, simple Ray Tracer. In my Ray Tracer, I have multiple types of geometries in the world, all derived from a base class called "SceneObject". I've included the header for it here. /** Interface for all objects that will appear in a scene */ class SceneObject { public: mat4 M, M_inv; Color c; SceneObject(); ~SceneObject(); /** The transformation matrix to be applied to all points of this object. Identity leaves the object in world frame. */ void

Raytracing - Ray/Triangle Intersection

痴心易碎 提交于 2019-12-11 09:13:43
问题 I am having an issue with my algorithm to check if my ray intersect a 3D triangle. It seems to be still drawing in the circle behind it(top left hand corner). I can't seem to find out where in my code is causing this slight error. bool Mesh::intersectTriangle(Ray const &ray, Triangle const &tri, Intersection &hit) const{ // Extract vertex positions from the mesh data. Vector const &p0 = positions[tri[0].pi]; Vector const &p1 = positions[tri[1].pi]; Vector const &p2 = positions[tri[2].pi];

calculation for ray generation in ray tracer

爱⌒轻易说出口 提交于 2019-12-11 05:59:10
问题 I am implementing a basic ray tracer so I am reading up on theory and other implementations. Here is the code that I am currently referring to template<typename T> void render(const std::vector<Sphere<T> *> &spheres) { int width = 800, height = 800;//define width and height of the screen Vector3d<T> *image = new Vector3d<T>[width * height], *pixel = image; T invWidth = 1 / T(width), invHeight = 1 / T(height); T fov = 90, aspectratio = width / T(height);//defining field of view angle and

Raytracing seam-like rendering artifacts

痞子三分冷 提交于 2019-12-11 05:54:48
问题 I have written a simple raytracer (the code is here but you don't have to debug it). It can render simple meshes: It looks pretty cool, I think. There is no reflection in the raytracer and the pixels are shaded solely based on their interpolated normals. However, if you zoom up you see that there are rendering artifacts all over it: My question is, what is causing these "dots" on the model? I know it must have something to do with the intersection test because here is the same model rendered

How to keep a list of instances of a class?

痴心易碎 提交于 2019-12-10 17:46:55
问题 I'm writing a raytracer in C++ and need to be able to check intersections with every object in a scene (optimizations will come later), and to do this, I need to keep a running list of class instances. A list of pointers, updated when a new instance is created, won't work because as far as I know there is no way to increase the size of the array after it is initialized. I'd really like a built-in (to C++) solution if there is one. 回答1: I'm writing a raytracer in C++ and need to be able to

When writing openCL code, how does it perform on a single-core machine without a GPU?

久未见 提交于 2019-12-10 16:55:05
问题 Hey all, I Am currently porting a raytracer from FORTRAN 77 to C for a research project. After having ported the essentials, the question is how we proceed to parallelization. In the lab, I have access to a couple of different Opteron machines, with between 2 and 8 cores, but no GPUs (for now). We are running 64b gentoo. A GPGPU version would be (very) desirable, but with only one programmer on the project, maintaining separate non-GPU and GPU versions isn't an option. Also, the code will be

Camera Pitch/Yaw to Direction Vector

孤街醉人 提交于 2019-12-10 02:36:53
问题 What I'm trying to do is cast a ray from my camera. I know the camera's x, y and z coordinates, as well as its pitch and yaw. I need to calculate its direction vector so I can pass it to my raytracing algorithm. The camera's up vector is (0, 1, 0). "Pitch", from the perspective of the camera, is looking up and down. (I would prefer to not use matrices, but I will if I have to) 回答1: Assuming that your coordinate system is set up such that the following conditions are met: (pitch, yaw) -> (x, y