Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Curved World (OLD) - Screen Space Curvature Shader

Discussion in 'Assets and Asset Store' started by Arkhivrag, Nov 20, 2014.

Thread Status:
Not open for further replies.
  1. AnimosusIII

    AnimosusIII

    Joined:
    Nov 8, 2012
    Posts:
    18
    Ok ,Thanks !
     
  2. ixikos

    ixikos

    Joined:
    Jun 21, 2013
    Posts:
    26
    Thanks again for the shader, I bought this the other day and am enjoying looking at the thought and work put into this project.

    Is it trivial to make the shader matrix the calculation is based off of from the camera transform and looking straight out along the z axis? For my current project, this would be the ideal effect. If not, I look forward to using this sometime in the future.

    cheers.
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Hi,
    Can you show some images or may be video of the effect you'd like to achieve. Or I am afraid I can not clearly understand your question.



    VacuumShaders - Facebook Twitter YouTube
     
  4. EtherGames

    EtherGames

    Joined:
    Jan 10, 2013
    Posts:
    12
    Hey i want to buy your assets.

    But beforehand i want to clarify few things.

    1. Our is a game like subway surfer, will it apply curve to dynamic incoming vehicles and coins ( randomly generated ) ?
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Yes, without problem.



    VacuumShaders - Facebook Twitter YouTube
     
  6. MasterKelli

    MasterKelli

    Joined:
    Jul 18, 2014
    Posts:
    11
    Do you have a solution for the raycasting from camera? It needs to be made incrementally raycasting inverse curved rays, I'm working on my own solution but was asking if your packade does have a working solution? I would consider purchasing if it does. :)
     
    Last edited: Feb 12, 2015
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    No, such solution is not included.



    VacuumShaders - Facebook Twitter YouTube
     
  8. MasterKelli

    MasterKelli

    Joined:
    Jul 18, 2014
    Posts:
    11
    Ok, good to know.

    I just solved the problem myself, it was quite simple :D If you are interested in knowing the solution I can post it for you so you can include the ability to raycast through the curved world.
     
  9. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
  10. MasterKelli

    MasterKelli

    Joined:
    Jul 18, 2014
    Posts:
    11
    Ok, here it is.

    Code (CSharp):
    1.  
    2. public bool BentRayCast(Ray r, out RaycastHit hitInfo)
    3.     {
    4.         // Define iteration count and single ray distance (less iterations = more performance but less accuracy)
    5.         int iterationCount = 10;
    6.         float rayDist = 50.0f;
    7.  
    8.         // Variables for optimization
    9.         float rayLength;
    10.         Vector3 rayStart;
    11.         Vector3 rayEnd;
    12.         Vector3 rayDir;
    13.         Ray bentRay = new Ray();
    14.  
    15.         // Raycast multiple times to "curve" the raycast
    16.         for (int i = 0; i < iterationCount; ++i)
    17.         {
    18.             rayStart = GetInverseCurvedPosition(r.origin + i * (r.direction * rayDist));
    19.             rayEnd = GetInverseCurvedPosition(r.origin + (i + 1) * (r.direction * rayDist));
    20.  
    21.             rayDir = rayEnd - rayStart;
    22.             rayLength = rayDir.magnitude;
    23.  
    24.             bentRay.origin = rayStart;
    25.             bentRay.direction = rayDir / rayLength;
    26.  
    27.             if (Physics.Raycast(bentRay, out hitInfo, rayLength))
    28.                 return true;
    29.         }
    30.  
    31.         hitInfo = new RaycastHit();
    32.  
    33.         return false;
    34.     }
    35.  
    36.     public Vector3 GetInverseCurvedPosition(Vector3 position)
    37.     {
    38.         // convert position to camera space
    39.         position = camera.worldToCameraMatrix.MultiplyPoint(position);
    40.  
    41.         float zOff = position.z / distance;
    42.  
    43.         // inverse bend position and return world space position
    44.         return camera.cameraToWorldMatrix.MultiplyPoint(position - offset * zOff * zOff);
    45.     }
    46.  
    47.     // Simple example of use:
    48.     void Update()
    49.     {
    50.         RaycastHit hitInfo;
    51.  
    52.         if (Input.GetMouseButtonDown(0))
    53.         {
    54.             // Get the normal ray that you would use without bending
    55.             Ray originalRay = camera.ScreenPointToRay(Input.mousePosition);
    56.  
    57.             if (BentRayCast(originalRay, out hitInfo))
    58.             {
    59.                 // Do whatever you would do with the raycast
    60.             }
    61.         }
    62.     }

    Your curvature calculation might be different than mine so what you need to change is the code inside GetInverseCurvedPosition. It needs to be inverse of your vertex offset calculation from your vertex shader.
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    wow, thanks for sharing.



    VacuumShaders - Facebook Twitter YouTube
     
  12. Fahrettin

    Fahrettin

    Joined:
    Mar 10, 2014
    Posts:
    81
    Can i make infinite road with this asset like your videos or i need to find another solution + your asset ?
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Yes you can make infinite bend road effect.
    Curved World is a collection of shaders (not 3d assets) that can make bending effects like in promo video and demo(Web demo available).
    All scenes from web demo are inside package as example scenes, you can inspect them.



    VacuumShaders - Facebook Twitter YouTube
     
  14. Fahrettin

    Fahrettin

    Joined:
    Mar 10, 2014
    Posts:
    81
    I checked your videos and webdemo. I want to make a scene like your runner but with a car. I was searching all-in-one solution for endless track.
    Thanks for the info.
     
  15. realworld666

    realworld666

    Joined:
    Nov 2, 2012
    Posts:
    24
    How do I make a "Use Mesh Vertex Color" checkbox appear in the inspector for a custom shader? I have defined
    Code (csharp):
    1. #pragma multi_compile V_CW_VERTEX_COLOR_OFF V_CW_VERTEX_COLOR_ON
    in the shader.
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    All optional parameters being displayed inside Curved World material editor are handled by custom editor scripts.
    You can not use that scripts inside your custom shaders.
    But you can make you own property drawers: check-boxes, drop-down lists, etc.
    Here is doc: http://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html



    VacuumShaders - Facebook Twitter YouTube
     
  17. realworld666

    realworld666

    Joined:
    Nov 2, 2012
    Posts:
    24
    Thats great. Thanks very much.
     
  18. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Will this work with Unity 4.6?
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Yes.



    VacuumShaders - Facebook Twitter YouTube
     
  20. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Thanks I purchased it an after a quick review of the package I'm quite happy. It seems quite suitable for endless runner variant game.

    I'm just wonder if you know what endless runner games have used this asset. I'm curious about any interesting implementations.
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Thanks,
    I do not know games where my shaders are used. But effect that offers Curved World are used in most runners (and not only runners).



    VacuumShaders - Facebook Twitter YouTube
     
  22. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    Has anyone found a way to make this AWESOME asset work with the new Unity 5 standard sharder? If so, please do share :)
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Unity 5 beta is currently not supported, waiting for final release.



    VacuumShaders - Facebook Twitter YouTube
     
  24. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    that said... some minor help in setting up the Curved World shader for the RELEASE CANDIDATE 2 for Unity 5, which all other asset store assets i use have done so, would be much appreciated!
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Do not know what other assets did, but related to shaders and rendering passes Unity 5 beta still has bugs and has not been tested enough.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Feb 23, 2015
  26. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    Bugs or not, it is now in release candidate state... The standard shader is in a near final state, and it would be most helpful to have some advice on where to inject the curved world shader code into it.
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Yesterday I had time to work with Unity 5 for the first time and here is my reaction about recreating (yes recreating, not importing) Curved World to Unity 5.
    nope.gif
    This is about deferred rendering and shadows. In Unity 4 I modified shadow collector pass to make them curvy, but in Unity 5 shadow collector pass is completely removed and I can not figure out how to render it know.



    VacuumShaders - Facebook Twitter YouTube
     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Little update v1.21
    Scene Material Baker replaced with improved Scene Material Manager.
    Now it is possible to review all scene materials(not only Curved Worlds) and easy control of global switch of the materials.



    VacuumShaders - Facebook Twitter YouTube
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Update v1.22
    • Fixed - Particle shaders did not display global switch button inside material editor.



    VacuumShaders - Facebook Twitter YouTube
     
  30. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    Youch... looks like I'll have to strip curved world out of any projects destined to be moved to Unity 5, until you give word of a solution. Thank you for taking the time to check out the potential of moving to Unity5 with Curved World. I'll await you potentially being able to port to Unity5 :)
     
  31. jalapen0

    jalapen0

    Joined:
    Feb 20, 2013
    Posts:
    136
    Could this asset be used to apply a slight curvature to a terrain to make it more planet like? Is it possible for it to NOT affect anything but the terrain? For instance, I do not want it to affect the game objects sitting on the terrain, only the terrain itself.
     
  32. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Unity Terrain is not supported, because Unity engine bug. If it will be fixed in Unity 5 I'll add it.



    VacuumShaders - Facebook Twitter YouTube
     
  33. jalapen0

    jalapen0

    Joined:
    Feb 20, 2013
    Posts:
    136

    Ok, I'll watch for that fix, thanks.
     
  34. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    If your luck you might be able to export a Unity terrain as obj and re-import it. Not perfect but might come close
     
  35. sirio21

    sirio21

    Joined:
    Mar 11, 2013
    Posts:
    114
    hi!, Curved World works like an image post procesor or work culling objects? Thanks
     
  36. psimek

    psimek

    Joined:
    Nov 9, 2014
    Posts:
    7
    Any word on Unity 5 support for fog/shadows?
     
  37. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Curved World is not image effect, it is per mesh material effect. Just apply material with Curved World shader to the mesh and it will be bended.

    Unity 5 is currently not supported. I have 7 assets on the Asset Store and I need time to convert them all.




    VacuumShaders - Facebook Twitter YouTube
     
  38. sendmyfile

    sendmyfile

    Joined:
    Jan 31, 2014
    Posts:
    9

    any chance some one know how to use this? newbie coder need help.
     
  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Update v1.24 released.

    Pickup.png

    Added function inside Global Controller for calculating bend point.
    GetBendPoint() - function takes point world space position and returns its bend variant (also in world space).

    for example, if you apply this scrip to any object (do not use Curved World shader), Global Controller will modify scene position according to its parameters.
    Code (CSharp):
    1. public class PointBend : MonoBehaviour
    2. {
    3.   Vector3 origPosition;
    4.   // Use this for initialization
    5.   void Start()
    6.   {
    7.   origPosition = transform.position;
    8.   }
    9.   // Update is called once per frame
    10.   void Update ()
    11.   {
    12.   transform.position = CurvedWorld_GlobalController.get.GetBendPoint(origPosition);
    13.   }  
    14. }
    If you attach script to the collider its position will be updated and you can hit it using Physics.Raycast().



    VacuumShaders - Facebook Twitter YouTube
     
  40. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    So from what I gather, you have NO PLANS to implement Unity 5 with this?
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Why "NO PLANS" ?!
    Curved World for Unity 5 is in development. It is not ready yet.



    VacuumShaders - Facebook Twitter YouTube
     
  42. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Because of your post that said:
    Yesterday I had time to work with Unity 5 for the first time and here is my reaction about recreating (yes recreating, not importing) Curved World to Unity 5.

    This is about deferred rendering and shadows. In Unity 4 I modified shadow collector pass to make them curvy, but in Unity 5 shadow collector pass is completely removed and I can not figure out how to render it know.
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Yes, it was my first reaction. Just a joke :p.
    Curved World for Unity 5 is in development.



    VacuumShaders - Facebook Twitter YouTube
     
  44. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Well, some of those of us who paid for it, didn't see the humor.
    I'm glad it's in development now.
     
  45. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Some of those who buy anything on Asset Store have wrong thoughts that they are buying lifetime support and upgrade, you know. It's just my good will to give support and upgrade and do not care about humor sense level.



    VacuumShaders - Facebook Twitter YouTube
     
  46. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    If only your attitude towards the people who are buying the things you sell was as good as the screenshots of your products. You may not know this, but you have a reputation for being a total D**k around here. I have read in many places how you will not own up to your own assets and constantly lay blame at the feet of people who buy the things you sell. If you don't want to deal with other people, then find someone else to do product support for you.
     
    buttmatrix likes this.
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    Calm down, John. If you are such disappointed with the product and support, there's always the option of returning it!
    Just send Unity a mail!



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Mar 10, 2015
    schmosef likes this.
  48. Dean Avanti

    Dean Avanti

    Joined:
    Oct 21, 2012
    Posts:
    12
    If I fired a bullet, or a projectile rocket, would it work? or would I get problems? would the effect break, is this not suitable for fps, would certain weapons work, others not? I can see it would work perfectly for sword games, platform or driving, but how would shooting games effect things, I want to know how i could get something working to use for any sort of shooting games weapon types?
     
  49. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,986
    I have not tested shader on fps games and can not give correct/full answer now. But if you shoot at a bend object, Curved World has function for detecting bend object position, and it gets hit. Also projectile rocket will be bend and its movement will be curvy.
    You can try web demo, in second scene press space to go into fps mode, there is no shooting option, but you will have some feelings about fps.



    VacuumShaders - Facebook Twitter YouTube
     
  50. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    On building and deploying on the windows phone . All the objects with this shaders are like blue in color . Whats the reason. can anyone help me
     
Thread Status:
Not open for further replies.