Thursday, March 27, 2008

ActionScript Project

Since I am getting some hits regarding my ray tracer, I thought it would be cool to include progress on my other projects as well.

I am working on a molecular visualization project regarding molecular 'spiders' that a research group here at UNM is working with. Many, many people are working on getting these molecules to walk around a surface and *hopefully* compute something useful. Primarily, I work with ActionScript in an attempt to get some flashy visualizations online.

In addition to messing with ActionScript, I read papers on molecular visualization to try and figure out how other people are approaching this problem. I hope to use this blog to show some of my progress, post ActionScript for everyone to view, and place my thoughts on academic papers I read regarding molecular visualization.








Please leave me a comment if you find any of this useful.

Monday, March 17, 2008

.OBJ Loading Up

Hey Hey,

With the help of the two Nate's (Nate Gauntt helping with indexing into Nate Robbins GLM stuff) I was able to load in .obj files.


First (working) image generated from an .obj file
1 sample / pixel



As we swim closer to the dolphins...



We begin to question, why were they red?


This took a while to render:
real 5m35.747s
user 4m45.890s
sys 0m2.280s

.OBJ model can be found here. Source is will be here (once the UNM CS network is up, that is.)

Saturday, March 8, 2008

Done - until refactoring

I still have a few errors in my ray tracer. If you closely look at the green sphere, it should be cut by the plane. Also, the order that I add items to my scene object list currently matters in my ray tracer. This is because I do way too much of the scene shading in the object hit function. In order to fix this, I really need to add more methods to my parent GeometricObject class, and stop implementing things in the derived classes. This is going to take a bit of refactoring, but once I get some sort of version control (SVN) setup I should be able to move forward.


Sphere with Cool Texture by Autumn Stinar

I really, really, really like the artwork my sister sends me. Most of the time for Christmas or my birthday, I ask her for art as presents. The texture I wrapped the sphere in is from a picture message she sent me of a piece inspired by trance lyrics. Since the image was taken with a camera phone (and edited a bit by me) it isn't the highest resolution in the world. I have a view other abstract pieces I want to scan at extremely high resolution and use for sphere textures. My goal is to have an entire scene with her textures.


256 samples / pixel

Earth + Plane


Earth above a plane - 32 samples / pixel - no shading



Earth above a plane - 32 samples / pixel - matte shading




Earth above a plane - 128 samples / pixel - matte shading

Friday, March 7, 2008

Tiled Plane = Super Easy to test Anti-Aliasing

It is really, really clear what my anti-aliasing is doing when looking at the plane fading out into the distance. Below are some images (no shading - it is easier to see the plane approach the horizon without any shading) of different sample rates. Getting the plane to work took a bit of trial and error, but I think it is looking OK.

I used a completely square image that tiles perfectly. Here's the tile pattern I used (thanks Nate Gauntt):







1 sample per pixel = ugly



16 sample per pixel = better



5,000 samples per pixel (yes, 5k - I ran it for 6 hours on a university machine)

Thursday, March 6, 2008

Thanks Nate!

Nate and I talked about my bug for about 15 minutes and we were able to find it! I was totally calculating the index into my images incorrectly:

tmpColor = RGBVector[width * vertical + horizontal]; // correct

tmpColor = RGBVector[height * vertical + horizontal] // totally wrong




Map of the Earth, as taught in Panama

Square Textures = Perfect, still some issues with non-square textures

Today I spent a lot of time with my host for my SIBBS class. The speaker, Dr. Julia Cole, is a totally awesome researcher. Listening to her talk, eating a bunch of free meals and hanging out with a number of very intelligent people from all different disciplines made hosting the visit a lot of fun. It still was a lot of work and the experience involved choosing what to sacrifice so I could make the visit enjoyable. I wasn't able to work on graphics quite as much as I would like, but I have made some good progress.

Spherical mapping from a square texture to a sphere is at 100%. Check out the grid texture below Nate Gauntt send me for testing and it perfectly mapped to the sphere.

Welcome to Grid World!


The Square (255 x 255) Texture


