FabIV

  • 3 May
  • Joined Jul 19, 2018
  • 0 best answers
  • Hello fellow Godoters,

    I recently found a nice shader, created for unity that went around latley.
    Since I like Godot a lot, I decided to recreate the shader and share it with you.
    It is a bush and tree shaders, where a nice foliage can be created with minimal effort.

    This is how it looks.

    You can find the code here:
    https://github.com/FaRu85/Godot-Foliage

    It is a combination of three shaders:
    Base Shader idea:
    -Pontus Karlsson
    -

    Coloring:
    -Victoria Zavhorodnia
    -

    Wind Behavior:
    -Rainware
    -

    Hopefully it is of any use to someone.

    Cheers
    FaRu

    [Edit]
    To add some general Information:

    • Mesh must be in general shape of bush or tree.
    • Mesh must be quad elements only.
    • UV of each polygon should be a filled square
    • UV2 -X-coordinate is used to rotate the faces randomly, to give a more natural look.
    • Red-channel from texture is used as alpha and should be in shape of leaves
    • colors can be set in the shader
    • Hello,
      I am currently recreating a foliage shader from Unity into Godot. However I need the Transform-Matrix of the Object on which the shader is applied on.
      Is there any way to access it or do I have to create a Uniform and apply it from the object onto the shader via script?

      Thanks for the help.
      Best Regards

      Fab

      • It can be accessed in a shader as WORLD_MATRIX.
        (MODEL_MATRIX in 4.0)

    • Hello bluepangolin55 thanks for the help. I finally could get it to work.

      @bluepangolin55 said: Maybe using 'script' to refer to C# code is a bit misleading since C# is not a scripting language.

      I just used this expression, because it is called that way in the editor ;)

      @bluepangolin55 said: 2) Access them from any other place in your code with MyAnimationPlayer animationPlayer = GetNode("/root/.....") as MyAnimationPlayer;

      This did the trick. I did not even thought about access the new class of the node, although it is quite obvious after rethink the situation that this node now carries two classes.

      @bluepangolin55 said:

      With (Class Name) Getnode("Node Name") I can access this class. But I do not know how to get the extension of this node ( attached script) Yes, this is right. And that way you have already correctly accessed the object you wanted :) It's dynamic type is the extended type. Just cast it to MyAnimationPlayer and not AnimationPlayer.

      This is how it works in my normal writing style. For documentation purpose it would be : MyAnimationPlayer animationPlayer = (MyAnimationPlayer)GetNode("/root/....");

      Thanks again

    • Hello duke_meister, First thanks for the response. Yes I have used c# before, but sadly I am no pro. An own class is what I use to manage all the properties I need. I also create a List of this container class to access all the parameters in one object, but my problem is something else: In GD script it seems that a script that is attached to a node (just for pre-defined nodes) is used as an extension of this class. This is at least shown in the video. I do not know if this is possible in c# anyway, but the script is defined with class name: otherclass Normally behind the : is written Node With (Class Name)Getnode("Node Name") I can access this class. But I do not know how to get the extension of this node ( attached script) . At the moment I just think it is a problem of name, because the script is no actual node with a name. But the node also tells me that the are no child's attached to this node

    • Hello Guys,

      currently I try to get my hands on Godot and I like it so far, but currently I have one problem with accessing a script that is attached to an AnimationPlayer-Node.

      What I want to do: Use several AnimationPlayer and give it some extra properties like Enums that can be read out by a parent node.

      What I did: Create a node with my Main-script, added a Sprite and an AnimationPlayer-Node and added a Script to the AnimationPlayer Node.

      Accessing nodes works just fine and I can also access everything of my own classes but not when the Node has a Godot-functionality and an additional script is attached.

      To access the node I just type in:

      AnimationPlayer animPlayer = (AnimationPlayer)GetNode("name");

      Then I want to access the Script and I tried

      (ScriptName)animPlayer.GetScript("ScriptName"); or (ScriptName)animPlayer.GetNode("ScriptName"); or (ScriptName)animPlayer.GetChild(0);

      In all cases I cannot acces the script.

      I found a video that shows how to access Scripts with GD-Script https://www.youtube.com/watch?v=4TYh6ZLOHiU , but I cannot make it work in c#.

      If you have any ideas that could help me out, I would be very greatful.

      Thanks in advance.