Search Unity

► Curved World ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, Jul 28, 2015.

  1. McSwan

    McSwan

    Joined:
    Nov 21, 2013
    Posts:
    129
    How do I apply a curve to a terrain - I have 18 terrains in a group that need bending to create the curvature of the earth.
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Import Terrain and Foliage shaders from Curved World Settings window. Change terrain material.



    VacuumShaders - Facebook Twitter YouTube
     
  3. McSwan

    McSwan

    Joined:
    Nov 21, 2013
    Posts:
    129
    That worked - Thank you!
     
  4. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Hi,

    Would it be possibly to share a code example of how to change the bend amount over time (similar to the examples in the trailer video (city roll up etc.) please? I'm having trouble figuring out how to use the API and none of the example scenes do what I'm looking for.

    Thanks
    Spudly
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    You can control bend and bias parameters from CurvedWorld_Controller script. Check API.pdf file (page 2).



    VacuumShaders - Facebook Twitter YouTube
     
  6. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Yes, I know that, as it's been stated a lot before, but the API docs don't really give any details on usage, which is why I'm having a problem figuring it out and asking for a little example :-/
     
  7. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Well, after many hours of being a bit of a moron, I figured it out and it was a lot easier than my brain was making it.

    If anyone is interested, below is the code (with comments). I honestly don't know if this is the best way to do it, but it works. The bend speeds and amounts are hardcoded into this example, but are easy enough to modify.

    I have this set up so that you add it to the same 'container' object as the controller, but with a teeny bit of modification it can be added to anything and it will still work.

    For this I was using the 'Universal' bend type on a Terrain object, not tested with any other types as yet, so your mileage may vary.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using VacuumShaders.CurvedWorld;
    4.  
    5. public class BendSize : MonoBehaviour {
    6.  
    7.  
    8.     //Define Initial Values for bend
    9.     float BendX = 0f;
    10.     //float BendY = 0f;  :: Not Used in this Example
    11.     float BendZ = 0f;
    12.  
    13.     //Speed at which the object Bends
    14.     float bendSpeed = -0.001f;
    15.  
    16.     //Define our controller script
    17.     CurvedWorld_Controller curveController;
    18.  
    19.     void Start() {
    20.  
    21.         //'Grab' the controller script from the current Object
    22.         curveController = this.GetComponent<CurvedWorld_Controller> ();
    23.  
    24.     }
    25.  
    26.     void Update () {
    27.  
    28.         //Define our current bend amount variable and grab it from the controller script
    29.         Vector3 currentBend = (Vector3)curveController.GetBend();
    30.  
    31.         //Assign 'current bend values to temporary variables
    32.         float currentBendX = currentBend.x;
    33.         float currentBendZ = currentBend.z;
    34.  
    35.         //Check to see if we have reached out desired bend amount, if not increment the bend values.
    36.         if (currentBendX >= -0.1f) {
    37.             BendX -= bendSpeed * Time.deltaTime;
    38.         }
    39.  
    40.         if (currentBendZ >= -0.1f) {
    41.             BendZ -= bendSpeed * Time.deltaTime;
    42.         }
    43.  
    44.         //Define our new Complete Bend information ready to send back to the controller
    45.         Vector3 newBend = new Vector3 (BendX, 0, BendZ);
    46.  
    47.         //Send the new bend to the controller and adjust the bend.
    48.         curveController.SetBend (newBend);
    49.  
    50.     }
    51. }
    Thanks
    Spudly.
     
  8. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Heh,

    So, this is a lot easier than I was making it.

    Another quick script, again not sure if this is the best way to do it, but this one alters the curvature based on the vertical distance to the camera. (ie. the further away the camera, the more 'round' the terrain. Again some hard coded values, I'm sure that there's some clever maths that will make it perfect, but that's for another day. :)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using VacuumShaders.CurvedWorld;
    4.  
    5. public class CameraAltitude : MonoBehaviour {
    6.  
    7.     //**************************************************************
    8.  
    9.     //Define Initial Values for bend
    10.     float BendX = 0f;
    11.     //float BendY = 0f;  :: Not Used in this Example
    12.     float BendZ = 0f;
    13.  
    14.     //Define our controller script
    15.     CurvedWorld_Controller curveController;
    16.  
    17.     //**************************************************************
    18.  
    19.     float heightAboveTerrain;
    20.     public Camera testCamera;
    21.  
    22.     // Use this for initialization
    23.     void Start () {
    24.    
    25.         //'Grab' the controller script from the current Object
    26.         curveController = this.GetComponent<CurvedWorld_Controller> ();
    27.  
    28.     }
    29.  
    30.     // Update is called once per frame
    31.     void Update () {
    32.  
    33.         Transform rayEmitter = testCamera.transform;
    34.         RaycastHit hit;
    35.         Ray downRay = new Ray (rayEmitter.transform.position, -Vector3.up);
    36.         if (Physics.Raycast (downRay, out hit)) {
    37.  
    38.             heightAboveTerrain = hit.distance;
    39.             Debug.Log (heightAboveTerrain);
    40.  
    41.             BendX = heightAboveTerrain / 10000;
    42.             BendZ = heightAboveTerrain / 10000;
    43.  
    44.             //Define our new Complete Bend information ready to send back to the controller
    45.             Vector3 newBend = new Vector3 (-BendX, 0, -BendZ);
    46.  
    47.             //Send the new bend to the controller and adjust the bend.
    48.             curveController.SetBend (newBend);
    49.  
    50.         }
    51.     }
    52. }
    Thanks
    Spudly.
     
  9. BigYetti

    BigYetti

    Joined:
    Apr 11, 2015
    Posts:
    26
    Can this asset be used to make a fully spherical area (like a planet) that can be traversed across the edge boundary?
     
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    No. There is no such mathematical equation which converts plane into sphere.



    VacuumShaders - Facebook Twitter YouTube
     
  11. atpkewl

    atpkewl

    Joined:
    Jun 30, 2015
    Posts:
    17
    Did this get resolved ? i also have the same issue... i don't understand what normal, tangent means and how to add them to meshes
     
  12. atpkewl

    atpkewl

    Joined:
    Jun 30, 2015
    Posts:
    17
    @DEggleton Did you resolve the flickering issue ? i have the same one... only happened when I rotate object with One Directional Light shader
     
    hopeful likes this.
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    There is nothing to be resolved.
    Light calculation needs Normal and Tangent, like texture rendering needs UV.



    VacuumShaders - Facebook Twitter YouTube
     
  14. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I have a camera that is using a custom variant of the Follow script to follow a character around a surface curved by the CurvedWorld shader. The problem, however, is as I move away from the origin, so as to move the character around the sides of the curve, all the rendered geometry appears to experience shearing. Like what happens when you have an object that is a child of a non-uniformly scaled parent. The reason I made a custom variant is because I suspected it might be caused by the fact the camera's rotation (specifically its up vector) wasn't matching the curvature of the world. So I just added code to cause it to rotate as it moves over the circumference of the level, but that doesn't seem to have had any effect.

    What am I missing? Thanks!
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Curved World shaders do vertex offset (transformation) in the world space, camera position and orientation doesn't effect them. However each bend effect is to be observed from specific position.

    For example Classic Runner bend effect from two different position:
    Untitled-1.png

    or Little Planet
    Untitled-3.png

    or Cylindrical Tower
    Untitled-2.png

    Further the vertex is from the pivot point more offset it takes. Again, each bend effect is to be observed from specific positions.
    You are missing nothing. But you just can not do a big orbital camera rotation around pivot point.

    Correct third person camera with Little Planet





    VacuumShaders - Facebook Twitter YouTube
     
  16. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Ah, okay, that's what I had wrong -- I wasn't setting the pivot point to match the position of the camera. Or should it match the position of the character (such as the character in the third-person example above shown in the animated GIF)?
     
  17. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Hi. I'd like to ask the Classic Runner shader is fine to use for mobile game projects?
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Hi, mobile shaders in Curved World are hand optimized and supper fast :cool:



    VacuumShaders - Facebook Twitter YouTube
     
  19. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Hey, not sure if I changed something or if it was the Curved World update, but my 2D sprite now gets cut off by the curved ground when I move him left/right. Didn't seem to do this before.

    Did something change for that? I haven't worked on my game in a few months so I'm not sure if It's something with the Unity update or Curved World updating, or if I did something to have it get cut off.

    Any chance anyone knows how to resolve that? I'm using the standard VacuumShaders/CurvedWorld/Sprites/Default(2Sided)

    Thanks!


    EDIT: I changed the Pivot Point so it always stays at the players position (camera follows player) and that seemed to fix it. Before it was a fraction of the way between the center screen and players position, so that seems to be what's now cutting it off. Is there any way around this now? Ideally I'd like to keep my pivot point how I had it (pivot point transform.position=newVector3(player.position.x/1.5f,transform.position.y,transform.position.z)

    Thanks!
     
    Last edited: Dec 6, 2016
  20. sunnysun

    sunnysun

    Joined:
    Jul 24, 2015
    Posts:
    13
    Hi,

    Unity's built in global fog doesn't seem to work on curved world unlit objects or am I missing something?

    Thanks.
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Enable Fog options inside material editor.



    VacuumShaders - Facebook Twitter YouTube
     
  22. Usmith

    Usmith

    Joined:
    Apr 7, 2013
    Posts:
    20
    Hi Arkhivrag!
    I'm using Curved World in our project, I found a strange phenomenon ,
    let's set up the environment first:
    1) Curved world is working under Little planet mode.
    2) We have a 'big' scene about size 1500x1500x100(X,Z,Y), it's a mesh converted from terrain.
    3)A camera hover on the mesh , the height is about 500.
    4)when I drag the mouse, the camera moves along X and Z, it looks like a satellite moving above the earth and looking at the ground at 45 degrees.

    The problem is, when I drag the mouse moving the camera, the earth shaking up and down. It's not a problem until our artist scaled the mesh from size 300x300x20 to 1500x1500x100 (5 times bigger, and yet the camera hovering height changed from 100 to 500).

    I found if I disable the CurvedWorld_Controller component first and then enable it, everything goes right. It temporarily avoids the embarrassment because we luckily have a cut that the camera has a 90 degrees looking right down to the earth, when this occurring, I switch the controller off and on , and later when camera rotate back to 45 degrees, things look right.
    I'd like to find out what causing this shaking, but the code was compiled into CurvedWorld.dll thus I can do nothing about it.
    So I wondering if you could offer a sourced version of CurvedWorld , like some other assets in asset store, with additional money.
    Thank you!
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Hi,
    Can you send asset purchase invoice to: vacuumshaders@gmail.com



    VacuumShaders - Facebook Twitter YouTube
     
  24. cmos

    cmos

    Joined:
    Aug 6, 2012
    Posts:
    10
    Hi, I can't seem to find a working online demo for this. Can you post the link again?

    Also, I will be able to walk around a 2 sphere seamlessly with this asset?
    For example, no walls are needed. I am not sure how this is done via your screenshots
    so just want to make sure before I get it since that is the main aspect of my game idea.
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Web demo may not work because of your web browser (Unity also does not support it any more). Try PC build.

    About seamless sphere - no you can not, there is no any kind of 'sphererification' of meshes. They still remain the same as before applying shader.


    VacuumShaders - Facebook Twitter YouTube
     
  26. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Just updated to the new Curved World. My previous post talked about having a moving pivot point. This time it "works" and I can see the pivot point moving in the Scene editor along with the curve, but it doesn't seem to render in the actual game.

    I have a player that moves left and right. Camera follows him. The pivot point is basically player.position.x / 1.5f (so the curve changes a bit as you move from the center) but the curve doesn't seem to change in-game.

    Any ideas?

    Thanks!
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    It's difficult for me to figure out what you are trying to achieve and what is the problem. Can you capture video or may be some screens-shots.
    Note, that Prespective2D bend type always has the pivot point in the screen center. It is the only one such bend effect (screen space bend), other are world space modifiers.



    VacuumShaders - Facebook Twitter YouTube
     
  28. Vaille

    Vaille

    Joined:
    Nov 30, 2015
    Posts:
    1
    Hello !

    I'm actually working on a project with a team, but we have encountered some problem with the curved world shader when we added the Blob shadow projector of Unity. Since everything in the game is unlit, we had to use the shadow projector of Unity to simulate a shadow. However, the shadow projector display the projection before being curvified : the result is 2 separated map, the normal one, and the one with the fake shadow on it . Here is a pic

    problem.jpg

    Is there a way to force the blob shadow projector of unity to be curved or priorize it ?

    Thanks a lot, exept this little problem, everything work like a charm with curved world !
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Curved World includes projector shader.
    Note, projector gameobject position must be updated using Follow script.



    VacuumShaders - Facebook Twitter YouTube
     
  30. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Actually looking at it again it would appear the bend isn't working at all to the left and right of the player (as it's shown in the Scene Editor).

    In an older version the hill almost looks like a sort of halfpipe, if that makes sense? I don't think the pivot point is the problem. You can see the "half pipe" curve in the Scene Editor but not in the rendered game. I have an old version on my phone that works as it should... maybe I changed something or didn't update something correctly? It's been a few months since I touched the game and when I updated Unity and Curved World that part stopped working.

    I really hope this makes sense!

    Thank you so much!

    Video link:
     
  31. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Ok actually I opened up an older version of the game and the curve is there.. it had to have been something I did (no idea what it could be, though!).... I will get to the bottom of it, but if you know what I may have done please let me know - thanks so much, sorry for thinking something was broken!
     
  32. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Argh.... ok.. I figured more out. It appears to work on mobile but not on mac/ps builds. Any chance I can get this working?

    Sorry for all the posts!
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Do you use any custom shaders?
    How about an empty scene with only Plane meshes? Do they bend correctly?
    Curved World bending formulas has not changed since release, so shaders are the same

    Works without problem
    Untitled.png



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Dec 14, 2016
  34. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    I do use one custom shader, for the mountains in the back, all it does is sets it so it's not affected by fog. Is there something I should do with this shader?

    I went back to Mac/PC build and took the shader out with no effect (except you cant see the mountains)
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    How about an empty scene with only Plane meshes? Do they bend correctly?



    VacuumShaders - Facebook Twitter YouTube
     
  36. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Hmmm yup it looks like it does work correctly, you're right. No clue why it's not working in my other scene, tho!
     
  37. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Seems problem is in your scene setup.
    Make sure there is only one CurvedWorld_Controller script in the scene.



    VacuumShaders - Facebook Twitter YouTube
     
  38. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Hmm I do only have one. And it looks like my old build has the same problem... not sure what could be interfering with that!
     
  39. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    What gets me is that it works fine for mobile builds.. hmm..
     
  40. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Hmmm quick update: it does work when I turn fog off - perhaps it is something with those custom shaders? Not sure what to do about them, though. I'd prefer they work and would prefer the fog on but I'm not sure how to fix it for PC/Mac builds
     
  41. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Here is the shader, I didn't write it myself I found it online... maybe that is breaking something? So weird, though.. this shader and fog both work on mobile builds. I wish I knew more about this... I'm still learning
     

    Attached Files:

  42. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    Hm actually fog breaks the curve in my empty test scene as well :(
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    I cann't help with custom and third party shaders.



    VacuumShaders - Facebook Twitter YouTube
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
  45. subver

    subver

    Joined:
    Feb 22, 2016
    Posts:
    20
    This was just using an empty scene with a plane and curved world, without a third party shader - on mac and pc builds turning fog on in Unity broke the curve... I added some modules last night (added PC and Android builds) and now my whole game is broken this morning so I can't really test anything at the moment.. trying to reinstall Unity to get to where I was... frustrating!

    The fog breaking was probably something I was doing wrong, though, if it works for you on the latest Unity.
     
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    After heavy testing on Unity 5.3, 5.4, 5.5 I was not able to reconstruct issue. Everything works. No problem with fog.
    Fog is just a color value applied in pixel shader, I do not think it can effect Curved Worlds per-vertex transformation.



    VacuumShaders - Facebook Twitter YouTube
     
  47. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    I'm using Curved World on a Gear VR game which has been working great, until I updated today.

    I stupidly updated unity from 5.4 to 5.5 which stopped Curved World from working, but after I updated Curved World to the latest version all looked good.

    I do not know which update broke this, either Unity or Curved World itself.

    In the editor my game runs fine and the world is curved as expected, however, when I deploy to the GearVR its bending in the wrong direction?

    The shaders are set to Little Planet and worked great in unity 5.4, but on the Gear VR after the update, they are now bending to the left, is that the Runner setting? In VR this is very sickening!

    Any thoughts on how to solve this?
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Try recompiling shaders. Go to the Curved World Settings window and change bend type, then click Update Shaders button.



    VacuumShaders - Facebook Twitter YouTube
     
  49. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    Thanks for the quick reply, but unfortunately I've already tried that and it didn't help.
     
  50. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    I just tried deleting everything and putting it all back to unity shaders, re-installing curved world and setting everything back up again. Unfortunately I have the same results, it works great in the editor but on my phone it's the wrong bend :(

    If it makes a difference, I'm using the legacy shaders because this is mobile and VR.

    I'm going to un-install unity and go back to 5.4 with an older back up until I know this has been fixed.