Thursday, March 6, 2008

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