However, all is not good and right in Grid World. If I, even slightly, modify the texture to be anything other than a square, it looks really messed up. Check it out below with the (252 x 255 grid):


I must be indexing into Y incorrectly...

Tuesday, March 4, 2008

Anti-Aliasing Looking Good!

Hey hey, it looks like I have random anti-aliasing looking good! I have been working extremely solidly on this project since it was up on the course website. For the next assignment that Joe briefly mentioned, I am going to get started the day after I turn this in, or directly after I turn this in REGARDLESS of when it is posted.



Here's an image I generated from an Earth texture @ 16 samples per pixel. However, I massively shrunk the original image. When I use my giant earth image, I am still getting some moray aliasing patters. I think I'll up the number of samples to 64 or 128 and try with the giant image.






1 Sample per Pixel


16 Samples Per Pixel


And the sweet, sweet code-ness:

....
RGBColor pixelColor = RGBColor(0,0,0);
int num_samples = 16;
float inv_num_samples = (1 / (float)num_samples);

RGBColor tmpColor;
for (int r = 0; r < c =" 0" o =" myWorld.ViewPlane.eyePoint;" count =" 0;" random1 =" (" random1 =" random1" random2 =" (" random2 =" random2" d =" myWorld.ViewPlane.from_screen_to_world(c+random1," tmpcolor =" myWorld.trace_ray(ray);"> 1){
tmpColor.r = 1.0;
}
if (tmpColor.g > 1){
tmpColor.g = 1.0;
}
if (tmpColor.b > 1){
tmpColor.b = 1.0;
}

tmpColor = tmpColor * inv_num_samples;
pixelColor = pixelColor + tmpColor;
}

myWorld.myfile << " " << (ceil( 255 * pixelColor.r)) << " " << (ceil( 255 * pixelColor.g)) << " " << (ceil( 255 * pixelColor.b)) << " "; // Don't forget to zero this out! This jacked me up bad. pixelColor = RGBColor(0, 0,0); ....

Sphere Texturing Done - Just need Anti-Aliasing

Things are looking all right with the spheres. You can completely see the moire patterns due to aliasing on the big sphere. Once I get a little more time to add content to this blog, I'll go over the math behind translating between world coordinated - polar coordinates - image coordinates.




Looking all right, if a bit aliased.


I'm not completely sure if I have the texture mapping completely right - it looks like only 1/4 of the below smiley texture mapping onto 1/2 of the sphere - I am fairly certain my polar - y image index is OK, but my polar - x may still need a little work. These concepts are not extremely difficult mathematically, but it takes a LONG time for me to code them up in C++.


Texture mapped onto the sphere - no shading




If people like checking this stuff out, leave me a comment! I've seen some hits from all over the world on this, and I would like to hear what you guys think.

Sunday, March 2, 2008

Looking Better

The texture mapping is going better. I think I may almost be done with the sphere. After contemplating a handball, and talking with my friend from Kazakhstan, I realized that when looking at a sphere from my angles, you will see the full -radius to +radius in two dimensions. However, the third dimension you will only see one radius worth of sphere. This is due to the self occlusion of the sphere; once you reach a (relative) peak, the sphere will be blocking itself. Maybe this seems obvious to many people, but for me it was a wonderful revelation while looking at the handball.

Ultimately, I realize that the Z-axis and Y-axis are incorrectly labeled in my code (they are switched). This hasn't been noticeable before, due to the self similar nature of all the objects I have ray-traced, but it explains why my relative positions look a little different than my class mates. Now, because of the above property, it makes a huge difference. I was repeating the texture below and above the equation.


More coming Soon
200 x 200 texture

Attempt at Texture Mapping on a Sphere

There is something weird going on around the poles; I may be calculating rho incorrectly by somewhere taking an absolute value or something. I should index different parts of the image if I am close to 0 or if I am close to Pi.

The red around the border is intentional - I was concerned with accessing elements of my image in a non sequential way, I thought this was the source of my problem. However, the non sequential accesses are as they should be, right around the edges of the sphere where I wrap around to the other side to get my texture.


Here is a big sphere with my texture mapped to it - no shading



Here's the texture - generated in Gimp