[SOLVED] Change cloud material parameters at runtime


Recommended Posts

Hi there


I'd like to access the parameters of the cloud material to simulate different wind at runtime. We need a controlable environment, in which the user can define the specific wind power and direction and the clouds should react correctly to those.


Is there a possibility to get a handle to the velocity and the angle of the animation settings?


Thanks in advance

Link to post

Hello Paul,


Cloud simulation is done in C++ part of the engine so the best place to change something is inside Clouds class. You'll have to have source license though.


However, you can try to make your own cloud simulation in the script. For example, you can fill a 3d texture with cloud density data and write custom material with approptiate shader and that's it.


Also, you can simulate some effects such as wind via particle system.

Link to post

Hi unclebob


does the full license limitation also apply to changing the parameters of a ObjectVolumeBox used for fog? Or can I access the Power and Multiplier parameters during runtime?



Link to post

Hi there, Renato!


There's no restriction in changing material parameters at runtime. It's quite simple, all you need to do is to change volume_power and volume_density material parameters like in this code:


You can find such code in samples/objects/volume_00 example.

Link to post

Hi unclebob


I tried this one already with the following code example, but without any result, so I thought, maybe it's a limited feature.

ObjectVolumeBox visBase2Middle = engine.world.getNode(1755834813);

if (visBase2Middle != NULL && visBase2Middle.getType() == NODE_OBJECT_VOLUME_BOX) {
	visBase2MiddleObj = node_cast(visBase2Middle);

visBase2MiddleObj.setMaterialParameter("height_falloff", vec4(0.5f), 0);



Link to post



No, it's not limited. Have you set material "height" state to one before setting "height_falloff" parameter?

Link to post

I found a solution to access a pre-defined material:


In my environment.mat file I defined the fog as below:

<material name="base_to_middle_fog" parent="volume_fog_base">
	<blend src="src_alpha" dest="one_minus_src_alpha"/>
	<state name="height">1</state>
<parameter name="diffuse_color">0.778431 0.529412 0.6 1</parameter>
<parameter name="volume_power">1.7</parameter>
<parameter name="volume_density">1.73085</parameter>
<parameter name="height_falloff">0.09</parameter>

In the script-file I access the material this way and change for example the "height_falloff" parameter.

Material fogMat = visBase2MiddleObj.getMaterial(0);
fogMat.setParameter("height_falloff", vec4(0.5));


Link to post