Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Ray Tracing

Name: Anonymous 2011-11-08 23:59

Goddamn all of these homework threads. Let's talk about something interesting.

I'm starting work on a ray-tracer for shits, /proggles/ Any tips on speed improvements? It's being written in C.
I know the show stopper (usually) is having to check each element in the scene and see if it has been intersected by a casted ray. Any ideas on improvements in that area?

Name: Anonymous 2011-11-09 0:02

What's a ray tracer?

Name: Anonymous 2011-11-09 0:17

>>1 find a better hobby?

Name: Anonymous 2011-11-09 0:28

>>1
Pro-tip: make your renderer multithreaded. Divide the screen up into uniform tiles and assign each one to a thread.

Name: OP 2011-11-09 0:43

>>2
http://lmgtfy.com/?q=ray+tracing and IHBT

>>3
Fuck you.

>>4
Thanks, I had that on the list already.

Any other tips?

Name: Anonymous 2011-11-09 0:52

do what mister or mises >>4 say. You can calculate the result of every ray in parallel. If you'd like to get the calculation for a single ray to become more efficient, then you can check out some spacial data structures. I think BSP trees would be helpful for finding the closest intersection point of your ray with the world, although if the world is constantly deforming like crazy, it might hard to maintain such a data structure efficiently. I wanted to make a 4d space renderer a while ago. I think I will continue. I was planning on using transparency as a part of the visualization, and I was hung up on how to get a good spacial data structure that would handle projections from 4D to 3D, and when the projection was changing based upon the user's view parameters.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 2:32

Ray tracers are inefficient bruteforce solutions to rendering. It no wonder even latest cards can't handle raytracing at real-time while procedurally generated content of same quality can be run rendered in software.

Name: Anonymous 2011-11-09 2:36

>>7
Surely you can optimize a raytracer with leet haxor skills to run at realtime.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 2:41

>>8
I can but i prefer optimizing my Quasicrystal generator. If you show me a C raytracer written in one .c file i'll try.

Name: Anonymous 2011-11-09 3:28

OP Here
>>7
Recommend a better rendering algorithm with as much realism as a two-pass raytracer that is faster then, and I'll look into that.

>>9
I'm a college kid, so my projects are made in my sparse spare time. After I make the well-designed one, I'll make a simple one and take you up on that.

Side note, it'd be interesting to make a ray tracing engine using pure Monte-Carlo simulation, having all rays traced from light sources and only gathering the ones that reach the camera. It would  be rather realistic, but fuck efficiency.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 3:52

>better rendering algorithm with as much realism as a two-pass raytracer
You draw the objects in fast OpenGL code and apply "realism"(i assume shadows and lighting) globally like every 3D game on the planet.
Current cards all support shadows, transform and lighting, basically 99% of realism is done with a 10 years old card.
The rest of that 1% is the miniscule difference imperceptible to gamers and casual viewers.

Name: Anonymous 2011-11-09 4:01

>>11
Really? What about caustics in lighting? Realistic refraction and reflection? Didn't think so.

Name: Anonymous 2011-11-09 4:03

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 4:08

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 4:10

http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node156.html

Next: 11.1.0.1 Accelerated Reflection and Up: 11. Scene Realism Previous: 11. Scene Realism

  
11.1 Reflections and Refractions

 

In both rendering and interactive computer graphics, substantial effort has been devoted to the modeling of reflected and refracted light. This is not surprising - almost all the light perceived in the world is reflected. This section describes several ways to create the effects of reflection and refraction using OpenGL beginning with a very brief review of the relevant physics. Pointers to more detailed descriptions are provided.

From elementary physics, the angle of reflection of a ray is equal to the angle of incidence of the ray (Figure  52). This property is known as the Law of Reflection [21]. The reflected ray lies in the plane defined by the incident ray and the surface normal.

Refraction is defined as the ``change in the direction of travel as light passes from one medium to another'' [21]. This change in direction is caused by the difference in the speed of light traveling through the two media. The refractivity of a material is characterized by the index of refraction of the material, or the ratio of the speed of light in the material to the speed of light in a vacuum [21].

 

The direction of a light ray after it passes from one medium to another is computed from the direction of the incident ray, the normal of the surface at the intersection of the incident ray, and the indices of refraction of the two materials. The behavior is shown in Figure  52. The first medium through which the ray passes has an index of refraction n1 and the second has an index of refraction n2. The angle of incidence, , is the angle between the incident ray and the surface normal. The refracted ray forms the angle with the normal. The incident and refracted rays are coplanar. The relationship between the angle of incidence and the angle of refraction is stated as Snell's Law[21]:

    (4)

If n1 > n2 (light is passing from a more refractive material to a less refractive material), past some critical angle the incident ray will be bent so far that it will not cross the boundary. This phenomenon is known as total internal reflection and is illustrated in Figure 53 [21].

