Modelling Nature
continued
by A. Nadif
XNA Meeting Point
XNA Meeting Point
Introduction
In a previous article, I tackled realism when rendering water movement. I explained several theories I have to explain the difference between the live picture and the rendered image.
Time has passed and I could find two interesting facts that I thought would be worth adding to this article about modelling Nature.
Time has passed and I could find two interesting facts that I thought would be worth adding to this article about modelling Nature.
Animating water using Flow Maps
Kyle Hayward published on his blog (graphicsrunner.blogspot.com) an interesting article that explains how to animate water using flow maps. And this is exactly what we've been talking about in the previous article.
I found his article and results pretty interesting. He also provides a source code sample for XNA 3.1. If I find the time, I will update it to the current version of XNA (that is to say XNA 4.0), and try to see if the results support the hypothesis about flows being the key to realistic water rendering.
Here, see an example of result that Kyle Hayward reached:
I found his article and results pretty interesting. He also provides a source code sample for XNA 3.1. If I find the time, I will update it to the current version of XNA (that is to say XNA 4.0), and try to see if the results support the hypothesis about flows being the key to realistic water rendering.
Here, see an example of result that Kyle Hayward reached:
As you can see, the agitated water reflects less light and the flows clearly separate the water into distinct sections.
Inaccurate water reflection
While doing some research in order to write a tutorial about rendering objects with reflection/mirror materials (that is coming soon!), I found a particular article that - it is my belief - also explains why the graphics we generate don't match reality exactly.
Well, this article is very useful for beginners and does provide a solid base for advanced rendering (especially with XNA), but there is a bit of inaccuracy to it.
The article tackles the problem of rendering water in multiple steps. First it generates a refraction and a reflection map, then it displays water as a perfect mirror, then add ripples, and finally use the maps to update the color of the water.
The calculations are based on serious math and physics that are perfectly okay to use in this context. The inaccuracy does not come from the applied formulas, but from a simplification of the problem. If you take a closer look at all the explaining images, you realize that all the calculations are made based on a plane water, which is animated with the ripples afterwards.
And this changes everything. As we could see in the previous article, reflection (and refraction too) is influenced a great deal by water movement (flows, wave patterns and noise patterns).
A good way to realize this would be to animate the water "in place", that is two say without having a general movement. Normally, the ground below the water would be deformed by the movement and thus the color would change. If you take a water made using the described technique however, the color for any given point of the water grid would be left unchanged, no matter what the wave pattern.
The reason for that is that the technique used is a projection of the map onto the water. Another way to achieve this result might have been to render the plane water with the reflection and refraction maps and then add the ripples.
Realistic rendering however implies drawing the water in 3D and use both light and normal vectors and the diffuse color in order to calculate the appropriate color for each point of the water.
Of course, this implies more complicated calculations, but since the new normals are actually taken from a normal map in that example, we could imagine using the normal map in order to generate the reflection and refraction maps. Also note that the reflection and refraction maps would now evolve as the water is animated.
There are some video games (e.g. Crysis) that appear to be calculating reflection and refraction based on the final geometry of the water, and the results are often nice to watch.
Well, this article is very useful for beginners and does provide a solid base for advanced rendering (especially with XNA), but there is a bit of inaccuracy to it.
The article tackles the problem of rendering water in multiple steps. First it generates a refraction and a reflection map, then it displays water as a perfect mirror, then add ripples, and finally use the maps to update the color of the water.
The calculations are based on serious math and physics that are perfectly okay to use in this context. The inaccuracy does not come from the applied formulas, but from a simplification of the problem. If you take a closer look at all the explaining images, you realize that all the calculations are made based on a plane water, which is animated with the ripples afterwards.
And this changes everything. As we could see in the previous article, reflection (and refraction too) is influenced a great deal by water movement (flows, wave patterns and noise patterns).
A good way to realize this would be to animate the water "in place", that is two say without having a general movement. Normally, the ground below the water would be deformed by the movement and thus the color would change. If you take a water made using the described technique however, the color for any given point of the water grid would be left unchanged, no matter what the wave pattern.
The reason for that is that the technique used is a projection of the map onto the water. Another way to achieve this result might have been to render the plane water with the reflection and refraction maps and then add the ripples.
Realistic rendering however implies drawing the water in 3D and use both light and normal vectors and the diffuse color in order to calculate the appropriate color for each point of the water.
Of course, this implies more complicated calculations, but since the new normals are actually taken from a normal map in that example, we could imagine using the normal map in order to generate the reflection and refraction maps. Also note that the reflection and refraction maps would now evolve as the water is animated.
There are some video games (e.g. Crysis) that appear to be calculating reflection and refraction based on the final geometry of the water, and the results are often nice to watch.
Conclusion
Well, I hope these two articles were useful. And I hope that thanks to what was shown here you'll be able to model realistic water.