Search Unity

Vector Grid - 'Geometry Wars'-style Fluid Mesh System

Discussion in 'Assets and Asset Store' started by mrsquare, Jan 27, 2014.

  1. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hi folks,

    I'm pleased to announce the release of Vector Grid on the Unity Asset Store

    Interactive Demo

    Infinite Scroll Demo

    Website

    Vector Grid allow you create a dynamic, ever-changing neon grid that will stretch, distort and flow in response to forces from your game. Perfect for adding a Geometry Wars-style futuristic background to your game!

    * Fluid mesh system that dynamically responds to external forces.
    * Infinitely scrollable in any direction.
    * Apply color changes along with physical forces.
    * Optimised code designed to be efficient, even on mobile devices .
    * Only one draw call per Vector Grid.
    * Full C# source code and example scene included.


    Vector Grids are easy to implement into your game - you can simply drop one into your scene and it'll work nicely with the default settings, or you can dive into the Inspector and tweak spring behaviour and rendering options to your heart's content.

    Interacting with the Grid via forces is as simple as attaching a VectorGridForce behaviour to any GameObject - the grid will then move and deform as the GameObject approaches it. Alternatively, you can use C# functions to manually interact with the mesh.

    $1fc84bca-c597-40fe-a830-c7d92cb498cc_scaled.jpg

    I hope this proves helpful to some people out there! Please feel free to reply in this thread or PM me if you have any questions :)
     
    Last edited: Jan 27, 2014
    echoMike, jjbish and jpthek9 like this.
  2. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Look really great :)
    I can't think of a direct use right now, but Im sure I will find and as soon as this is done, I will get it :)
     
  3. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi this looks nice. Any chance you could add a version that makes it a 3D vector cube rather than than just a 2D square plane ? For a game I'm making I was looking for something that could let me fire plasma from a spaceship that is moving around a 3D cube with the objective being that when it fired plasma it would cause the verticies of the cube to ripple and change colour permanently as it passed over the grid much like your tool.

    My questions are one would it be suitable for a 3D cube ? In my game if the ripple got to the edge of the cube it would continue to wrap around the other side.

    My other question is how easy is it to control the forces affecting the grid. In my example the space ship would want to fire the ripple in a small arc rather than a complete circle in all directions. Also the force would need to be able to be manipulated for example my game would need barriers or obstacles on the cube that would stop the ripple effect if the plasma wave hit it. My game would also need to be able to query the grid to see what colour each cell was at present as the goal of my game is to paint the cube a particular colour.

    I'm wondering how suitable your asset would be for all this, thanks
     
  4. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Heya,

    Sounds like an interesting idea :)

    1) The cube idea might be feasible, but I think would require a fair bit of modification to the code. The basic principal of having grid points connected by springs could presumably remain unchanged, but the grid generation code would need to be changed fairly substantially to generate the points in a cube formation and then go through and connect them all up to their neighbors. It probably wouldn't handle the edges of the cubes as you'd want though (any points affected by forces would sort of fly away from the edge of the cube rather than wrapping around). A better approach might be to internally simulate a 'T' shaped 2D mesh (think of a cube unfolded into 2D space) but then render it as 3D cube.

    2) Currently forces can either be applied in an outward radius from a given position (so all points are pushed away from the centre) or you apply a force to push all points in a particular direction. It sounds like the second one might provide the effect you're after, but if not then its pretty easy to code custom force types (essentially just loop over all the grid points, check each one is within the force area, and if so then apply the force)

    3) Individual grid points can be locked in place, so won't be affected by forces - you could presumably do this for any points underneath your obstacles to prevent them from being moved.

    4) Yep, you can query the color of a particular cell quite easily (it actually requires a minor change to the code to make the grid point array public, but I'll roll that into the next update as I can see that being quite handy)


    tldr: The asset as it stands probably isn't suitable for all your needs, but if you're confident messing around with the code then it could provide a decent starting point for implementing it :)
     
  5. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very cool project,

    Q:
    1. Can the 2D shape be changed into say a spider web shape or other geometry ?
    2. Possible to map a texture onto the mesh?

    Cheers
     
  6. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey,

    1) Not currently - the creation and update code only supports a grid-style configuration.

    2) You can indeed map a texture onto the grid. There is a dropdown list in the Inspector where you can choose the 'Render Mode' - set it to 'Plane' instead of 'Grid', and it will render the grid as a solid sheet with a texture applied to it, rather than a grid of individual lines.
     
  7. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Definitely would like to get this asset.
    Request: Would you consider adding a way to modify the shape geometry to other than a rectangular grid in a future update. Spider web / polar type of grid.

    Cheers.
     
  8. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Sure, I can take a look. The basic spring/point simulation stuff won't require any alteration, just the positioning/drawing code - I'll have a play around with it see what I can do :)
     
  9. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    It would also be great if you could connect multiple grids together in the editor with options to allow energy to transfer between connected grids and perhaps options to disable grids that were no longer on screen or an item wasn't moving close to so that there wouldn't be a performance issue in having lots of grids in a scene. That way it would have lots more uses you could make 3d objects out of the grids and especially if you implemented other shaped grids you could make some very interesting geometry.
     
  10. Dravish

    Dravish

    Joined:
    Feb 28, 2014
    Posts:
    1
    Wow, I didn't realize this was a fairly new project. I've been messing around with it for a day or so now and it's pretty amazing. I'm currently working on an Oculus Rift demo and this looked like the perfect asset to use for it. Hugh (mrsquare) has been very helpful and I'm hopeful to see some 3D object meshes in the near future. Thanks for this awesome asset and keep up the great work!
     
  11. jgalvezpa

    jgalvezpa

    Joined:
    Dec 27, 2012
    Posts:
    36
    Hey can i put a normal background on the vector grid plugin? I don't want the lines of neon to be seen , just like a regular background with the effect
     
  12. Reapazor

    Reapazor

    Joined:
    Jun 19, 2008
    Posts:
    173
    Being able to provide points which would then construct the geometry necessary (for example i provide 4 points of a rectangle and it generates the mesh for that, extending that out to other shapes as well).

    Neat! (purchased!)
     
  13. indy2005

    indy2005

    Joined:
    Aug 22, 2009
    Posts:
    81
    Hi,

    When I am running the demo, I keep getting Chrome crashing on me saying the computer is low on memory? If this is happening on a MacBook pro, I am concerned how it is going to perform on mobile. Any advice appreciated.

    Regards

    i
     
  14. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    That's weird - people are using Vector Grid for stuff like this and running it quite happily on iPhones, so I'm fairly sure memory won't be an issue on mobile devices. Do you see the same problem with any other webplayer demos?

    Just running the Interact Demo through the profiler, these are my memory stats:

    upload_2014-7-1_22-32-37.png

    So its hardly excessive. The mesh itself is 9.4k triangles, only one texture - the only thing that might be taking up any memory from the Vector Grid side is are the grid springs/joints with are just an array of (very roughly) 40 x 30 objects consisting of a couple of vector3s and some floats.
     
  15. indy2005

    indy2005

    Joined:
    Aug 22, 2009
    Posts:
    81
    Hi,

    Not sure what the issue is, but in Unity I keep getting this:

    Cleaning up leaked objects in scene since no game object, component or manager is referencing them
    Mesh VectorGrid Mesh has been leaked 1 times.

    Can you tell me how to apply a force directly under a game object. This code seems to apply the force not at the centre of the game object the force is supposed to be coming from, but slightly offset. This code is in the update method of the object I want the force to come from.


    Vector3 worldPosition = transform.position;

    worldPosition.z = m_VectorGrid.transform.position.z;

    if (velocity != 0) {
    m_VectorGrid.AddGridForce (worldPosition, m_ImplosiveForce * 0.1f, m_ForceRadius, color, true);
    }

    Thanks

    i
     
  16. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - that's nothing to worry about, its more of a garbage collection warning than an error. It only happens in the editor when you stop and restart the scene.

    From this thread:


    Regarding your other question:

    This code should work fine - if you have a look at the VectorGridForce.cs script that comes with the asset, this is almost exactly the way that I do it.

    I just tried to reproduce this in the editor using the 'Interact' demo by creating a sphere, sticking it in the middle of the grid (at the same Z height), and then attaching a VectorGridForce component to it. To make it apply the force, you then need to drag the Vector Grid onto the VectorGridForce component, and assign a force scale and radius value (I chose 0.6 and 0.3 respectively).

    It all seems to work fine, although you do need to remember that certain parts of the grid are stiffer than others. Eg. if I put the sphere in one position I get this:

    upload_2014-7-3_10-50-12.png

    but if I move it slightly to the left then I get this:

    upload_2014-7-3_10-49-41.png


    The 'bunching up' of the lines in the second pic is presumably due to the distribution of the loose springs (the additional springs which are dotted around the grid to help it keep its shape). If you've got a nearby loose spring, that is going to affect how the mesh deforms in that direction.You can change how often they appear and their strength in the inspector.

    Also remember that forces only act on the grid points - ie at the intersections of the lines - so you're always going to be somewhat biased towards a particular direction unless you're exactly in the middle of a set of four grid points. Having a small force radius versus the distance between points would probably make this more obvious too.
     
  17. Lachee1

    Lachee1

    Joined:
    Aug 21, 2012
    Posts:
    16
    How large can the meshgrid be before significant frame rate drop? I have a use for it but it might be a bit too big. I am looking into making it the background of a world that is 500mx500m

    EDIT:

    I just realised I can use the infinite scroll system and just make the mesh the size of the viewport. I just need to know how easy it is to scroll. For example, would it be possible to scroll it the opposite way and speed to the player, so it looks like its moving? Can you give an example snippet on how it scrolls please.
     
    Last edited: Aug 4, 2014
  18. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - performance is very much dependent on what device you're trying to use (an iPhone 4S, for example, should handle a 40x30 grid at ~60fps, any vaguely modern PC should be able to do much better). But in general, yep, scrolling is probably the way to go if you want a really massive play field. You'll probably want the mesh to be slightly bigger than the visible viewport so that the user can't see the rows/columns being deleted as they move off screen.

    Scrolling the grid is dead simple, its just a single function that takes a Vector2 representing the scroll direction

    Code (csharp):
    1. Vector2 scrollSpeed = new Vector2(10, 0);
    2. vectorGrid.Scroll(scrollSpeed * Time.deltaTime);
    And that's it :)
     
    Lachee1 likes this.
  19. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Is it possible to have the ripple effect pulsate ? So for example when the object makes contact waves move outwards in pulsating intervals.. The ability to adjust the time between pulses would be great & even adjust the hue & vibrance of successive pulses..

    So for example a character might move and the grid ripples are as per the demo... but when the character stops moving the grid pulses beneath..
     
    Last edited: Oct 16, 2014
  20. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Heya - I think you're probably using the wrong shader on whatever material you're using for the Vector Grid. At a guess you're using 'Diffuse'? Try switching to 'Particles/Additive (Soft)' and it should work :)
     
  21. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    yeah I was ... I simply checked the demo & copied the shader :) now all is sweet ....

    So anyways... how bout my incredible idea regarding PULSE ...ability to control pulsating waves when an object is stationary...

    p.s - thx for the speedy reply
     
    Last edited: Oct 16, 2014
  22. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    **** Solved****

    Code (CSharp):
    1.      void start ()
    2.  
    3.      {
    4.  
    5.          m_VectorGrid = GameObject.Find("Vector Grid").GetComponent<VectorGrid>();
    6.  
    7.     }
    8.  
    9.  


    **** Solved****
     
    Last edited: Feb 16, 2015
  23. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - glad that you've solved the issue :)

    For future reference, you can't store references to other game objects in a prefab, unless they're children of the prefab object. Prefabs can be loaded into any scene, not just the one they were created in, so there is no guarantee that any referenced objects will even exist when a prefab is loaded - for that reason, Unity just blanks them out when serializing the prefab.
     
  24. ctmctm5

    ctmctm5

    Joined:
    Jul 1, 2013
    Posts:
    7
    How efficiently does this run on mobile devices (especially ones a gen or two old)? And is their any way to scale its efficiency? Like by lowering the detail level so It will run faster on older devices.

    Because this is a really cool asset that I will probably purchase.
     
  25. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - it'll run just fine on mobile devices, but as with anything mobile-related, you do need to be quite careful about how you use it.

    The asset itself grew out of a game called Bitstream that I released on iOS a few years back. It was written using Cocos2D rather than Unity, but ran at a fairly solid 60fps on my iPhone 4S, and about 40-50fps on an iPhone 4 Touch. The Unity version of Vector Grid is admittedly a bit slower than the version used in Bitstream, primarily due to running in C# instead of C++, but the basic concepts are the same.

    The speed is directly linked to the size of the grid you use, so if you keep the dimensions as small as possible then you'll get better performance. There is also a 'Grid Smoothing Factor' setting in the Inspector that determines how smooth the lines between points are - you can reduce that for a bit more performance at the cost of some visual fidelity.



    *Edit - Ah, that video I linked to was taken from before I added the Vector Grid-style background. Regardless, if you've got a iOS device, it's up on the app store so you can check it out on there :)
     
    Last edited: Jan 5, 2015
  26. ctmctm5

    ctmctm5

    Joined:
    Jul 1, 2013
    Posts:
    7
    Very, very cool. Also, does the plane deform in the third dimension or just two.
    So if the plane was in a scene and I was walking around it, would it look flat, or would it look like a 3D sheet?
     
  27. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Yeah, its all in 3D. When you apply a force, it pushes all of the grid points away from the force center - as long as you apply the force above/below the plane that the grid is on then the grid will deform in 3D. In the same way, you can also force it to only deform in 2D by clamping your force position to the plane that the grid is on.

    The demos actually all use the 2D approach, but its simple to get them working in 3D. If you've already got the asset, then in InteractDemoManager.cs, just change these lines:

    Code (csharp):
    1.  
    2. worldPosition.z = m_VectorGrid.transform.position.z;
    3.  
    to

    Code (csharp):
    1.  
    2. worldPosition.z = m_VectorGrid.transform.position.z + 0.1f;
    3.  
    Quick screenshot from the scene view in the 'Interact' demo, modified for 3D movement:

    VectorGrid.png
     
  28. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Would it be possible to map a grid to a 3D mesh (i'm thinking specifically something like terrain-based meshes, which would be an even spaced grid on x/z and displaced on y). I'd like to get crazy with mountains, they'd already have lightmaps, vertex colours, shaders and wotnot, i just think.. that + the earth/distant mountains + OR would be a.. trip you might not forget that soon. I'd be in.
     
  29. ctmctm5

    ctmctm5

    Joined:
    Jul 1, 2013
    Posts:
    7
    One last question before I buy this.
    How many triangles make up each line segment?
    Is each line segment two triangles or is every box two triangles?
     
  30. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    There isn't any built in-functionality for that, but you could theoretically modify the code to support such a thing without too much trouble. You'd just need to create some sort of a height map, and then go through all the points in the Vector Grid, sampling the height map at the appropriate coordinates, and then adjust the resting position of each grid point to be the appropriate height. You'd also need to adjust the rest distance of all the springs to compensate for the adjusted distances between points.

    This is configurable. By default, every line segment is two triangles, but you can use the 'Grid Smoothing Factor' value to increase the number of subdivisions. Alternatively, you can put the Vector Grid into 'Plane' mode, which just renders the mesh using quads rather than individual lines. The pictures below show the difference between unsmoothed/smoothed/plane rendering in wireframe view:

    VectorGridUnSmoothed.png
    VectorGridSmoothed.png
    VectorGridPlane.png
     
  31. WizByteGames

    WizByteGames

    Joined:
    Mar 28, 2013
    Posts:
    70
    Are you planning on making a free version of this?
     
  32. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Nope, sorry! I can't really think of anything that I could strip out to make a free version, to be honest. If it was a more complex system then I'd certainly consider it.
     
  33. FullMe7alJacke7

    FullMe7alJacke7

    Joined:
    Dec 17, 2013
    Posts:
    55
    Hello, just a quick question, is this compatible with unity 5 as is or will it need to be modified?
     
  34. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - yep 100% compatible with Unity 5. The latest version on the Asset Store should just work with no modifications :)
     
  35. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Even on mobile. This is AWESOME! The scrolling works like a charm for my infinite runner game. Worth every penny (and many more).
     
  36. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    Nice! It saved a lot of time for me.
     
    mrsquare likes this.
  37. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    56
    hi, i try to use vectorgrid using the tracking camera. my problem is that when i rotate the camera the grid jitters. Have to experienced this as well? Is there something a could change to fix this?
     
  38. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - is that using auto-follow camera script that comes with the asset? It could be that your script execution order needs changing - eg. if the camera position updates after the Vector Grid script, then the Vector Grid will be using the camera position from the previous frame.

    See: http://docs.unity3d.com/Manual/class-ScriptExecution.html
     
  39. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    56
    i had to change the object the grid centers on to a transform, so i could center it on a position the camera looks at. rather then to orient itself on the camera's position. this fixed my jitters
     
  40. NnelGdaBandit

    NnelGdaBandit

    Joined:
    Dec 21, 2012
    Posts:
    18
    Hi MrSquare,

    Can you provide steps to make the grid work off of unity time, so i can slow down and speed up the grid with Unity' timescale. I made a change in the gridpoint file to scale the velocity by time.deltaTime and a force but I'm thinking there is more to it than that. It seems to work but when my time scale is double the grid becomes very unstable.

    Thanks!
     
  41. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - interesting question! Unfortunately it's not an entirely trivial problem to solve - the code uses something called verlet integration to simulate the physics, which has a lot of advantages for cloth-like physics simulation but doesn't respond so well to variable timesteps. Check out this:

    http://lonesock.net/article/verlet.html

    for a fairly technical discussion on the subject of modifying verlet systems to cope with variable timesteps. But yeah - that's why you won't see the code using Time.deltaTime anywhere.

    Your best bet is probably to fake it somewhat - if you're finding that the simulation is unstable at timescales > 1, then you could try running the grid simulation multiple times per frame. That way the forces remain exactly the same so stability should be ensured. Something like this (in VectorGrid.cs):

    Code (csharp):
    1. static float timeStep = 0.0f;
    2.  
    3. void Update()
    4. {  
    5.        if(Application.isPlaying)
    6.         {
    7.             ...
    8.  
    9.             timeStep += Time.timeScale;
    10.  
    11.             while(timeStep >= 1.0f)
    12.             {
    13.                 UpdateGrid();
    14.                 timeStep -= 1.0f;
    15.             }
    16.  
    17.             UpdateMesh();
    18.  
    19.             ...
    20.  
    This doesn't look too great for time scales less than 1, as it means that the simulation will only run once ever eg. 4 frames (if you had the timescale set to 0.25), which looks jerky. For time scales > 1 it works much better - although you may still get a slightly uneven simulation (eg. 2 updates one frame and then 3 the next), so best to stick to whole number time scales if possible.
     
  42. NnelGdaBandit

    NnelGdaBandit

    Joined:
    Dec 21, 2012
    Posts:
    18
    Hey MrSquare, that fake seems to work pretty well. I'll take a look at that Verlet integration resource when I get a chance. Thanks so much, Vector Grid is awesome.
     
  43. immagg

    immagg

    Joined:
    Oct 29, 2015
    Posts:
    3
    Hey! I wanted to ask how do I set it all up to work with uNET multiplayer?
    I want the VectorGrid to be spawned on each client locally. I've added it on the scene, then I've attached the NetworkIdentity Component to the grid and set it to "Local Player Authority". Am I missing something? Because right now always on the build window whenever I move it looks like multiple instances of the grid are overlaping with each other...
     
  44. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - sorry for the slow reply, had a busy weekend!

    I've never actually touched any of the uNET stuff, but I imagine its simply creating duplicate copies on each machine, each of which will behave independently of one another. You probably want one 'master' mesh, which would be in charge of the physics behaviour and would transmit the vertex positions to clones of the Vector Grid on the other machines (these would just do the rendering part, and none of the physics). The master mesh would be the only one that could apply physics forces etc. so all requests would have to go via that one.

    Send me a PM if you like and I can try to help you out with it, but I very much doubt it'll just work out of the box. Certainly something that I could look into for a future update though.
     
  45. RedCabinGames

    RedCabinGames

    Joined:
    May 8, 2016
    Posts:
    7
    Hi! Does this work with multiple objects as well? I would like to use this as a gravity grid with multiple objects. Some would push and others would pull. Possible? It looks great! :)
     
    Last edited: May 8, 2016
  46. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - yeah, absolutely. Multiple objects is no problem, and you can simply apply a negative force value to suck the points towards the force point rather than pushing them away.
     
  47. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    I am still using this great asset if there was a future update where it allowd different shapes would be awesome.
     
  48. timrbetts

    timrbetts

    Joined:
    Jun 21, 2013
    Posts:
    5
    Hey MrSquare. Very cool asset. I have a couple questions.

    Lets say I want to curve/bend the grid along a spline to create a somewhat of a curved movie screen for example. Would this be possible with modifications and/or in get it for "free" by using another Unity asset in conjunction with it?

    I'm sure you have a great demands on your time and so you may not be able to work on it right now, so let me ask you. What kinds of modifications would I need to make, so that I could construct a vector grid for my own 2d shape? Say a circle or a star shape and such? Isn't it simply a matter of querying the triangles in the mesh and using that as input to whatever builds the mesh? I'm not saying its easy and perhaps it would sacrifice other functionality, but immensely useful.

    Cheers, Tim.
     
  49. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hi Tim,

    Curving a grid should be pretty easy to do. You could simply modify the function that spawns the individual grid points to eg. extrude the position along the Z axis depending on the distance along the grid. If you look in VectorGrid.cs @ line 197 (in the InitGrid function), there is a line of code that calculates the position for each point. If you just add the following immediately afterwards:

    Code (csharp):
    1. float maxExtrusion = 1;
    2. position.z += Mathf.Sin(Mathf.PI * (x / (float)m_GridWidth)) * maxExtrusion;
    then that'll bend the grid outwards at the center (just modify 'maxExtrusion' to set how deep it can go)

    A custom 2D shape is a more difficult proposition. The asset is very much geared around grid shapes - the code to calculate the individual vertex positions is quite complex (as in fiddly to work with, rather than mathematically complex), as it needs to take what is essentially a set of 1-D lines and create a set of triangles that extrudes them into become two dimensions. On top of this, it is dividing up each line into smaller segments to allow for the grid smoothing functionality. If you zoom in on one of the mesh joints you can see the number of triangles involved. With a custom shape you'd probably want a different layout, certainly at the edges at least, which would require a whole load of changes.

    I think your best bet would be to still use a grid shape behind the scenes, but have a shader using some sort of mask that only displays the area within your defined shape.
     
  50. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @mrsquare would it be possible to use the asset "river tool" (allows you to pull out a plane and curve it to make rivers or what ever) with the scrolling vector grid? I have my own realistic water shader and I want to have rocks pop out of the river and also have that contour/adjust to the terrain shape -both the rocks and the terrain would have vector grid force applied.. is this possible or is your is Vector grid system dependent on the vector grid shader?