When a ray hits a surface, some light is reflected off the surface and some is transmitted. The weighting of the transmitted and reflected light is determined by the Fresnel equations.

More details about reflection and refraction can be gleaned from most college physics books. For more details on the reflection and transmission of light from a computer graphics perspective, consult one of several general computer graphics books or books on radiosity or ray tracing [17], [32], [45].


 

    11.1.0.1 Accelerated Reflection and Refraction
    11.1.1 Techniques for Rendering Reflections
    11.1.2 Planar Reflectors
        11.1.2.1 Planar Reflections Using the Stencil Buffer
        11.1.2.2 Planar Reflections using Clip Planes
        11.1.2.3 Planar Reflections using Texture Mapping
    11.1.3 Curved Reflectors
        11.1.3.1 Implicit and Extruded Reflectors
        11.1.3.2 Arbitrary Curved Reflectors
        11.1.3.3 Convex Reflectors
        11.1.3.4 Concave Reflectors
        11.1.3.5 Reflectors of Mixed Convexity
        11.1.3.6 Conclusions and Issues
    11.1.4 Refraction
    11.1.5 Further Realism
        11.1.5.1 Interreflections
        11.1.5.2 Blurry Reflection


Next: 11.1.0.1 Accelerated Reflection and Up: 11. Scene Realism Previous: 11. Scene Realism
David Blythe
1999-08-06

Name: Anonymous 2011-11-09 4:12

>>14
Remind me where either of those sources accurately rendered caustics and where they did realistic, recursive reflection and refraction. (reflections of reflections of refractions, etc)

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 4:16

Name: Anonymous 2011-11-09 4:22

>>17
Fine. Most of those cheated and weren't very realistic, but this one sold me:
http://graphics.cs.ucf.edu/caustics/

It's done through ray-tracing though. They just mixed it with hardware accelerated techniques.

Anyways, for my purpose, I don't plan on using the raytracer as a game engine or anything. It achieves the most realism because it is closer to a model of reality than OpenGL rendering techniques. It is, at least, more intuitive and easy to code.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 4:28

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 4:33

>closer to a model of reality
You can get much closer with OpenGL. tracing rays is the inefficient bruteforce solution.
What if you want to add some effect to your raytracer? That which is not possible in the "pixel reality"? Can you see you prematurely limit yourself to fixed pixel reality of your raytracer(which is pretty primitive compared to full set of openGL effects and transforms)

Name: Anonymous 2011-11-09 5:02

>>20
Ray tracing is a SIMD problem. In that regard, it's no different as a "inefficient bruteforce solution" to rastering polygons in traditional interactive 3D graphics. The nature of ray tracing means that scene rendering is inherently multi-core friendly; you can literally add more cores to solve ray tracing to make it faster.

Name: Anonymous 2011-11-09 5:03

Use the powah of OpenCL and Cuda. It already was done though and decided that it's not feasable yet. So listen >>4 and use every core your i7 can offer.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 5:07

>inherently multi-core friendl
Graphics card have thousands of cores now, you can't beat that.
>you can literally add more cores
Throwing hardware at the problem.
Using most inefficient algorithm.

Name: Anonymous 2011-11-09 5:08

>>22
Cuda
closed source piece of shit

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 5:16

Anyway if you still want to create a raytracing renderer, when you finish post the code to /prog/ as pastebin link.
Most raytracers use very inefficient code which can be easily optimized with some C hacking.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 5:19

You can start one based on Metro instead of plain raytracing btw:
http://graphics.stanford.edu/papers/metro/

Name: Anonymous 2011-11-09 8:33

OP back from the dead.
>>22
I've been looking for a good excuse to learn CUDA. I guess after I write this I could go back and use that to parallelize it.

>>23
Agreed.

>>25
Alright, I'll put it up. It probably won't all be in one file. Should I put everything together when I upload?

>>26
Sounds interesting. I'll look into that.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 10:00

>>27
You can copy paste everything and post the result file on pastebin(or just use copy filea+fileb+filec hugefile and post that).

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 10:02

>>28
Also it might be helpful to know what libraries(and their versions) and compilers are used(this should be noted at start of code).

Name: Anonymous 2011-11-09 21:14

>>23
Efficiency is meaningless out of context. Efficiency is always subjective relative to the problem at hand and the solutions to the problem. Until you can give me real data, my opinion is that ray tracing is no less efficient at interactive 3D graphics than traditional techniques.

Name: Anonymous 2011-11-09 21:25

>Complains about homework threads
>Suggests ray tracing

We have ray tracing for like the first three semesters of classes in our computer science department as required in the courses.  Then if you want you can go do more advanced stuff with senior and graduate level classes.

Coincidentally we have a lot of shitty students after their first couple semesters who have no idea what they're doing.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 21:28

