Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

Vertex / Pixel Shaders (aka Wavy Grass)

From UamWiki
Revision as of 18:39, 5 May 2011 by AndyLegate (talk | contribs) (Created page with 'This tutorial will only work for Ages that are designed for a MOUL type of server. This component will not work with Stand Alone versions of Uru, such as Uru:CC, nor will it work…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This tutorial will only work for Ages that are designed for a MOUL type of server. This component will not work with Stand Alone versions of Uru, such as Uru:CC, nor will it work on ALCUG servers.

If you link in to say Eder Tsogal, stop and take a moment to take a look at the grass and cattails there. You'll notice that they seem to be swaying in a gentle breeze.

You can do this by taking the mesh of each and animating them, then setting them for a animation loop.

But doing so would be very tedious work on your part, and it would also be a resource hog for the game.

Instead, there is something we can do to achieve the same affect on certain things, like grass planes or bushes. And that's use the Vertex / Pixel Shader for Grass, also known as the Grass Shader Mod.

If we open up Eder Tsogal with PrpShop, you can click on a scene object called "dGrasspatch01". The little "d" in the name denotes that it is a Distributor object (meaning that the Distributor Tool was used to make copies of it and spread it in certain areas of the Age.). However the more important thing to note, is to see the component that is assigned to it: plGrassShaderMod.

We can take it a step further and look at the component itself. Here is the xml code for it in the prp file:

<plGrassShaderMod>
	<plKey Name="cShdrGrass_2" Type="plGrassShaderMod" Location="12;1" LocFlag="0x0000" LoadMask="0xFEF0" ObjID="1" />
	<SynchParams flags="0x00000000">
		<ExcludePersistentStates></ExcludePersistentStates>
		<VolatileStates></VolatileStates>
	</SynchParams>
	<Material>
		<plKey NULL="True" />
	</Material>
	<Waves>
		<plGrassWave DistX="0.200000003" DistY="0.200000003" DistZ="0.1000000015" DirX="0.200000003" DirY="0.05000000075" Speed="0.1000000015" />
		<plGrassWave DistX="0.200000003" DistY="0.200000003" DistZ="0.1000000015" DirX="0.05000000075" DirY="0.150000006" Speed="0.1000000015" />
		<plGrassWave DistX="0.200000003" DistY="0.200000003" DistZ="0.1000000015" DirX="-0.1000000015" DirY="-0.150000006" Speed="0.150000006" />
		<plGrassWave DistX="0.200000003" DistY="0.200000003" DistZ="0.1000000015" DirX="-0.150000006" DirY="0.1000000015" Speed="0.150000006" />
	</Waves>
</plGrassShaderMod>

As you can see, we have some displacement going on with velocity (and that equals motion).

So let's do this ourselves.



Getting Started

You'll need to have at least one grass plane or one object of planes set up to look like a bush (please note: your planes for your bush can not be separate objects, but must be all one object).

To assign the Grass Shader Mod, call up the component manager, and click on New > Vertex/Pixel Shader > Grass and assign it to your grass (or bush) plane.

Grpix1.jpg

Look at the roll out for it.

Grpix2.jpg

In the drop down box, you'll notice that you have 4 waves you can set. This is to keep the grass movement from looking to repetitive. The values you assign for each wave should be different. It's pretty easy to figure out. Large values will give you large movement and speed, where as smaller values will give you smaller movement and speed. Don't be afraid of using negative numbers, as the X, Y and Z coordinates have such values. If you don't use some negative values, your grass will look like it only bends in one direction, heheh.

If you do this to one grass plane, and then use the Distributor Tool to have many different grass planes on your surfaces, the Grass Shader Mod will be on them too.

You can have several different planes with these mods on them, but you can not have more than one mod on each plane.

That's all there is to it! Here's a video of it in use in Serene on the bushes there.

http://www.youtube.com/watch?v=78tGFf7lLEk


Return To: Andy's Max Tutorials