Search Unity

Assets diamond Visual Scripting

Discussion in 'Works In Progress - Archive' started by maz_dev, Jun 17, 2017.

  1. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    sorry, thats not my question again. I understand that diamond creates scripts. I want to make scripts with diamond that do not need editing by a programmer in order to receive variables from other scripts that have not been made with diamond. that is all i have been asking. it seems like that is not possible.

    the programmer is entirely aware of how to program those functions, but is busy. I can ask him to make the variable i need any type of variable or do anything inside the scripts he has control of, but editing scripts made by diamond is just a world of hurt when it comes to changes and then having to re add those changes again. not good. surely being able to interact with pre made scripts is a fundamental part of diamond being useful as an art resource. it will greatly limit the usability of diamond in any professional environment.


    good to hear that surface shader properties are going in. i am looking to produce a wrinkle system that blends textures in a shader depending on bone positions similar to this
     
    Last edited: Oct 19, 2017
  2. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    maybe I begin to understand your need, you have for example a C# script made already by someone, this script is called for example "PremadeScript.cs" and this script has a float variable called "myFloatVariable". You want to access this variable with diamond graph.
    If this is your need I will search around this kind of situation because I think that it is possible to add to diamond a new feature doing that.

    in the upcoming diamond access to surface shader properties, you will be able to get and set , floats, colors textres, etc in a shader.
    In the video you have shown I think that the guy has all coded in his shader demanding to the shader to detect bones movements and use this information to interpolate between 2 mask textures to express 2 normal maps differently in different areas. I don't think it is simple to do that with diamond even with the upcoming get / set shader properties.
     
  3. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    Yes, thats it. there seems to be lots of ways. maybe this will help
    http://answers.unity3d.com/questions/42843/referencing-non-static-variables-from-another-scri.html

    yes, thats my plan also. I have the shader working. the diamond script excepts several "bone" objects that are already part of the face model. when the script starts it finds the start position of these objects. the script then checks for any change in position and uses the magnitude of the movement to change the blending property in the shader. extra complexity would be to limit the detected direction, and maybe change the target texture. I`m also planning to generate the position masks in the shader so i dont have to use more of the limited number of available samplers in a unity shader. I could also link the shader to blend shape animations, or indeed link blend shapes to bone positions to improve the surface deformation.
     
  4. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    yes, there are several ways to achieve this, I will keep you informed,

    your need is that diamond acts on shader properties according to bones movement. The good news is that shader properties access will be available in the next diamond 1.1.6, you will be able to get and set a shader property according to its name, (like the name _Color for the main color).
    I will give you a trick that you may already know, but it can be useful for other forum readers, to show a shader properties names in unity editor, you turn the inspector of the corresponding material to debug mode (following image):

    is your need to read C# scripts variables Is related to reading bones movement? because the bones are animated by already written C# scripts? or is the bones movement are done in the shader? (I don't think so because moving objects via a surface shader isn't simple, I don't know if it is possible)
    materialInspectorDebugMode.png
     
  5. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    Available since october the 21th

    Terra is a diamond plugin and it use Perlin noise to create Unity compatible terrains

    Asset Store Link


    What is a Perlin Noise?


    Ken Perlin is an American professor and researcher in computer graphic and inventor of the Perlin Noise. He also worked on Tron for Disney in 1985.


    Based on white noise, Perlin noise creates organic effect by interpolating gradient vectors. This noise is highly used for terrain design, fire, water, and wood generation, etc.



    Terra use 2D Perlin noise to generate terrain heights, black: lowest point, white: highest point.



    How to use terra?


    Terra is a new node for your diamond asset, using Perlin noise settings:

    For global shape of the terrain:

    Frequency : number of peaks

    Seed: the random start point (to not repeat the same random)

    Octave: fractal level effect (usually 3-4)

    For details (Octaves = 2 or greater):

    Lacunarity & persistance : to quickly obtain high realism, we will come back later about this both parameters in a full topic.




     
    Last edited: Oct 22, 2017
  6. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    this is in a different project of mine, and quite separate from the script variables problem. the bone movement is skin/bone animation in the fbx file exported from 3ds max. So the reading of the bone position is as simple as "transform/get position" of the bones i want to drive the shader value lerp :)
     
    maz_dev likes this.
  7. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    very much looking forward to testing terra. i think i`ve said already that part of the project i`m working on is full planet procedural generation from space all the way down to a close to ground level.

    Hopefully i can link it into the land mass images i am already generating with procedural textures.
     
    Kennth and maz_dev like this.
  8. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    looking forward that you test terra, and tell us about new needed features.
     
    Kennth likes this.
  9. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    I`ll also be testing the new seeded random nodes, hopefully fairly soon.
     
    maz_dev likes this.
  10. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    i`m trying to make an object snap to grid function. there doesn't seem to be an implementation of unitys "round" function, or a maths absolute (abs) function.
     
  11. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    We are preparing diamond 1.1.7 which is coming the next week, after that immediately I have the math class to implement in diamond, for now, I propose to you to use the following logics:

    Abs:
    AbsLogic.png

    Round:
    Round.png
     
    Last edited: Oct 27, 2017
  12. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Top middle one is the best in my opinion. Although a different color for diamond would be better.

    Center middle one is also nice, but the text should be smaller and leave some space around instead of touching borders.

    Great designs.
     
    maz_dev likes this.
  13. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    @s-ta-c thank you for your opinion, glad that you are interested in our thread.
     
    s-ta-c likes this.
  14. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    I`m currently working on a project that requires me to generate a procedural solar system. I have 2 planet types that use procedural materials to generate the surface textures. the planets are cube mapped, so these materials are also instanced 6 times per planet. there is also another object to simulate planetary rings (like Saturn) which only uses a single procedural material. i already have a diamond script that places and scales instances of these objects. i believe that i need to acquire the instance of the materials on the placed planet prefabs, in order to change the settings on the correct instance of the procedural material, and also to trigger the procedural material generation. is this possible in diamond?
     
  15. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    getMaterial.png

    node 0 to get the material
    node 1 to modify it

    in node 0 you can choose:
    a) Get Material, or
    b) Get Shared Material
    'Get Material' will copy an instance of your material and attach it to your object so changes affect only this object. preferred to be used in runtime only.
    'Get Shared Material' will get the material from assets, so changes on this material will affect all game object using this material, usable in runtime and editor.

    If you have a procedural material and you want to regenerate it immediately after the change, you can choose in the node 1: 'Procedural Material Set Procedural Float and Rebuild' to regenerate it after a float change for example.
     
  16. Guigui_White

    Guigui_White

    Joined:
    Nov 1, 2017
    Posts:
    10
    Hi, I have just a little question. Is Diamond visual Scripting support the Animation component ?
     
  17. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    thank you so much for your reply. I think this is another area where the 2 part selection process causes some confusion.
    the "component renderer/ get material" seems to only acquire the first material on the object mesh renderer.


    It may also be useful to get access to the whole material array. maybe with another sub selection on the node that lets it output a material list or have each material from the list as a separate output.

    I`m also trying to use the set procedural int enum, which i`m presuming works like the float variable, but i dont seem to be getting any results so far. (it also doesnt have a set and rebuild option). I am setting a global variable in a separate state machine, which may be causing this issue though.
     
    Last edited: Nov 1, 2017
    Kennth likes this.
  18. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    I think it would be good to allow the copying of state nodes. the copying and pasting of logics between state nodes, and the renaming or changing of the start node. i sometimes find myself needing to insert a node before the idle node if i have used it, i then have to remake the logics. a work around is of course not using the idle node except for sending the flow directly to another node.
     
  19. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    Hi Guiguik, for now, animation component is not supported,

    For simple animations, diamond has animation curves that can be applied on your floats, color, vectors ..take a look at this:

    Assets\Mezanix\Diamond\0_Documentation\0_Diamond _Documentation_First_time.pdf

    page 65

    this is a simple animation feature that can be useful when combined in the future with the upcoming animation component in diamond.
     
  20. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    @Barada I will evolve the get material node to access the materials array. When getting material array I think that will be instance materials not shared ones so changes will probably affect only targeted object not all objects using these materials.

    You are right I have to add a rebuild option after enum procedural material set.

    Do you propose a feature that copies all logics from a state to another?

    Do you propose a feature that permits the rename of the idle state?
     
    Kennth likes this.
  21. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    that sounds great. i think it may be nessesary to make a shared version also, as its not realy possible to know everything that people may want. i also think that maybe when the node selection system gets a major update, combining similar functions into single nodes with more controls would be a major simplification for the user. so instead of having separate get material, get procedural material, get shared material, like it is at the moment. it would be a single "get material" node with a sub menu "normal/procedural" and "single/shared" etc. many functions could be combined this way to simplify the node selection tree.

    I think just having a copy function, similar to the edit logics menu list would be fine. so logics could be copied individually. only a single logic needs "copying" so a simple "paste logic" on any node would be needed. this also allows for duplication of logics, which would be very useful.

    yes. if you look at playmaker (which i recomend for the whole state machine view), it doesnt have an idle state but it does have a start flag. a single start flag must exist in the state system, but can be moved to any node. "make start node"
    if in the future you implement a system where logics dont make the connections to other states, they connect to outputs that are created on the state node they are in, then this would also mean the idle state could be altered so that the user cant add logics and the idle state has a single default output that the user can wire to any node.
     
    Last edited: Nov 2, 2017
    Kennth likes this.
  22. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    As part of the solar system creation project i also need to be able to pull values from textures that i use as lookup tables that contain numerical information in the RGBA values. would it be possible to get a "color to Vec4" node?
     
  23. Guigui_White

    Guigui_White

    Joined:
    Nov 1, 2017
    Posts:
    10
    Ok, so if I want to play an animation when I click on a button for exemple I can’t ? I must to wait a future version.

    Thank you for your reply and continue what you do, it’s very cool and useful.
     
    maz_dev likes this.
  24. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    I haven't used the system yet, but I imagine you should be able to set up some sort of wrapper or proxy class for this particular job.
     
    maz_dev likes this.
  25. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    Your proposition can work if the user wants to code; diamond is fully open source and all its classes are reachable in the namespace "Mezanix.Diamond", diving in these classes is difficult, there are many lines to analyze, but all classes are exposed to interact with, so anyone can code his own classes to make his own modification (version) of diamond.

    I think that @Guiguik wants to do this with no coding, so it is possible when diamond integrates the animation component.
     
    s-ta-c likes this.
  26. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    duplicateLogic.png

    @Barada you can duplicate a logic in the same state or to another state, this functionality is not polished yet, the copied logic needs some manual modifications to be exactly like the original one.

    You proposed modifications related to diamonds organization (grouping nodes and functions, more global viewers of nodes and events etc..) we are working on a big change of diamonds organization that contains most of your ideas, when this modification comes, we will be glad to hear about your opinion.

    Changing the idle state name, is it useful? explain it to me please, you are an intensive user so you have many situations in which is useful to you, you have tried to explain it to me but I didn't get it yet, could you please explain this need to me with a little example.

    For colors RGBA get set and colorToVector4 I have to add new functions that I added to me to do list.

    We are working on a public wish list and a public roadmap, this will be announced in this forum when it's ready
     
    Kennth and Barada like this.
  27. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    the problem i`ve had with the idle state is mainly a user problem. i have on several occasions in my eagerness to start coding, added logics to the idle node. later i have found that i need to add a node BEFORE that node to setup something. The way playmaker gets around this is instead of a default start node (idle) it has a start tag (see image). any node can be right clicked and (set as start state) so its very easy to cut out parts of a fsm or change its order.

    Also shown below is the way playmaker uses named exit events rather than direct links to other nodes. the "FINISHED" light grey blocks on the bottom of the nodes are the exit events and the user can drag a single line to any other node, to change the target. the "logic" in the state node says "go to finished" (or one of several exit events) then the playmaker editor looks to see what the node connected to that exit event is.

     
    Kennth likes this.
  28. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    One of the problems i`m also having is with the transfer data system. I use the same diamond scripts on instanced prefabs. i am calculating some random numbers that are seeded by a value taken from the objects position. this gives me a unique value for each object. i need this value to be accessible by the whole graph, but only that graph instance. At the moment the "listen" node only "hears" the last value generated by the last object. I cold generate unique names for the sent data, but cannot "listen" for them as they are chosen from a list. I think i need a variable that is limited to the current graph and recreates the functionality of local variables.
     
  29. Guigui_White

    Guigui_White

    Joined:
    Nov 1, 2017
    Posts:
    10
    No I don't want to code because I'm learning game designing as passion and I don't know coding ^^
    If I didn't discovered your tool, I would not do anything so thank you again ^^
     
    Kennth and maz_dev like this.
  30. Guigui_White

    Guigui_White

    Joined:
    Nov 1, 2017
    Posts:
    10
    Is there a way to detect collision on two objects ?
     
  31. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    detectObjectByRay.png

    Choose:
    Logic: Compute Or Operation
    Variable Type: Game Object
    Compute: Other Game Object Found At Radius

    Here is the help text of this node:
    "Find if another game object is near of your game object by a defined radius.",
    "Only one game object can be detected by frame.",
    "If your game object has a collider on it, the search zone will begin outside",
    "the collider bounds, if not, the search zone begin at your object's transform position",

    So this node takes into account the collider of your objects.


    If you have a moving object and you want to detect objects in his way, you can choose this:
    Compute: Other Game Object Found On My Way At Distance

    Here the help text of this node:
    "Need a Rigidbody component",
    "While moving, find if another game object is on the way of your game object ",
    "by a defined distance.",
    "Only one game object can be detected by frame.",
    "If your game object has a collider on it, the search zone will begin outside",
    "the collider bounds, if not, the search zone begin at your object's transform position",

    So your moving object needs a Rigidbody component on it to make the node working.

    The 2 above nodes have 3 outputs:
    bool: Something found, to tell you if something is detected or not
    GameObject: Found Game Object the detected gameobject
    string: its tag: the tag of the detected gameobject

    Tags are strings used by unity to identify objects, for example, if you tagged enemies by the tag "enemy" you can detect only enemies. here is the unity documentation about tags:

    https://docs.unity3d.com/Manual/Tags.html

    I may explain things that you know already, but as long as this forum is visited by developers having many levels of experience, the explanation is helpful for everyone.

    We have more advanced contact detection nodes coming in upcoming versions when you can detect the collision enter, stay and exit, and the same features for triggers.
     
    Kennth likes this.
  32. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    So you propose that every State node can be transformed to idle, it is a good idea an I will do it for diamond

    About linking state from the states view, we are preparing a big change of the diamond UI in which every state show clearly his logics so you can connect states using shown logics directly.

    StateExposedLogics.png
     
    Kennth and Barada like this.
  33. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    You can stock generated values in a list and listen to the list or name every new transferred value differently, I will try to make and show to you a graph solving this kind of situation. Or maybe a new feature needs to be added to diamond
     
    Last edited: Nov 4, 2017
  34. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    ah yes. i didnt think of that. in this case i would have to number each object add the generated value to the list in the correct position (or create 2 lists one with the value and 1 with the name of the target object.)
    i think that may be a possible work around for me. i have started recalculating the values i need in each node, but transmitting a list could also work ok. thank you for the idea. But in other situations i can see that having a transmitted value that only gets "heard" by the current instance of a graph would be needed. At the moment i dont think there is any way to keep a value local to a graph (rather than just local to a logic, by wiring) is there?
     
  35. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,487
    Hi, have you come any closer to achieving this goal? Interesting way to animate normal maps, you doing so via script?
     
    maz_dev likes this.
  36. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    I didn't understand very well the question, is this about a variable that needs to be listened by its own graph?
     
  37. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    This is maybe about having the "transmit" node have 2 modes. "global" and "local". global works like it does currently where everything transmitted is heard (listened) by all nodes in all graphs. Local is heard by all nodes but only in the current instance of the graph.
     
  38. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    I havent had a chance to continue with this yet. I think it may also need to use local variables on multiple instances of the same graph attached to each controlling bone. my plan being that the diamond graph finds the rest position for all the control bones, and then checks to see if it moves, and if it foes it edits a variable in the shader, that actually blends the normal maps.
     
  39. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    It may be achieved by simply connecting this variable to other nodes in the same graph.

    AnswerBonesRestMove.png

    I don't know all details of how you manage to do it, so I tried to imagine a similar situation in which I propose this logic to put in the idle state.
    P.S. in nodes 1 and 2, I selected the option "The Attached To" for the game object, if every bone is a game object, so the script generated by this graph can be attached to all bones and works with each bone independently.
    P.S. this logic compares the current position to the first one (game start, Lagrangian approach), so the movement magnitude is a "total" movement magnitude. If you want to measure the movement several times during the game ("Eulerian approach"), you can use a tictac on time node to trigger getting the "first position" every 2 seconds for example. after that you continue to take the current position in all frames, so all movements are measured relative to a "base" position taken at most 2 seconds earlier.
    tictacTime.png
     

    Attached Files:

    Last edited: Nov 6, 2017
    Barada likes this.
  40. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    I suggest you make this project open source and put it on GitHub. Because I believe this project can become the go-to visual scripting solution if it gets mature enough.

    By making it open source you might also get some visual improvements from graphics guys out there as well. It can help massively.
     
    maz_dev likes this.
  41. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    It is a good idea, I am a new user of Github as a provider, I have a question here:
    As long as diamond is already open source and free in the unity asset store, what kind of benefit can have the project when putting it in Github? I think there is one or many benefits, If you have an idea, please tell it to us, so we will know why we do the action (putting in Github) and maybe doing other actions.
     
  42. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    Here are some beautiful creations with terra

    Terra Link


     
  43. cel

    cel

    Joined:
    Feb 15, 2011
    Posts:
    46
    Sorry if this has been asked before, but can diamond interface with playmaker? I mean, retrieve and set variables for example?

    Thanks for your time and keep up the great work!!
     
    maz_dev likes this.
  44. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    this is exactly what i was intending for my first test. thank you, you have saved me the extra time it would have taken me. my next task would be to extend this to a relative directional offset. i havent thought about the specifics of this yet though. what may be needed is to have two positions stored, the relaxed and the maximum travel of the bone, so a linear value can be interpolated between the two points. This could be done by the animator adding 1 or 2 control frames for minimum, relaxed and maximum in the first frames of animation (that wouldn't normally be played) this way the movement of the corner of the mouth (for instance) could be used to add smile lines and sadness wrinkles depending on its motion.

    Also after this i had thought about adding another system that generated a mask for each of the wrinkle channels so that each bone would only effect the area of the face where the bone is. i`m not sure if this is entirely possible, but was thinking it could be a good test of diamonds texture effects and controls. this could be a generated or just blending premade masks. i also hadn`t realy thought this part through very much.
     
    maz_dev likes this.
  45. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    Putting Diamond on github would allow other programmers to work with all your code, and make non destructive changes and new versions at the same time, and also allow you to have access to their changes and allow several people to work on the same features.
     
  46. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261

    Hi cel, thanks for encouraging us, diamond doesn't interface with playmaker. In its next version (1.1.7) diamond will interface with any script created by other developers.
     
    Kennth likes this.
  47. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Putting it on GitHub means users can improve the project or solve the bugs they come across by themselves and purpose them to you, instead of sending you a ticket or bug report. Basically, all users become potential developers.

    Also, you gain some hype from it, which is always good.
     
    maz_dev and Kennth like this.
  48. eggeuk

    eggeuk

    Joined:
    Sep 1, 2013
    Posts:
    88
    Hi everybody,
    'Terra' works fine. There can be wonderful landscapes.
    But how can I combine two or more of generated maps with a smooth transition between them.
    I have shown two generated maps, but sorrowly they don't fit.
    What's to do?
     

    Attached Files:

  49. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    okay got its benefit for the project, we may put it later in Github once diamond is more mature and after standardizing the way to code it and centralizing the library a am creating to it.
     
    Kennth likes this.
  50. maz_dev

    maz_dev

    Joined:
    Sep 23, 2012
    Posts:
    261
    Do you mean combine two height maps (textures), or combine already generated or existed terrains? terra has not this feature, but we can add it if you think that it will be very helpful.