>>30
If it was, why no one switched for ray tracing for games?

Name: Anonymous 2011-11-09 21:35

>>31
Where do you study? Sounds like my university. All of the people who never programmed before college still can't program. I'm better than I was when I made my ray tracer, and I've always thought about going back and making a better one.

Name: Anonymous 2011-11-09 21:36

>>32
And he's suggesting that the context in which you would use raytracing and traditional techniques are different. In general, you can get more realism from raytracing, and so its inherent slowness is negligible depending on circumstance.For instance, animation companies use raytracing to render animated films.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 21:38

In short ray tracers:
1.are inefficient by design vs OpenGL effects(which are more complex and provide flexibility in design)
2.use horrible,uncached computation architecture which has zero environment knowledge(rays to pixels blindly shot everywhere)
3.typically have a huge inner loop with multiple branches. Branches in the inner loop=slow code everytime branch miss occurs

Name: Anonymous 2011-11-09 21:47

>>33
Clemson school of ray tracing

Name: !!mEFVYLkcRFWjjY+ 2011-11-09 21:50

>>35
SHUT THE FUCK UP YOU DUMB NIGGER. CRIPES. I DON'T KNOW IF YOU'RE FUCKING MENTALLY RETARDED JEW OR JUST A DUMBASS. EITHER WAY, YOU GIVE THE WORST ADVICE OUT OF ANYONE HERE.

NOW GO FUCKING KILL YOURSELF YOU USELESS PIECE OF SHIT.

Name: Anonymous 2011-11-09 21:59

>>36
Alas, we do go to the same school.

Name: Anonymous 2011-11-09 22:04

>>36
What year are you/have you finished the mess that is "RayTracing" 212?

Name: Anonymous 2011-11-09 22:25

>>10

naw, starting from the light and bouncing around till you hit the camera doesn't work. It would take way too long to hit everything that is visible from the camera to have light hit it and for it to send rays of light in the exact direction of the location of the camera. You can do something similar though, check out photon mapping:

http://en.wikipedia.org/wiki/Photon_mapping

>>23

It's not that its the most inefficient algorithm, but that its the most evaluating the scene using the a more general model.

>>30

ray tracing is hard as fuck compared to typical opengl stuff

>>32

You have to admit that realistic ray tracing would be the shit in a game. But unfortunately not worth the drop in framerate.

>>35

You could try to use caching, but there would take a lot of memory, and would break the arbitrary parallelism, unless you allocated a separate cache for each worker thread. Also depending on the spacial resolution, you would introduce some artifacts.

Name: Anonymous 2011-11-09 22:41

>>39
You stop after 212 unless you go on to take 405.  Or you go back in time and take the C version of 215.  Though back then you were also expected to make nice shit with your ray tracer.  Like those pictures at the front of the beginning.  Or the one with the wanted poster of Westall in the faculty lounge.

Anyway I prefer to remain ANONYMOUS AS FUCK and as such not revealing who I am.  Though if you did know who I am then you could probably guess it.

Name: Anonymous 2011-11-09 22:44

>>41
front of the beginning should be front of the building.

AND NOW I GET TO BE KICKED OFF OF 4CHAN AND BY EXTENSION THE INTERNET FOREVER!

Name: Anonymous 2011-11-09 22:44

>>41
You would likely never guess who I am, and it sounds like you've been in Clemson longer than I have. I'm beginning 300 level classes next semester. And anonymity is just fine.

Name: Anonymous 2011-11-09 22:45

>>42
Also, I understood. I'm looking to outdo those, though.

Name: Anonymous 2011-11-09 22:51

>>43
You're one of those fuckers in 212.  There's one section of that.  All I have to do is go into the class tomorrow, discreetly look at everyone's browsing history, and find the sap who has /prog/.  And incognito mode or equivalents won't work.  I'm a fucking ninja.  Don't [spoiler]turn[/around] around

Name: Anonymous 2011-11-09 22:51

>>45
And there go my other Internet cards.  Good night /prog/.

Name: Anonymous 2011-11-09 23:01

>>45, >>46
231/215 actually. But have fun scaring all of those poor, soon-to-be liberal arts majors.

Name: Anonymous 2011-11-09 23:11

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-09 23:42

>>48
"Ray tracer" that use printf as display device and output lines?
also the sphere coords are hardcoded into tracer:
 "1111886:6:??AAFFHHMMOO55557799@@>>>BBBGGIIKK"[b]-64;
 "C@=::C@@==@=:C@=:C@=:C531/513/5131/31/531/53"[b]-64;

Name: Anonymous 2011-11-09 23:51

>>49
It prints a PPM file to stdout.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-10 0:11

>>50
Then i could "raytrace" PPM files to /prog/ one post at the time.

Don't change these.
Name: Email:
Entire Thread Thread List