GLSL Wind Shader v0.2 [UPDATE 15.04.17]

(Another older video:https://www.youtube.com/watch?v=tcrEEATyqoI)[INDENT=5]

The Shader reproduce basic blender materials
and give them a configurable wind movement

[/INDENT]

UPDATE 15.04.17:
- add support for normalmaps (Tangent space)

  • add support for material color (non texture materials)
  • python component settings rework
    -> add different material types (Diffuse Texture, Material Color, Diffuse Texture (Fast Lighting), Material Color (Fast Lighting), Diffuse Texture + Normalmap, Material Color + Normalmap)
  • some other small changes in the shader code

Download:

BGE/UPBGE:
Wind shader_v0.2.zip (12.8 MB)

UPBGE optimized (More Info: post #13):
Wind shader_v0.2_upbge.zip (8.6 MB)

There are 3 different examples. One example use pure python to assign the wind shader via a predefined windshader class.
The other two examples assign the wind shader via python components (the easy way with an UI -> see picture below), but it requires upbge or the Python Component Addon:

https://upbge.org/
https://blenderartists.org/forum/showthread.php?393763-Python-Components-Addon

Normally the shader should work on Windows, Linux, and Mac, tested on:

Windows 10 (NVIDIA Geforce GT 540M/Intel HD Graphics 3000)
Linux Mint Mate (NVIDIA Geforce GT 540M)
OS X 10.11 (NVIDIA Gefore 8400GT)

***

Details:

Shader settings:

  • Material name
  • diffuse texture: Texture slot, texture coordinates scaling
  • Wind settings: strength, speed, object deformation, bending, groundlevel (minimum height):
  • lighting -> Point/Sun/Spot/Hemi (currently locked in the shader to max 16 lights)
  • optional you can use per vertex lighting (instead of per pixel) for better performance (recommend for alpha textures))

BUT: the BGE can’t detect Hemilights via python! So every hemilight need property called “type” with the value “HEMI” otherwise it will be detected as point light except you use upbge.

  • also there can be a shadow bug, where casted shadows from shader materials are static and don’t move
    To avoid this issue activate Transparency for the material and select Z Transparency or change the Alpha Blend mode from Opaque to something else, even if you don’t use alpha.

Here you can see all supported settings at a glance:


Limitations (at the moment):

  • no setting for the wind direction

  • no specular shader models (also already available in the shader)

  • no environment lighting (because there is no python api)

  • can’t receiving shadows (because Blenders shadows don’t work right in custom shaders for me: See)

WIP/planned/possible features:

3 Likes

Hello !
Why trunks have static shadow while leaves have dynamic shadow ?

As mentioned above:

  • also there is a shadow bug, some shadows from shader materials are static and don’t move (for example the tree trunk, I don’t know why)

I don’t know whether it’s my fault or it’s a blender bug, normally it is the task of the engine to generate the shadows. I’m sorry.:frowning:

great job, and thanks for sharing this

I make a little update: (Download for the new version 0.1a is in the first post.)

Now the shader should work also on mac osx (only tested on an old mac book pro, OS X 10.11).
(Seems like apple’s driver have some problems with the combination of structs and integers uniforms so the
struct for light uniforms was replaced with arrays to fix a bug with integer uniforms on mac osx)
Also the shader can be affected by the emit value in the material tab now.

I also have edited the start post a little bit and add an image that shows all supported settings at a glance:


Thank you very much for this. However it does not seem to work in overlay scenes. The textures show up as black. Any ideas or workarounds? To reproduce my issue add a scene to demo files (I am using upbge w/ a component) and an empty with an always sensor to load the original “Scene” and play.

Oh I think I know the problem and I already have a fixed version but I haven’t done a release for it. I will upload it later.
:wink:

*taps desk patiently waiting update…

Sorry, now version 0.1b is available (See download in the first Post) that should fix the bug with the overlay scenes/scene restarts and multiple scenes. I hope everthing works fine.

Maujoe

Working now! Thank you very much.

What is the possibility of getting normal maps working? You say the script already supports it? Any tips on how to implement it? I’ve been playing with this a lot the past couple of weeks.

Hm yes, currently the code for normalmaps are not in the release version but I have it hardcoded in my test version of the shader. The problem is that I don’t want to write x-versions of the same shader for every material setting combination and checks inside the shader would make it slow.
(Actually my plan was to create a little, flexible shader system that I can use generell for all my shader projects to solve that problem but it’s not finished yet.)

The next days I haven’t much time but maybe in a few days I can take a look at it again, maybe I can publish a basic shader version with normalmapping support at least.

Version 0.2 has been released:

The release features are support for tangent space normal maps and material color. Now the material color can be used instead of a Texture. If you use the Python component you can set the material type in the component UI.

Version 0.2 and future versions will be released in two versions, one version is compatible to BGE and UPBGE and the second version will only optimized for the use in UPBGE because upbge provides some more settings and features. Big THANKS to the upbge-team :slight_smile:

Here are all currently supported settings and differences in UPBGE at a glance (Will be more in the future):



I also have figured out how to avoid the shadow bug. If casted shadows from a shader material doesn’t move, activate transparency for the material and select Z Transparency or change the Alpha Blend mode from Opaque to something else, even if you don’t use alpha.

List of WIP/planned/possible features:

Thanks a lot for this. Haven’t had any time lately to play with the updates yet.

It’s working great, thanks

Thanks for the Feedback. New updates will come soon when my Internet connection at home works again.

Hey the shader looks great, i downloaded the file and all three are working great. But am not exactly sure on how to install the addon and py scripts. I tried copying the code from the example where you used only python and it works okay on the leaves but the trunk is static. Please if you dont mind can you explain on how to use the addon and components

When I read Wind Shader I thought it was a joke but it looks great. Kind of has that Far Cry 2 feeling.

can anyone please help me on how to use the files. do i put them in the scripts\addons file or ??

@3D Upgrade Thank you, yes it’s not a prank, it’s real. :smiley: Nice tutorials by the way, I have taken a quick look to them. :slight_smile:

@bright1 Sorry, I haven’t seen your question. Thats’s a good point I will add it to the start post in the future.

It’s not an addon, it’s more like a library, your just need to copy the “custom_shaders” folder in the directory of your Projekt (Blend file) and attach the shader to your objects via Python/ -components like in the examples. If you use Python components you should call it with “shader_components.Wind”.

Things to consider:

-The origion of the object should be on the bottom of the tree (roughly) because it will be used to determin the ground level (no wind area) you can adapt it also with the ground level setting. <-- maybe thats the reason why your trunk don’t move.
-Also the scale of the object should be applied (Objectmode -> ctrl+A -> Scale)
-The trunk and the leaves should have the same wind settings otherwise they are out of sync (it’s a limitation at the moment).

I hope, that helps you. If you have any further questions, just ask! :wink: