PDA

View Full Version : Interactive Foliage with Wind Material.



A Rabbit
02-16-2010, 09:32 PM
Here is a basic material setup which combines the "Wind Direction and Speed" node with the "Foliage Normalized Rotation Axis and Angle" node into the world position offset.

This setup is used with an interactive foliage actor and a wind actor. It makes the foliage rotate when it is touched taking vertex colour into consideration and also recreates a wind effect using the data from the wind actor in your scene. The advance material takes the object world position and uses it to create a wave affect over a field.

Hopefully this will help someone:

Advanced:
NEW Material Snippet (http://4.bp.blogspot.com/_u1s16bXmyZo/S38t8Gl2aDI/AAAAAAAAABc/k6bBzow7BU0/s1600-h/VertexShader_InteractiveFoliage.jpg)

Basic Setup:
OLD Material Snippet (http://3.bp.blogspot.com/_u1s16bXmyZo/S3tOTWbU8ZI/AAAAAAAAAA8/0RLs8zmUcis/s1600/SS9_IFSnippet.jpg)


Feel free to add interesting and more advanced material setups for interactive foliage. :)

*Edit - Youtube link:
NEW:
New vertex material. (http://www.youtube.com/watch?v=VG6kUnX2eXg)

OLD:
First vertex material Test. (http://www.youtube.com/watch?v=sbSN55tcmvc)

ShadeMistress
02-17-2010, 02:42 AM
Looks interesting. I'm not yet sure if I am going to include interactive foliage actors, but if I decide to try it I'll give this a shot and see how it works. :) Thanks

Denny
02-17-2010, 02:43 AM
Oh, I never managed to get that wind stuff to look good, nice to see how to set it up. You don't happen to have a video on how it looks?

A Rabbit
02-17-2010, 06:26 AM
Ye sure ill upload a video in a short while, this is a basic setup however I believe randomising the wind effect even more is achievable. Using the object world position I think its even possible to add delays to each individual piece of foliage.

A Rabbit
02-17-2010, 08:29 AM
Heres a video of this setup in action:

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

Forsaken
02-17-2010, 08:53 AM
that looks really nice.
Also the snippet could be very useful.
A tutorial video would be awesome.

ThePriest909
02-17-2010, 09:04 AM
Very nice work, thanks for sharing the structure!!!

Denny
02-17-2010, 10:27 AM
Some kickass results, the assets looks really good.

A Rabbit
02-17-2010, 11:03 AM
Thx :) its a wip but coming along quite quickly, two of us are working together to build a game for our final major project at Uni. Im currently working on a more advanced material that I'll post once i'm happy with it.

A Rabbit
02-17-2010, 11:09 AM
that looks really nice.
Also the snippet could be very useful.
A tutorial video would be awesome.

I'll see what I can do when I get the time ;)

Forsaken
02-17-2010, 12:11 PM
I'll see what I can do when I get the time ;)

you would get a place in my heart for ever. :D
thanks

Hendrixlt
02-17-2010, 02:43 PM
Heres a video of this setup in action:

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

Couldn't help but notice around the 10 - 15 second mark that you were able to rotate the camera to face the front of the character. Is that intentional, and if so, how did you do it?

A Rabbit
02-18-2010, 06:10 AM
Couldn't help but notice around the 10 - 15 second mark that you were able to rotate the camera to face the front of the character. Is that intentional, and if so, how did you do it?

My codes a bit scruffy as I'm still learning but I can point you in the right direction. The key lies in editing the UpdateRotation function in your playerController. All you have to do is hook up a bind and an exec function that changes a var on the key press, in my case it was the middle mouse button. The UpdateRotation function then has an if statement that checks the free-look var, depending on the status of your var it will deactivate the updateRotation code.

Not sure if that makes any sense lol.

BloodReyvyn
02-18-2010, 06:14 AM
Video looks really nice, going to try this with a few meshes and have a close-up view of the results. Thanks man. Looks really cool...

If I am understanding correctly, the InteractiveFoliageActor is no mare taxing than a static mesh, but has the drawback of having static lighting even when it is moving correct?

pipesfranco
02-18-2010, 06:17 AM
Any chance on the tutorial being posted on Youtube...are we close?

Cheers

A Rabbit
02-18-2010, 06:55 AM
If I am understanding correctly, the InteractiveFoliageActor is no mare taxing than a static mesh, but has the drawback of having static lighting even when it is moving correct?

I believe the overhead is very, very small which means you can use it extensively. I think your right about the static lighting also, however I dont allow shadow casting on any of my ground foliage to keep frame rates up anyway.

BloodReyvyn
02-18-2010, 07:53 AM
Where exactly am I supposed to put this material?

I was looking around the actor properties, but didn't see any way to reference this material. Maybe I missed it?

Is the overhead for generating static shadows that much? I thought it was all handled by static light maps. Sure, it takes a little longer to build the lighting, but I didn't see any change in FPS.

A Rabbit
02-18-2010, 08:45 AM
Where exactly am I supposed to put this material?

I was looking around the actor properties, but didn't see any way to reference this material. Maybe I missed it?

Is the overhead for generating static shadows that much? I thought it was all handled by static light maps. Sure, it takes a little longer to build the lighting, but I didn't see any change in FPS.

Set this up in the static meshes material, with the all the other textures. :)

