Eduardo Rodrigues
Let me show you my programmings
Wednesday, May 16, 2012
Sunday, May 13, 2012
Renderman Assignment
Another assignment for Computer Graphics II; grab a version of Renderman (I use Pixie) and mess around in it.
I threw what I did up on my GitHub account in case I did something groundbreaking and it needs to immediately be shared with the masses.
I threw what I did up on my GitHub account in case I did something groundbreaking and it needs to immediately be shared with the masses.
Mission accomplished.
Thursday, May 10, 2012
Ray Tracer Checkpoint 7 - Tone Reproduction
Reinhard, Lmax = 1 |
Reinhard, Lmax = 1000 |
Reinhard, Lmax = 10000 |
Ward, Lmax = 1 |
Ward, Lmax = 1000 |
Ward, Lmax = 10000 |
Thursday, May 3, 2012
Lighting and Shadowing: Status Update - Week 8
Recap
Basically, I wanted to create a scene with random terrain and light the scene with some different illumination models. Then I wanted to throw in dynamic shadow casting and, if time permitted, some fancier effects like soft shadows and volumetric shadows. The best way to go about all of this was with the use of shaders; specifically GLSL.Status
According to my timeline in the previous post I expected to be further. In all honesty I knew I would get distracted and fall behind. Progress has actually been made though; I'm only a week behind!- Random scene generation is done
- Basic shader understanding/implementation is done
- Phong illumination model is implemented
Terrain Generation
I began the project with my basic terrain generation algorithm I started a few months ago. It used the simple recursive Diamond-Square Algorithm to generate a 2-dimensional height map. From there I could create a basic polygonal mesh and render the scene using OpenGL. It gets some pretty nice results and isn't too difficult to implement, but can be a bit intensive when generating larger maps.Diamond-Square Terrain |
Distraction 1: Minecraftify it! |
Random Planet Generation
I got distracted on a bit of a terrain generation kick and felt like taking it a step further. I can not for the life of me find the paper and website where I got this algorithm from, but it is awesome:- Generate a tessellated sphere (I use recursive icosahedron subdivision)
- For an arbitrary number of iterations:
- Generate a random plane normal
- For every point on sphere
- Determine side of plane the point is on
- If in front, raise a random amount
- If behind, lower a random amount
Shaders
I ended up following an object-oriented approach similar to what's outlined on the Swiftless Tutorials website, but modified to make things a bit more logical for me. This made loading, compiling and linking shaders extremely easy and let me focus on actually writing the shaders.My shaders are still a tad basic, but they do have a few noteworthy characteristics:
- Implement all the basics of GLSL usage, such as varying, uniform, and attribute types
- The vertex shader adjusts vertices based on a distance calculation (any points below sea-level are adjusted to preserve a more rounded planet)
- The fragment shader determines pixel color based on their position, and implements the Phong Illumination models (Per-pixel lighting, yeah!)
Results
Originally being made in C++, all of this has been ported over to Java and runs on Android 4.0.3 (should work on 2.2+) with OpenGL ES 2.0. I got a tablet and figured this would be a good way to break it in.
|
|
||||
|
|
||||
|
|
Labels:
3d,
CGII,
computer graphics,
lighting project,
OpenGL,
RIT
Wednesday, May 2, 2012
Ray Tracer Checkpoint 6 - Transmission
Will type better explanation/description later; currently in "the coding zone."
Results
Basic - Transmissive Surface |
Wednesday, April 25, 2012
Ray Tracer Checkpoint 5 - Reflection
Before this checkpoint the ray tracer only calculated local illumination on the surface of an object; with the exception of shadows, the illumination of a point on a surface was completely independent of the rest of the scene. The purpose of this checkpoint is to change that a bit.
The easiest way to do this was to have each surfaces' material (or texture, as of the last checkpoint) store the coefficient of reflection.
The actually reflection is then implemented using recursion. The basic algorithm is as follows:
Also, it may be difficult to see, but please note that the specular highlight no longer shows up in the shadowed areas. This, of course, is a triumph. I have to make a note here; huge success. It's hard to overstate my satisfaction.
The Plan
The goal was to make surfaces reflective based on a coefficient of reflection that each surface will have.The easiest way to do this was to have each surfaces' material (or texture, as of the last checkpoint) store the coefficient of reflection.
The actually reflection is then implemented using recursion. The basic algorithm is as follows:
- Cast out a ray
- Check for surface collision
- If no collision, use background color (black)
- If collision
- Calculate normal illumination color
- Determine reflection ray
- Start over again, but with reflection ray
Results
Basic - Reflective surface |
The actual algorithm is extremely straightforward, simple to implement, and looks awesome. However, I still struggled for way too long with the blue sphere being in the reflection; turns out my sphere-ray collision detection was broken.
Also, it may be difficult to see, but please note that the specular highlight no longer shows up in the shadowed areas. This, of course, is a triumph. I have to make a note here; huge success. It's hard to overstate my satisfaction.
Wednesday, April 18, 2012
Ray Tracer Checkpoint 4 - Procedural Shading
The fourth checkpoint is all about procedural shading; basically applying a pattern or texture that is generated on the fly (as opposed to loaded in from an external image) and then applied to a surface or object.
When the ray is cast out from the camera and intersects with a surface, we translate that point of intersection into local coordinates (u, v) relative to some origin on the surface. The easiest case for this is a Polygon which is why it was the focus of this checkpoint. Determining relative (u, v) coordinates shouldn't be too difficult for other objects, however, and I plan on doing so in a later release.
The local (u, v) coordinates then can be used to easily determine the corresponding color from the Texture object. The (u, v) coordinates lying outside the dimensions of the array can be easily handled in a manner similar to actual texture mapping; either repeat the image or stretch the nearest legitimate pixel.
The biggest benefit of using this setup, however, is that it can easily be extended to allow for actual textures to be loaded in. All you have to do is convert a texture into an array of RGB values, which the Simple OpenGL Image Library can actually do for us.
The Plan
I decided to treat the procedural pattern generation as the generation of a "texture," and thus created a Texture class. A Texture object is created with a width and height and stores an array of unsigned chars, it's length being width * height * 3 (it stores the RGB values for every "pixel" of the "texture").When the ray is cast out from the camera and intersects with a surface, we translate that point of intersection into local coordinates (u, v) relative to some origin on the surface. The easiest case for this is a Polygon which is why it was the focus of this checkpoint. Determining relative (u, v) coordinates shouldn't be too difficult for other objects, however, and I plan on doing so in a later release.
The local (u, v) coordinates then can be used to easily determine the corresponding color from the Texture object. The (u, v) coordinates lying outside the dimensions of the array can be easily handled in a manner similar to actual texture mapping; either repeat the image or stretch the nearest legitimate pixel.
The biggest benefit of using this setup, however, is that it can easily be extended to allow for actual textures to be loaded in. All you have to do is convert a texture into an array of RGB values, which the Simple OpenGL Image Library can actually do for us.
Known Problems
- Shadows are finally casting correctly (WOO!), but ambient light does not work as expected. Illuminating scene fully with ambient light should eliminate all shadows; currently does not.
- Objects are still one-sided and I'm still not sure if I like this or not.
- Loading in textures and converting to RGB values is surprisingly slow using SOIL. Need to figure out why or find a better method.
- There's no real concept of "texture mapping" yet, so when textures are loaded in they're stretched almost unrecognizably.
Results
Basic - Procedural Shaded Polygon |
Subscribe to:
Posts (Atom)