Overclock.net banner
1 - 9 of 9 Posts

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #1 ·
So for the final assignment in my image processing course I have to choose something related to the course and implement it as an iPhone app.

I got this idea to implement a raytracer, only in 2 dimensions, because it takes my i5 a couple minutes to render one scene in the 3d raytracer I wrote last year.

I'm not even sure if this is possible, or if I can even call it raytracing, but the assignment criteria is basically "do whatever you want, as long as you have fun" and this is fun.

Here's what I have so far:



All it is is a modified version of Bresenham's algorithm. I'm planning on eventually implementing textures, refraction, and reflection.

First I have to fix the algorithm, there are way too many artifacts.

Anyone have any ideas?

Update: Ok so for some reason the lines around the octant barriers were drawn twice. I added a check and halved the ray intensity and they seem to have gone away.



There are still a few anomalies though. I'm also experimenting with a blur filter to get rid of the lines. Its just an intensity map so it doesn't need to be precise.

(Oh, and its brighter because I'm using different values)
 

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #2 ·
Big update! I have to make my project proposal tomorrow so I've been working on it.

Here's my pseudo-ray tracing algorithm so far:



The first one is just the basic image, unmodified.

Next is basically the same Bresenham line drawing, as you can see it still looks rather hideous. I'm still trying to figure out the whole 4 leaf clover effect.

Next is a fairly heavy gaussian blur, or what I call the de-sucking effect.

And finally I apply the intensity values to the target image, creating a fairly decent effect!

So far what I've done is literally a combination of parts the 3 previous assignments, so I'd say its fairly on-topic. I've got a lot of freedom in terms of what types of filters I can apply, and I might take a shot at bump mapping, similar to the photoshop light effect I originally got the idea from.

I also tried some basic reflections, and failed miserably. I just know its going to be a pain since I'll have to store(ugh) or compute(eek!) the angle of every surface I hit. I could probably use edge detection and go from there, but I'm getting a headache just thinking about it.
 

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #4 ·
Quote:


Originally Posted by serge2k
View Post

looks cool.

I'm actually working ona ray tracer as a project as well.

Mine looks considerably worse than yours.


I'm assuming its an actual 3d raytracer?

Here's the thread for the one I wrote last year, along with the final output:

http://www.overclock.net/coding-prog...r-scratch.html

The funny thing about raytracers is that one minute you'll be looking at an ugly red circle, you'll go back and write 3 lines of code and the next time you run it you get a work of art.

The presentation went alright. We get to choose our marking criteria so as long as I can give the marker something to go by I should be able to get a pretty good mark.

I had some time at the end of the class and I got an idea. The reason the shadows are so hard is because I'm doing point lighting. That is, every ray is originating from the exact same pixel.

I decided to change it up a little. Now what I do is draw a circle in my masking filter and I create lights at evenly spaced intervals around the circle. They can't actually pass through the circle so they all combine into 1 light with a much larger surface area.



(The dark spots are there because I still haven't implemented a circle fill function, its actually a hollow circle, so you would expect it to be completely dark inside)

I think I'm also going to modify my gaussian blur filter to ignore objects, because that glow around the edges doesn't work for me.

And I tested this in real time with moving lights, and it runs at about 12 FPS
 

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #5 ·


Another update.

I've got it reading the lighting information from a mask now, and circle fill finally works. The end result is that I can now make much better images, as you can see above.


I also figured out the equation I need to bounce the light around, although I'm not entire sure how much I'm going to need it.



A little bit of animation. Man screen capture in Linux is so freaking easy!
 

·
Premium Member
Joined
·
5,315 Posts
May I ask what language?

Im currently making an .3ds model loader in C++ and OpenGL but the lighting part is giving me a headache.

Hats off to you sir.
 

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #7 ·
Quote:


Originally Posted by i_ame_killer_2
View Post

May I ask what language?

Im currently making an .3ds model loader in C++ and OpenGL but the lighting part is giving me a headache.

Hats off to you sir.

C++ and SDL

I'm going to be porting it to Obj C and OpenGl next week and putting it in an iPhone app.
 

·
Premium Member
Joined
·
5,315 Posts
Quote:


Originally Posted by nathris
View Post

C++ and SDL

I'm going to be porting it to Obj C and OpenGl next week and putting it in an iPhone app.

Using SDL as my window and key manager. Very neat library.

Good luck!
 

·
Premium Member
Joined
·
12,992 Posts
Discussion Starter · #9 ·


Thats the end result.

The algorithm remained unchanged when I ported it, yet it suddenly turned to crap. I blame Steve Jobs.

But the point is, I'm done, and I hopefully will never have to deal with Xcode and the iPhone SDK ever again.

Surprisingly its also very fast. That image rendered in under 5 seconds, running on a simulator in a virtual machine running OSX!
 
1 - 9 of 9 Posts
Top