I believe handling a lot of foliage/grass its best to turn off shadow casting to increase performance: http://forums.epicgames.com/showthread.php?t=713119

BloodReyvyn
02-18-2010, 06:28 PM
Okay.... This is probably annoying, but I have all but one part of this set up... Where did you get the "Mask" nodes? They do not exist as far as I can tell and I have been looking for over an hour.

BloodReyvyn
02-18-2010, 06:35 PM
Also, plugging this setup into the WorldPositionOffset locks up my entire computer.

A Rabbit
02-18-2010, 08:51 PM
The mask node is called "Component Mask", it's always a tricky one to find.

As for the freezing, im not really sure. Try plugging in just a constant3vector with the value of (0,0,100). That should at least show you that the offset is working, as it will move your object. The great thing about this offset is that you can animate move/rotate static meshes and can even grab the vertex colours to move and rotate different parts of the mesh.

BloodReyvyn
02-18-2010, 08:59 PM
I'll give that a try later and let you know how it comes out.

Right now the only things affected by wind are my foliage actors that are on the terrain layer itself, so I am hoping to have some interactive foliage as well to try and detract from the fact that the trees aren't moving (SpeedTrees are just too much of an FPS killer).

It would also be nice to have foliage at the ground level that would move if an enemy is approaching, so that if the player is paying attention, they won't be caught off-guard.

A Rabbit
02-18-2010, 09:14 PM
Kl, Speedtrees arn't that bad if you have all the Loding setup for them, add a bit of fog and you will never see the transition.

BloodReyvyn
02-19-2010, 12:48 AM
I don't know if there's a special setup for SpeedTrees I missed, but my furthest LODs start to show long before any of the closer ones vanish. This has lead to many crashes with Lightmass, so I ditched them at least for the time being to build my map up with at least meshes.

Anyways, I haven't been able to get this to work yet, it just crashes UDK if I try to plug the Add node into the Material. Some of your numbers, most notably the decimal (I think) constants are hard to read at that resolution.

I don't know if you can, but a higher resolution image would be a great help.

And BTW thanks again a few times over. I really think this is a cool effect and you've been really supportive in helping get it working. Saves me a lot of frustration trying to figure it out. :)

BloodReyvyn
02-19-2010, 01:17 AM
Nevermind, I forgot to plug a multiply node, it's lookin sweet now... Awesome! and thanks again.

A Rabbit
02-19-2010, 05:58 AM
Np, the decimals I mainly for custom tweaking depending on your vertex wieght.

Ill be making a tut as soon as I have this new material made (got sidetracked).

BloodReyvyn
02-19-2010, 06:04 AM
That's fine. I got it working nice and been messing with both the values of the foliage itself and the material.

It's coming along quite nicely and I only saw about a 5 FPS drop, which is nice since I am going to have so many of these strewn about the map. It makes for a nice visual reference for when an enemy is trying to sneak up through the foliage.

ThePriest909
02-19-2010, 07:20 AM
I suppose the interactive foliage should not cast any shadows right?
Cause as it seems over here the shadow casted is based on polygon's shape and not the masked material.

BloodReyvyn
02-19-2010, 02:19 PM
Yeah, at the very least you should disable dynamic shadows because if you use a lot of interactive foliage, it will get taxing on performance anyway.

