Home Coding, Scripting, Shaders

Programming Array Animation?

SuperSparkplug
polycounter lvl 9
Offline / Send Message
SuperSparkplug polycounter lvl 9
Hi there,

For one of my projects, I have a bunch of independent cubes arranged in a grid in my environment. During my animation, I'd like the cubes to randomly switch between 2 shaders independently every 5 seconds. however, I have no idea how to do this in Maya nor how to program in Maya (never touched Mel or Python). An example would be just like the cubes in the environment of this game.

In something like Unity, I'd imagine it would involve putting all the cubes into an array and programming it to randomly choose a cube and change the shader, then change it back upon switching. I'd like to try finding a way to do this in Maya though since I'm not using other programs for this project.

I'd greatly appreciate any help with trying to programatically animate this.

Replies

  • monster
    Offline / Send Message
    monster polycounter
    If it's just in Maya use a blend node and animate the Blender property. This won't export to Unity.


  • RN
    Offline / Send Message
    RN sublime tool
    Here's a suggestion, without programming:
    Have a UV channel on the cubes that maps them to a single pixel (collapse all UV vertices to the same point). Have a wide texture image with only black and white noise, no grayscale values. Each cube needs to be mapped to a pixel on that texture, not necessarily adjacent pixels (they can be scattered throughout). Set the texture filtering to nearest-neighbor ("point" filtering).

    Animate a UV-panning effect (offsetting the UV values of the material, so all meshes inherit the offset), and use the sampled white or black colors as a mix factor between the two shaders. When it's white it'll be one shader, when it's black it'll be the other.

    This is from a different program, but the effect is program-agnostic anyway:


    If the texture is wide enough (for like 8 ~ 10 variations) then nobody will be able to tell it's coming from a pattern.
Sign In or Register to comment.