Plant API (Suggestion)

A new update is now available, introducing seasons and more!
  • Hi to everyone, some time ago I asked a question about the API for plants. As API of such kind is not implemented yet I listed a small suggestions about plant API that can be possibly added to allow creating custom plants with plugins or modify existing plants (probably) here.


    This is a list of how plant can be defined:

    • Plants have a unique ID by type (with key set plugin-plant-name -> integer number) if Rising World on Unity uses plant IDs like Java version. This tale will aloow safely add and remove plugins with plants;
    • Any plant can be defined as a list of mesh objects (probably in OBJ format);
    • Each plant have a vertex color information how wind should be applied to it (for example – red color gradient);
    • Each plant has an instance of shader with texture mask (single texture with 3 channels) for sub-surface scattering (leaves, red channel), glowing parts (for plants that can glow, green channel) and refracted parts (blue channel);
    • Plant can defile its LOD (for example LOD1 and LOD2) to improve game performance, the most distant LOD is a simple geometry with plant image and it can be generated by the game itself;
    • Plants can have a specific events like cutting event to make possible change default plant behavior to something unique or add additional functionality (like collecting rubber from Hevea or collecting fruits);
    • Plants can be one of 3 suggested types:

    Tree Plant (Cuttable Plant)

    • Can be cutted with axes or other tools (probably the tool can be defined in plant to allow users create custom tools to cut plants);
    • Will drop its content after cutting and leave a stump;
    • Stump can be uprooted and can define its drop;
    • Models are stored in a list of 3 separate lists (or in multi-indexed array) – random variants of upper parts, stumps and full for each plant age, all 3 lists have the same length and parts have the same indecies to make cutting operation smooth (without model changing);
    • Drops will be scattered across upper plant model part.

    Bush Plant (Collectable plant)

    • A small plant that will be collected;
    • Models are stored in a list of lists (or in multi-indexed array) – random variants for each age.

    Grass Plant (Ambient Plant)

    • A small plant that will be added to grass material depending on biome;
    • Is a 2D texture with defined size;
    • Couldn’t be collected.


    How plant shader can be organized:

    • All plants can use the same shader with complex behavior;
    • Texture mask for sub-surface scattering (leaves, red channel), glowing parts (for plants that can glow, green channel) and refracted parts (blue channel). This will alow make plants of almost any kind – from bioluminescent mushrooms (which are technically not plants but can be defined in this way) to any kind of tree.


    Sub-surface scattering

    This is a common shader technique for thin plant parts like leaves as they will scatter light. There are many different approaches on it

    Wind mask

    Color/Colors baked inside model vertices, colors can indicate different reaction on wind


    I hope you enjoy the idea of such API, discussion and criticism are welcome :)

  • This is a simple demonstration of plant shader made by me in Unity. All plants models were made hastily in Blender and exported as .dae into Unity (to save vertex colors used as wind movement markers). Trees used sub-surface scattering and wind mask (the same for grass), mushrooms - glowing mask, the shader is the same for all plants


    Unity Project Sources

    Assembled exe (can be used as screensaver)

  • Updated shader variant - now it uses more colors to detect large plant movements (branches on trees) and have smooth movement for small plants and leaves

    Red color marks leaves movement, green color - branch movement (it was mapped as distance to zero)

    The latest compiled version

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!