Animated Materials ?

0
Zarbuz posted this 05 June 2016

Hi !

I want to know if it's possible to do an animated material for water/lava or there is no way (except to a frame-by frame animation ...) ?

I think it will involves multiple materials but it is not possible currently. Is it feasible or is it completely impossible to do? Thanks ! :)

Last edited 05 June 2016

4 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 06 June 2016

If the sticking point is that you require multiple materials on your chunks then I can probably add that in (just a case of having a material array instead of a single material and then passing that down to the generated chunks).

Other than that, this is more of a general shader question and I'm definitely not enough of a shader expert to advise how to do vertex animation like that.

You could perhaps use the alpha channel of the voxel colours to depict which vertices are water/lava in your shader.

All of the PicaVoxel PBR shaders are created with ShaderForge, so you can open them in ShaderForge and extend them with your own effects if you wish.

If you are able to create the effect you want and apply it to a standard Unity mesh, then I can advise further on how to apply it to a Volume.

0
Zarbuz posted this 06 June 2016

If the sticking point is that you require multiple materials on your chunks then I can probably add that in (just a case of having a material array instead of a single material and then passing that down to the generated chunks).

Yeah, I think it could be a good addition.

Otherwise thank you for the info about Shader Forge. I will try to change existing shaders, and if ever I get to the desired effect, I will not hesitate to share them!

2
robertwahler posted this 06 June 2016

This is an excellent resource for mesh manipulation in Unity.

https://github.com/slipster216/VertexPaint

Have a look at the Flow examples for Lava.

0
Zarbuz posted this 15 June 2016

I have achieved what I wanted to do really nothing complicated. Here is the code I use to make an animation of the water. The mesh is static but I play on the renderers materials to give a semblance of animation.

public class WaterVoxel : MonoBehaviour {

public Material material1;
public Material material2;
public float duration = 2.0F;
public Renderer rend;

void Start()
{
    material1 = GetComponent<renderer>().materials[0];
    material1 = GetComponent<renderer>().materials[1];
    rend = GetComponent<renderer>();
    rend.material = material1;
}

void Update()
{
    float lerp = Mathf.PingPong(Time.time, duration) / duration;
    rend.material.Lerp(material1, material2, lerp);
}

}

Last edited 15 June 2016


Our 123 members have posted 454 times in 109 discussions