raytracing

Raytracer - Computing Eye Rays

烈酒焚心 提交于 2019-12-03 06:13:39
问题 I'm writing a ray tracer (mostly for fun) and whilst I've written one in the past, and spent a decent amount of time searching, no tutorials seem to shed light on the way to calculate the eye rays in a perspective projection, without using matrices. I believe the last time I did it was by (potentially) inefficiently rotating the eye vectors x/y degrees from the camera direction vector using a Quaternion class. This was in C++, and I'm doing this one in C#, though that's not so important.

How to quickly find if a point is obscured in a complex scene?

允我心安 提交于 2019-12-03 06:02:58
I have a complex 3D scene that I need to display HTML elements on top of, based on a 3D coordinate. (I'm simply overlaying a div tag on top and positioning it with CSS.) However, I also need to partially hide it (e.g., making it transparent) when the 3D coordinate is obscured by a model (or phrased in another way, when it's not visible in the camera). These models may be have many hundreds of thousands of faces, and I need a way to find out if it's obscured that's fast enough to be run many times per second. Currently, I am using Three.js's built-in raytracer, with the following code: // pos =

Elegant/Clean (special case) Straight-line Grid Traversal Algorithm?

橙三吉。 提交于 2019-12-03 04:42:58
问题 I'm dusting off an old project of mine. One of the things it had to do was -- given a Cartesian grid system, and two squares on the grid, find a list of all squares that a line joining the center of those two squares would pass through. The special case here is that all start and end points are confined to the exact center of squares/cells. Here are some examples -- with pairs of sample starting and ending points. The shaded squares are the ones that should be returned by the respective

How to move a camera using in a ray-tracer?

六眼飞鱼酱① 提交于 2019-12-03 00:42:22
I am currently working on ray-tracing techniques and I think I've made a pretty good job; but, I haven't covered camera yet. Until now, I used a plane fragment for view plane which is located between (-width/2, height/2, 200) and (width/2, -height/2, 200) [200 is just a fixed number of z, can be changed]. Addition to that, I use the camera mostly on e(0, 0, 1000) , and I use a perspective projection. I send rays from point e to pixels, and print it to image's corresponding pixel after calculating the pixel color. Here is a image I created. Hopefully you can guess where eye and view plane are

Refraction in Raytracing?

只愿长相守 提交于 2019-12-02 22:28:50
I've been working on my raytracer again. I added reflection and multithreading support. Currently I am working on adding refractions, but its only half working. As you can see, there is a center sphere(without specular highlight), a reflecting sphere(to the right) and a refracting sphere(left). I'm pretty happy about reflections, it does look very good. For refractions its kinda working...the light is refracted and all shadows of the spheres are visible in the sphere(refraction index 1.4), but there is an outer black ring. EDIT: Apparently the black ring gets bigger, and therefore the sphere

How to deal with refraction when the rays start inside of a nested object

烈酒焚心 提交于 2019-12-01 19:25:51
问题 I am building a simple raytracer for educational purposes and want to add refraction to objects. Using Snells Law, I am able to create a new ray recursively at the intersection points. The raytracer supports currently only spheres and I use a scene where I have multiple spheres nested inside of each other with different refraction indices. If I start a ray from outside of the spheres, everything seems simple. You start with the refraction index of the scene, and as soon as you hit the first

How to deal with refraction when the rays start inside of a nested object

ぃ、小莉子 提交于 2019-12-01 18:25:09
I am building a simple raytracer for educational purposes and want to add refraction to objects. Using Snells Law, I am able to create a new ray recursively at the intersection points. The raytracer supports currently only spheres and I use a scene where I have multiple spheres nested inside of each other with different refraction indices. If I start a ray from outside of the spheres, everything seems simple. You start with the refraction index of the scene, and as soon as you hit the first sphere, refract the ray using the refraction index before and the refraction index of the material of

Setting the up vector in the camera setup in a ray tracer

巧了我就是萌 提交于 2019-12-01 10:55:35
问题 I'm reading fundamentals of computer graphics and trying to set up my own ray tracer. the book says "The most common way to construct the camera frame is from the viewpoint, which becomes e, the view direction, which is−w, and the up vector, which is used to construct a basis that has v and w in the plane defined by the view direction and the up direction" but then I came across How to move a camera using in a ray-tracer? which says that we need to correct the up vector for the (slope?) by

How to best store lines in a kd-tree

一曲冷凌霜 提交于 2019-12-01 03:46:10
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? 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 query it correctly. The R*-tree (Wikipedia) might be a better choice here. It is really designed for

Ray tracing - soft shadow

强颜欢笑 提交于 2019-12-01 01:09:12
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? You are standing at a point P with local surface normal N, and need to find out the illumination arriving