Wind shader (tree, plants, grass)

Hello (sorry for my english)

I see this video:

But can not this create. I want to create a similar shader effect (Crysis It has also)

Any idea?


It would be best .blend example, but when I’m on PC i try. Oh, thank you very much for fast reply!

I don’t believe the script is set up for Blender, just for glsl for some other engine. It needs to be adapted (I’m not the best person to do this…)

Thank you, but my skill not so high :frowning:

Ok, I m try used logic editor Random - And - Servo Control and setting linear velocity value. Works fine :slight_smile: But not perfect. Here is video

But work only soft body plants, not a no collision gras :frowning:

Got a start on this - in the video that the OP showed, the person said that it works via vertex painting. So, that would probably be a good start. The outer edges of the tree leaves could be painted, thereby telling the shader to make those vertices move and sway.

EDIT: But mostly I’ve just been messing around with getting nice-looking trees by applying normal / spec / AO maps and stuff. :stuck_out_tongue:

I always searching this wind vertex shader tutorial on blender :frowning: nothing… nobody nothing new?

@MrPutuLips, by having a brief look at that shader, it seems to just modify the UVs , so it won’t work on anything except alpha leaves. Also I don’t think that there’s a way to input UV data in GLSL shaders.
Edit : it doesn’t change uv , but just the projection matrix.

@OP, You can make a simple script that applies random movements on vertices within a varying range.

I can not create this simple script for random movements :frowning:

Jackii’s solution is probably to be used over a shader-based one currently, as there seems to be a bug in which objects can’t share shaders (which kind of invalidates a huge part of it if only one object can use a specific shader at a time). Altering the vertex values directly allows you to share this between duplicated objects (other trees that use the same mesh, for example).

Well I just tried it but, vertex manipulation seems wierd, it’s as if the vertices are separated in every polygon, and also there’s a wierd python problem, for somehow I can no more create a variable once only, (if not blabla in own: own[“blabla”] = value) kindof doesn’t work, I was using it to get the initial position of vertices. so the deformation is always applied for the last position, not the initial position which basically destroys the mesh.

Blend file:


windtest.blend (481 KB)

There’s no bug with Python - you’re attempting to create it once if it doesn’t exist already, but there’s only one variable and however many vertices for the mesh. You need to loop through the vertices first and append their position to a list, and then go from there with the actual loop. If you give me a sec, I’ll make an example.

EDIT: I made one, but it runs kinda slow. Oh, well. I forgot that a shader runs faster (on the GPU) than pure hardware access. :stuck_out_tongue:

It can run faster (by only moving certain leaves, not ALL of them), and the tree’s kinda high-poly as well, so maybe there’s hope for it yet.

EDIT: Okay, hereit is. Managed to speed it up a bit by only moving the vertices of leaves influenced by vertex color (which is, actually, how they influence which leaves are moving in that video, I think).

I also think you could loop through a small selection of all of the vertices per frame (i.e. 1/10th of them all, so every 10 frames it would start at the beginning and move them). It might be effective if the movements aren’t too large and you could loop quickly enough.

Wow Jackii although it is not vertex shader wind, is perfect idea for shaking leaves :slight_smile: thanks!

But have a plane problem

windtest2.blend (502 KB)

I uploaded my example in the previous post that should work okay.

Thank you very much SolarLune! Perfect work I really appreciate it!

Hey SolarLune, I m testing your shader, but work only your tree leaf hmm. Here (see plane)

EDIT: oh, material must be name “leaves” sorry :smiley:

@SolarLune, I just discovered my stupid mistake. Actually there’s no need for a list , I just needed to make “initial position” an attribute for vertex not own.

Your example works perfectly!

Thanks, you guys.

EDIT: I was able to confirm that altering the vertices slows the Rasterizer down considerably, and leaving them alone enables the Rasterizer to continue well, too. I’m thinking that this has something to do with Display Lists, as disabling them without the script also runs slower than having them enabled without the script. I wonder if it’s possible to have Display Lists activated even in case of vertex operations…

I have a last one question, can be add multiple material to script? “if “leaves” in mat_name:”
etc if “leaves,grass,leaves 1"in mat_name:” ?

Hmm my Python skills is very weak I must study more this programming language and English too :smiley:

Hello, I didn’t see this. Yeah, it should be possible. Your proposed syntax is pretty close - instead of

if "leaves" in mat_name:

it would basically be

if "leaves" or "branches" or "whateverelse" in mat_name: