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)
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)
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:
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.
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.
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.
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
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.
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
@3D Upgrade Thank you, yes it’s not a prank, it’s real. Nice tutorials by the way, I have taken a quick look to them.
@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!