Sunday, December 16, 2012

Snow Accumulation and Generation Final

Finally Done!! Thanks to Patrick and Karl.

Video:

Code and Paper Link: https://github.com/DemiChen/SnowAccumulation


Sunday, December 9, 2012

Snow Accumulation Progress

I spent my weekend finding how to render to texture.
I encountered several problems, which are mostly due to my innocence.I found that I had never truly learnt about OpenGL before. Programming in OpenGL is really hard for me. There are so many features in the OpenGL. Often, to successfully render an image on the screen needs a lot of call for APIs. I was kind of lost  and often forgot something, then I spent a lot of time finding those bugs. One problem was about the indices type. Meshes are deformed. Because the obj load source code use int type for indices. However, in OpenGL, there are only GL_UNSIGNED_BYTE and GL_UNSIGNED_SHORT.

Let me talk about what I have learnt this week. I learnt how to use the framebuffer of OpenGL. There are many attachments for a frame buffer, like color and depth. We could render both to buffers or texture objects. In my project, I use rendering to texture. In the glsl, we could directly write to the buffers, by specifying the out variables in shaders, also don't forget to give the out variables locations, so that the OpenGL know which variable write to which buffer.

Now I have a new problem. I don't know how to output two depth maps from just one shader. I input two transformation matrices and pass two position vecs into fragment shader .In the fragment shader, write them into output textures. Unfortunately,  this method doesn't work..T T..


Monday, December 3, 2012

Falling Snow

Until now, I didn't get much progress.  I only get the snow falling works partly.

The theory is simple. First generate random positions for snowflakes as well as scales. And then according to the depth of snow, calculate the alpha value of color. Essentially, a snowflake is just simple squares. What makes them look like snowflakes is the texture attached to the squares.

Although the method is simple, I encountered problems in the implementation. The biggest obstacle is that I am  a beginner for three.js library. Due to the fact that the three.js library is not complete yet, some tutorials codes even cannot run on my machine. I have to spend much time to fix it. That is exact the reason my snowflakes are still squares. I don't know why I could attach texture to the squares, although I did exactly as the tutorial. For the animation, as usual, I do it in the vertex shader.





Thursday, November 22, 2012

Snow Shading Kick Off

Finally, I choose to do snow shading for my final project. I like snow, it will be interesting to construct a snow white world. There are two parts in this project: snow accumulation and snow fall. After some research, I started to get some ideas for snow shading.

Snow Accumulation
Snows distribution differs for different terrains. This is determined by the height and gradient.  I need to calculate the coverage of snow of terrains: terrains may be exposed to the snow or not, heights of accumulated snow also varies. How to calculate exposure? We could transform models into ortho view from the point of sky. And then use the depth to determine whether points are occluded. For the accumulation heights, use the normals to get them. While rendering the snow, we also need some noise to make snow Glisten.

Snow Fall
http://oos.moxiecode.com/js_webgl/snowfall/
This is the result I want.
First I need a function to generate snow in a 2D plane and  give snow a random depth. Then determine the size and  blur effects due to its depth. Maybe I could also design different shapes for snow.

Hope my final project goes well!!

Reference:
http://http.download.nvidia.com/developer/SDK/Individual_Samples/DEMOS/Direct3D9/src/SnowAccumulation/Docs/SnowAccumulation.pdf
http://jimbomania.com/software/snowfall.html
http://171.67.77.70/courses/cs448-01-spring/papers/fearing.pdf

Wednesday, November 21, 2012

GLSL2

Here are some results from this project.

Feature implemented:
  • Bump mapped terrain
  • Rim lighting to simulate atmosphere
  • Nighttime lights on the dark side of the globe
  • Specular mapping
  • Moving clouds
  • water animation
  • Space Screen Ambient Occlusion
  • Vertex Morphing(Morphing between a sphere and the cow)(Press M/m button, N/n for pass shader)
  • Vertex Pulsing(Press P/p button, N/n for pass shader)



Something is not normal about the vertex pulsing, although I move vertices along normals. I believe the reason is that a single vertex have many normals in the buffer, so when I move vertices, it have many directions. As a result, the cow becomes explosive.


12 * 12 Gird



4 * 4 Grid

Friday, November 9, 2012

GLSL Programming


filters:
* Image negative (3)
* Gaussian blur  (4)
* Grayscale      (5)
* Edge Detection (6)
* Toon shading   (7)
* Pixelate       (8)
* Contrast       (9)
* Swirl          (0)

Vertex Shader:

* A sin-wave based vertex shader:
* A simplex noise based vertex shader:
* Hat like vertex shader