raytracing

How to best store lines in a kd-tree

末鹿安然 提交于 2019-12-01 01:08:11
问题 I know kd-trees are traditionally used to store points, but I want to store lines instead. Would it be best to split the line at every intersection with the splitting of the kd-tree? or would storing just the end-points into kd-suffice for nearest neighbor finding? 回答1: The kd-tree itself is designed for point objects. Not even for boxes, spheres or something like this. I believe you can somehow use a 6d tree that stores minx, maxx, miny, maxy, minz, maxz ; but I'm not entirely sure on how to

Ray tracing - soft shadow

落花浮王杯 提交于 2019-11-30 19:56:57
问题 I'm implementing my own ray tracer as an iPad app for a school project. At the moment this is the result: I need to add the last requirement, soft shadows , but I can't find a complete reference anywhere. If I understood well, to implement this feature I have to shoot many ray from an intersection point to mt light source. This one must be an area light. Suppose I use a sphere, my questions are: Which point on the sphere I must use to calculate the shadow ray? How do I average the result? 回答1

How to do ray plane intersection?

风格不统一 提交于 2019-11-30 04:57:48
How do I calculate the intersection between a ray and a plane? I have been visiting every possible website I can find and this is what I have achieved so far: float denom = normal.dot(ray.direction); if (denom > 0) { float t = -((center - ray.origin).dot(normal)) / denom; if (t >= 0) { rec.tHit = t; rec.anyHit = true; computeSurfaceHitFields(ray, rec); return true; } } This does not work :s My function input is: ray: that contains origin and direction. rec: a container class for storing hit information (bool, t, etc) My function has access to the plane: point: the point that defines the plane

raytracing with CUDA

爱⌒轻易说出口 提交于 2019-11-29 21:07:57
I'm currently implementing a raytracer. Since raytracing is extremely computation heavy and since I am going to be looking into CUDA programming anyway, I was wondering if anyone has any experience with combining the two. I can't really tell if the computational models match and I would like to know what to expect. I get the impression that it's not exactly a match made in heaven, but a decent speed increasy would be better than nothing. Matt J One thing to be very wary of in CUDA is that divergent control flow in your kernel code absolutely KILLS performance, due to the structure of the

Spherical filter in android

自古美人都是妖i 提交于 2019-11-29 07:32:29
I have to apply a spherical filter on a image in android, I have attached input and expected output image. Output image will be processed from the squared centered region of input image and mapped it to sphere. Any idea how to do this in Android. Will I have to use openGL for doing this or 2D-trasformation alone will do the task. strike the following code Fish Eye lens for creating the Sphere and apply some modifications for scaling the sphere and background generation, it will work mostly for square images. Brad Larson I just got an implementation of this working using OpenGL ES 2.0 on iOS:

How do I initialize the t-variables in “A Fast Voxel Traversal Algorithm for Ray Tracing”?

纵饮孤独 提交于 2019-11-28 21:21:42
I am trying to implement the algorithm explained on this paper, used to traverse grid cells in order following a straight line, which is useful for ray tracing: http://www.cse.yorku.ca/~amana/research/grid.pdf The paper describes the algorithm as two parts: initialisation and iterative traversal. I can undersand the iterative traversal part, but I'm having trouble understanding how some of the variables in the initialisation part are calculated. I need help initialising tMaxX , tMaxY , tDeltaX & tDeltaY . Their initialisation procedure is explained as follows: Next, we determine the value of t

When are structs the answer?

谁都会走 提交于 2019-11-28 16:32:15
I'm doing a raytracer hobby project, and originally I was using structs for my Vector and Ray objects, and I thought a raytracer was the perfect situation to use them: you create millions of them, they don't live longer than a single method, they're lightweight. However, by simply changing 'struct' to 'class' on Vector and Ray, I got a very significant performance gain. What gives? They're both small (3 floats for Vector, 2 Vectors for a Ray), don't get copied around excessively. I do pass them to methods when needed of course, but that's inevitable. So what are the common pitfalls that kill

How to do ray tracing in modern OpenGL?

£可爱£侵袭症+ 提交于 2019-11-28 15:44:53
问题 So I'm at a point that I should begin lighting my flatly colored models. The test application is a test case for the implementation of only latest methods so I realized that ideally it should be implementing ray tracing (since theoretically, it might be ideal for real time graphics in a few years). But where do I start? Assume I have never done lighting in old OpenGL, so I would be going directly to non-deprecated methods. The application has currently properly set up vertex buffer objects,

Spherical filter in android

眉间皱痕 提交于 2019-11-28 01:14:14
问题 I have to apply a spherical filter on a image in android, I have attached input and expected output image. Output image will be processed from the squared centered region of input image and mapped it to sphere. Any idea how to do this in Android. Will I have to use openGL for doing this or 2D-trasformation alone will do the task. 回答1: the following code Fish Eye lens for creating the Sphere and apply some modifications for scaling the sphere and background generation, it will work mostly for

Testing whether a line segment intersects a sphere

。_饼干妹妹 提交于 2019-11-27 18:54:28
问题 I am trying to determine whether a line segment (i.e. between two points) intersects a sphere. I am not interested in the position of the intersection, just whether or not the segment intersects the sphere surface. Does anyone have any suggestions as to what the most efficient algorithm for this would be? (I'm wondering if there are any algorithms that are simpler than the usual ray-sphere intersection algorithms, since I'm not interested in the intersection position) 回答1: I don't know what