A Rabbit
02-19-2010, 07:41 PM
I said I would post a more advance vertex material when I finished it. So here is a realistic wind setup with an object world position offset to make the sway delay between each foliage:

http://4.bp.blogspot.com/_u1s16bXmyZo/S38t8Gl2aDI/AAAAAAAAABc/k6bBzow7BU0/s1600-h/VertexShader_InteractiveFoliage.jpg

Enjoy & Ill post a video soon. :)

*Edit* - New vertex material video (http://www.youtube.com/watch?v=VG6kUnX2eXg)
I have also updated the first post to show the new material setup.

miatribe
02-20-2010, 02:25 AM
Wow looks great now!

Took me ages to copy that lol (and then it diddent work)

A Rabbit
02-20-2010, 04:08 AM
Might sound daft but have u got a wind actor (WindDirectionSource) in your scene? What exactly did it do?

dvaessen
02-20-2010, 04:29 AM
Awesome, props!

A Rabbit
02-20-2010, 05:31 AM
I am hoping to make a tutorial some time within the next few days (Still trying to find the time).

BloodReyvyn
02-20-2010, 06:52 AM
Tried the new material setup you posted, but it shows the default checkerboard material on the preview and on my meshes.

In the material editor it says : "error X3004: undeclared identifier 'b'"

BloodReyvyn
02-20-2010, 06:59 AM
nevermind, I accidentally capitalized the "B" node when I named it.

ThePriest909
03-01-2010, 09:38 AM
So... can this kind of material be used as foliage layer actor on terrain?
It works if I place it as individual Interactive Foliage but it doesn't work if I use it for a foliage layer.
Any ideas?

Denny
03-01-2010, 11:06 AM
Doesn't work with deco layers. There is another way (http://dennylindberg.com/downloads/maya-t3d-exporter/) though. ;)

ThePriest909
03-01-2010, 11:52 AM
Doesn't work with deco layers. There is another way (http://dennylindberg.com/downloads/maya-t3d-exporter/) though. ;)

Thanks Denny!

Denny
03-01-2010, 01:00 PM
You're welcome, hope you find it useful. :)

A Rabbit
03-03-2010, 11:24 AM
Wow nice tool! that will come in handy.

On another note Iv managed to modify the material to work with hanging vines (There was a few problems with the orientation and simply reversing it doesn't work), ill be showing some ingame examples in a few weeks, check out my progress at: www.outlastgame.blogspot.com

Denny
03-04-2010, 02:33 AM
I know people don't tend to read comments on Blogspot so I'll type it here instead. I saw you tried to bake ambient occlusion to vertex colors, after you bake the ambient occlusion to a texture file you can apply that texture file to the vertex colors. Simply go to (menu) Color > Paint Vertex Color > Option Box > Attribute Maps > Import. :)

A Rabbit
03-04-2010, 12:29 PM
O nice thx Denny, that will do the trick, very helpful.

frozenfire2
03-09-2010, 02:14 PM
hi does this work for MULTIPLE actors per patch of foliage, since the shader can only be passed ONE value?

Denny
03-09-2010, 03:30 PM
It's per actor yes.

Kornswag
02-13-2011, 08:50 PM
Great tutorial, thanks!

JmPrsh153
03-15-2011, 04:23 PM
hi i am having an annoying problem and this is the coding i type in the custom node:

float angle = b;
float cosAngle = cos(angle);
float sinAngle = sin(angle);
float3 A = float3((a.x*cosAngle - a.y*sinAngle),(a.y*cosAngle + a.x*sinAngle),a.z);

return A;

and i cant seem to get the message to go away, im sure im doing it right

HelixEffect
04-16-2011, 01:30 PM
Are you sure you have both the inputs as lowercase/upper case depending on the code you put in the custom? You may find you have made the inputs upper case therefore voiding the code

HelixEffect
04-21-2011, 08:09 AM
I'm having an issue with the foliage. After I have created the material to be an exact replica of what is shown on this thread when I port it into my level ... nothing happens. It doest react when I touch it and it doest react to the wind actor it just sits there looking quite stale. Is there something I might be doing wrong? I've added it as a Foliage Actor as well

Furyia
05-03-2011, 01:02 PM
This is really bugging me I've got an error and a warning, I just followed the screenshot but I'm a complete noob so I've probably missed something that seems obvious to others..


warning X3206: 'tex2D': implicit truncation of vector type
error X3004: undeclared identifier 'b'

Fixed it:

Select the Custom node, drop down list and type in the Input Names. 'a' and 'b'.


---


GAAAAAAAAAAAAH. No errors but now the mesh isn't showing, I'm pretty sure it's me just being a complete tard at the moment but what I've done is got the S_CloverPlant_01 mesh, plugged the original texture into diffuse, plugged all the interactive stuff into the correct one. Then I've just changed the material on the cloverplant to the new interactive material..


--


Got them to show by reopening UDK but they don't move in any different way to the normal InteractiveFoliageActor plants. Also the material on the cloverplant mesh keeps reverting back to the original!

What am I doing wrong? Can anyone help me, please?

Regga-Voska
05-05-2011, 05:58 PM
Okey, so I have basicly copy/pasted your material...

http://dl.dropbox.com/u/6117552/attempt.jpg

But it just dont work, so... Any ideas? =P

Edit: BTW, what currently happens to the meshes with this material applied is...
1st it moves instant down along the Z axis, there is no transmission or any kind of animation.
2nd its scale decreases by ~25-40% somehow, wuuuut?
3rd it does not interact with the wind or the players.

Furyia
05-06-2011, 02:35 PM
Still doesn't work for me either. Some form of response or help would be great :/

CorvaenOboros
05-13-2011, 08:06 PM
to everyone having difficulties , go thru it all carefully , replicated the material with no problems.
many thanks A Rabbit

Regga-Voska,
noticed a few errors in your mat ,
from the ObjectWorldPosition in lower right corner your Component Masks should be R and G , currently you have R and R.

then from the FoliageNormalRotationAxisandAngle you have the Masked RGB and A going to the wrong nodes next. Masked RGB goes the the multiply , and A goes to the Append.

pedroagodoy
07-08-2011, 08:56 AM
Hello!!! Has anyone tried this material with the new foliage system UDK June 2011??? the system seams to group then together and animate as one it looks really weird.

other thing, the only way to use interactive foliage is place then one by one???

thanks...

sorry for the bad english :(

LucasWalter
11-23-2011, 09:35 PM
I am sorry for asking this if it is an easy solution, but I cant for the life of me figure out how to paint interactive foliage actors. When using this material in the tutorial, do I have to place each mesh individually or is it even possible to paint these? Thank you.

Snipe34
04-13-2012, 11:22 PM
I had the same issue - coding stuff XD - probably a wandering decimal -------> . OMG is that it?!

My solution was copy /paste. I looked in PivotPainter_Example.udk map and traced the mesh to materials, and also to the material instance. I copied the massive instructions from the Material into my own custom Material. To copy: hold ctrl and alt - drag mouse over the entire massive Material instructions (and I had to widen the sides to grab it all), then ctrl-C. Then next, inside your own Material, right click and: Paste Here, which is at the bottom of the list. Then finally, I duplicated their Material Instance but put in the custom Material with the copy/paste instructions. 'My' custom grass waves around fine.

Note: I will learn how the foliage system works eventually. Copy / paste isn't my preference. I see some UDK tutorials mention: 'your development team' and that would be me, me and me. So I need all the help that me can get because 'me' flags a little, and needs boosting by seeing stuff actually work, thereby motivating me to continue. Me needs that positive feedback, whereas, I, as team leader with the overview, has no problems with motivation ^^

EDIT2: use SimpleGrassWind for a simpler but ... it looks very effective for foliage. In your Material - Material Editor, look on the right listed under World Position Offset: SimpleGrassWind is below RotateAboutWorldAxis_Cheap and above SplineThicken.

SimpleGrassWind has 3 inputs, (I forget the inputs' name) press 1 key and it appears. Plug them to: WindIntensity and WindWeight. I set both to 1.0 AdditionalWPO set to 0.1
Finally I plugged in 'Result' to WorldPositionOffset of the tex input.

The slightly waving effect is exactly what I want, and that setup took only a minute.

Judgement45
08-03-2012, 03:18 AM
Thanks for the Material Snippet and Hope you're project is going well, it looks great so far.