Marco Tarini's Windy Flora

From Mount&Blade Modding Wiki
Jump to: navigation, search

As seen in The Last Days mod for Mount&Blade 1.011, Marco Tarini (mtarini), the creator of OpenBRF added a good bunch of custom shaders, that he released in the latest patch. This is an interesting bit of a vertex shader allowing us to make life-like waving trees and grass:

   float windAmount = sin(time_var*0.1014) + cos(time_var*0.1413);
   windAmount*=windAmount; 
   float2 treePos = float2 (matWorld._m03, matWorld._m13) + vPosition.xy;
   float t2 = time_var + dot( treePos , float2(2.5,1.5)) ;
   float windPhase = sin(t2*3.9)*cos(t2*2.3);
	vPosition.xy += float2(0.018,0.018) // *(vPosition.z+50.0)
				    *windPhase*(windAmount+0.2)
                   *vColor.w; // distance from ground stored in alpha channes with openbrf easteregg! ;)

Take a look to how the vertex height is encoded in the vertex color alpha channel of the resource file, passed as float from the game. Smart trick!

Source

Download the 3.1 patch from ModDB for the complete shader file:

http://www.moddb.com/mods/the-last-days/downloads/the-last-days-patch-from-30-to-31

Preview

The results are something like this:

http://www.youtube.com/watch?v=mWKgCEvbG6w

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox