Jump to content

[SOLVED] Change cloud material parameters at runtime


photo

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 comment

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 comment

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?

 

Thanks

Link to comment

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:

volume.setMaterialParameter("diffuse_color",vec4(1.0f,0.0f,0.0f,1.0f),0);
volume.setMaterialParameter("volume_power",vec4(2.0f),0);
volume.setMaterialParameter("volume_density",vec4(0.06f),0)

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

Link to comment

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);

Thanks,

Renato

Link to comment

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));

Reasonable?

Link to comment
×
×
  • Create New...