Search Unity

► Curved World 2 ◄

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

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    If you need a real 3D earth model this tool is not for that.

    Yes, single-stereo rendering is supported. No limitations or additional tips for VR.



    VacuumShaders - Facebook Twitter YouTube
     
  2. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    496
    I'm trying to add Curved World to a shader from a different Unity asset pack, and I can't seem to figure out where I should be adding the function. Here's one of the vertex passes:

    Code (CSharp):
    1. VertexOutput vert (VertexInput v) {
    2.              
    3.              
    4.                 VertexOutput o = (VertexOutput)0;
    5.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
    6.                 o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
    7.                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    8.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    9.                 V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    10.                 o.uv0 = v.texcoord0;
    11.                 o.uv1 = v.texcoord1;
    12.                 o.uv2 = v.texcoord2;
    13.                 o.vertexColor = v.vertexColor;
    14.                 #ifdef LIGHTMAP_ON
    15.                     o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
    16.                     o.ambientOrLightmapUV.zw = 0;
    17.                 #endif
    18.                 #ifdef DYNAMICLIGHTMAP_ON
    19.                     o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
    20.                 #endif
    21.                 o.pos = UnityObjectToClipPos(v.vertex );
    22.                 return o;
    23.              
    24. }
    Have I added the V_CW line in the correct place? What I missing?
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Code (CSharp):
    1.  
    2. VertexOutput vert (VertexInput v)
    3. {
    4.     VertexOutput o = (VertexOutput)0;
    5.  
    6.     //Do Curved World vertex transformation first!!!
    7.     V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    8.  
    9.     o.normalDir = UnityObjectToWorldNormal(v.normal);
    10.     o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
    11.     ....
    12.     ....
    13.     ....
    14.  
    Check ReadMe file and example shaders.



    VacuumShaders - Facebook Twitter YouTube
     
  4. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    496
    I had tried that first, but that was unsuccessful as well. Is there anything else that might be affecting it?
     
  5. winterkewl

    winterkewl

    Joined:
    Oct 28, 2011
    Posts:
    53
    I'm having an issue downloading and installing this package from the asset store. I've tried doing it from various versions of unity, I've tried storing the .package file at the c: and starting a project at c:\testProject, The disks have plenty of space left on them etc, but no matter what I try, I keep getting this error when i try importing this package:

    "Failed to import package with error: Couldn't decompress package"

    Has anyone seen this before? Any tips on how to alleviate this issue?

    I've also tried, installing from Unity 5.5.1, 5.6.0, 2017.2 and 2017.3 , restarted the computer, deleted the entire AppData/Roaming/Unity/Asset Store-5.x directory and redownloading from the asset store, and I've tried decompressing the .unitypackage with 7zip. None of those worked.
     
    Last edited: Feb 5, 2018
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Seems to be Unity or 7-Zip plugin problem.



    VacuumShaders - Facebook Twitter YouTube
     
  7. behrouzb

    behrouzb

    Joined:
    Feb 14, 2018
    Posts:
    9
    I purchased the classic runner version, but it seems like the scene curves along the wrong direction as seen in this image. My character moves left to right, along blue arrow. but the shader curves along the red arrow. I can not seem to find a solution to fix this. Any idea what I should do?
    Thanks
    bending angle.jpg
     
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Curvature is applied along world Z axis.



    VacuumShaders - Facebook Twitter YouTube
     
  9. behrouzb

    behrouzb

    Joined:
    Feb 14, 2018
    Posts:
    9
    Ok, thanks, and how do I change it to X axis? all the controls I have are x-axis bed size and y-axis bed size. For this image I only have y-axis bed size set to 1.
     
    Last edited: Feb 16, 2018
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    It will not be easy, changes must be done inside CPU part too, not only shaders.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Feb 28, 2018
  11. behrouzb

    behrouzb

    Joined:
    Feb 14, 2018
    Posts:
    9
    Ok thank you, and how can I animate the curve amount, I am applying this to my road so that it changes curvature as the player moves forward.
     
  12. behrouzb

    behrouzb

    Joined:
    Feb 14, 2018
    Posts:
    9
    When I apply the curved world shader to my object the contrast is increased a lot, any idea why this is happening and how I can fix this issue? curved-world.jpg
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Make sure mesh has correct Normals and Tangents. Those are required for light calculation.



    VacuumShaders - Facebook Twitter YouTube
     
  14. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    @Arkhivrag It would be INSANELY beneficial with two minor updates to CurvedWorld_Controller:

    A) An option to "Do NOT curve while NOT in playmode"
    B) A type of Singleton pattern, or other means so the system does not fail if the script is run a second time at playtime

    But specially A, it is REALLY annoying that this is in a DLL so I cannot just trhow in that line myself!

    Seriously: When using your system, now I have to click On/Off EVERY time I need to change something on the level, because basically this is present in .. Hmm hang on, I can probably make a hack where this is loaded by.. OK, I can probably do this, but it stinks that I have to hack such a thing ;)

    UPDATE:
    [Hack failed, execution order constant battle in dynamic loads, persistent GO's etc, PLEASE add the option to not be on in Edit mode, the On/Off was largely the reason for not writing it / copy pasting it from somewhere else myself - had not seen you only provided DLL, thanks]
     
    Last edited: Mar 26, 2018
  15. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    @Arkhivrag Instead of / as an alternative to the Eagle Eye, would it be possible to slightly tilt the camera on culling-calculation?
    The thing is: I do not want to render more to the sides, however I do want to catch the upper parts of the world.
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Ok.



    VacuumShaders - Facebook Twitter YouTube
     
  17. Parallel_

    Parallel_

    Joined:
    Dec 9, 2012
    Posts:
    90
    Hi, I installed the latest version on Unity 2017.3.f3, and it threw notifications (separate issue with other assets), then I deleted the VacuumShaders folder and it has ever since been reinstalling itself after a few clicks on the clean scene!?

    After deleting the folder the console prints a bunch of "Assertion failed: Failed to unload 'Assets/VacuumShaders/Curved World/Example Scenes..", (which I haven't opened, yet alone applied any Curvy World shaders in the first place) but the folder is gone..
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Curved World has no methods for reinstalling itself ,seems Unity Editor issues, try delete projects Library folder.



    VacuumShaders - Facebook Twitter YouTube
     
  19. sergioserman

    sergioserman

    Joined:
    Feb 24, 2017
    Posts:
    2
    Hello!
    I am using unity 2017.3.f1
    I have a terrain which uses your amazingWireframe geometry shader to display the wireframe and the original mesh.
    Screen Shot 2018-04-11 at 01.34.25.png
    I also want to have a curved world so I bought this asset. But it seems they don't work together. I get also an error in the "curved world compatibility" menu:
    Screen Shot 2018-04-11 at 01.27.39.png

    ¿Do you know if it is possible to combine both shaders? ¿how? Thanks!
    Screen Shot 2018-04-11 at 01.39.01.png
     
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Seems you are using old versions. Completely remove both assets from the project, clear Asset Store cache folder and re-download assets from the store.
    Just tried in Unity 2017.3.1f and everything works at my side.



    VacuumShaders - Facebook Twitter YouTube
     
  21. sergioserman

    sergioserman

    Joined:
    Feb 24, 2017
    Posts:
    2
    Ok thanks, I will try but I think I downloaded a fresh new copy just couple of days ago.

    I am on mac... Maybe it is something with the path and \ / things?? When I open the compatibility window I see this: FileNotFoundException: Could not find file error: "/Users/sergio//unity/ccbox/Assets/VacuumShaders/\The Amazing Wireframe Shader\Shaders\cginc\Wireframe_Core.cginc".
     
  22. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    Hi @Arkhivrag - you wrote "OK" some 2 weeks ago, and I have been telling my team that "they should just be patient", soon they will no longer have to enable / disable gameobject every time they go in / out of playmode..

    But did I understand you right, are you adding a "do not curve in Playmode" bool any time soon?
    (Or granting me access to some source to I can just implement this simple but extremely needed feature myself?)

    Thanks!
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Already submitted new version v2018.1



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: May 1, 2018
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Try attached file.
    Copy it into Assets\VacuumShaders\The Amazing Wireframe Shader\Editor folder.
    Currently can not test myself on MAC. If still have questions use support e-mail: vacuumshaders@gmail.com



    VacuumShaders - Facebook Twitter YouTube
     

    Attached Files:

  25. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    Hi @Arkhivrag

    I'm stuck with the lack of access to source in your product, maybe you can help me again?

    We're doing a mobile game using Matcap shaders alone. It's no problem to change matcap shaders to use Curved World efx.

    As I'm sure you know, a "round" shape using a matcap-based shader material will show "points around" on the matcap source texture; The texture is usually an image of a lit sphere of sorts.

    A "flat" shape will only use "one point" from this matcap source texture, according to the normal on that "flat" shape; The color will be the same all over the flat surface.

    Now, your project turns "flat" into "round", however the Matcap Shader is not informed this, so flat surfaces that are curved by your system, are "completely dead", as the "curving" is not passed on for the matcap shader to use.

    What's needed is a simple Matcap Shader that is passed a variable of "a fake normal" from "The Curved World".

    .. One way or the other..

    But it's not really possible for us to hack as your source is closed.

    I attach below a Matcap Shader - from the public domain, common techniques - that has your functionality inserted, it works, apart form the lack of "curved info passed on".

    Can you provide a way for us to pass the "curved info" on, or implement this shader into your project, but with the described effect of proper Matcap effect?

    Thanks!

    Code (CSharp):
    1. Shader "MatCaps/Vertex/Plain_Curved"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
    6.         _MatCap ("MatCap (RGB)", 2D) = "white" {}
    7.          _Curvature ("Curvature", Float) = 0.001
    8.     }
    9.    
    10.     Subshader
    11.     {
    12.         Tags
    13.         {
    14.         "RenderType"="Opaque"
    15.         "PreviewType" = "Skybox"
    16.         }
    17.        
    18.         Pass
    19.         {
    20.             Tags { "LightMode" = "Always" }
    21.            
    22.             CGPROGRAM
    23.                 #pragma vertex vert
    24.                 #pragma fragment frag
    25.                 #pragma multi_compile_fog
    26.                 #pragma fragmentoption ARB_precision_hint_fastest
    27.                 #include "UnityCG.cginc"
    28.                 #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    29.                
    30.                  uniform float _Curvature;
    31.                 uniform float4 _Color;
    32.                 uniform sampler2D _MatCap;
    33.  
    34.                 struct v2f
    35.                 {
    36.                     float4 pos    : SV_POSITION;
    37.                     float2 cap    : TEXCOORD0;
    38.                     UNITY_FOG_COORDS(1)
    39.                 };
    40.  
    41.                 v2f vert (appdata_base v)
    42.                 {
    43.                     V_CW_TransformPoint(v.vertex);
    44.  
    45.                     v2f o;
    46.                     o.pos = UnityObjectToClipPos (v.vertex);
    47.                    
    48.                     float3 normalW = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
    49.                     normalW = mul((float3x3)UNITY_MATRIX_V, normalW);
    50.                    
    51.                     o.cap.xy = normalW.xy * 0.5 + 0.5;
    52.                     UNITY_TRANSFER_FOG(o, o.pos);
    53.  
    54.                     return o;
    55.                 }
    56.                
    57.                 float4 frag (v2f i) : COLOR
    58.                 {
    59.                     float4 matCapCol = tex2D(_MatCap, i.cap);
    60.                     matCapCol = _Color * matCapCol * 2.0;
    61.                     UNITY_APPLY_FOG(i.fogCoord, matCapCol);
    62.  
    63.                     return matCapCol;
    64.                 }
    65.             ENDCG
    66.         }
    67.     }
    68.     Fallback "VertexLit"
    69. }
    70.  
     
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    P
    Package already includes Unlit shaders with Matcap option. You can check its source, that is not closed at all.



    VacuumShaders - Facebook Twitter YouTube
     
  27. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    Huh? As far as I can tell the word Matcap is not in documentation, and I cannot find it anywhere in any dropdowns?!

    Can you tell me how to get to this?
    Can you confirm this will consider the "curved world" so a "bend flat" will be "matcap lit as a bend shape" and not just a flat single color that is bend?

    Thx!
     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    upload_2018-5-2_20-15-20.png



    VacuumShaders - Facebook Twitter YouTube
     
  29. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    @Arkhivrag :
    OK, thanks a lot for the pointer. The thing is, your Editor script is not allowing multiple edits for "Curved World Optionals", so I was of course trying to "change the game to use your shader", by selecting the materials to change, and then the Matcap option did not show. One has to change a single material at a time for this to work. You might want to have a look at that ;)

    Fair enough, that will be an extra half hour of work, but never mind that part.

    Problem is: It's really not doing the job :)

    First most, a reason to use a matcap here, is that we want a very dynamic lightning, colors that change, has "depth". The matcap you include is apparently a form of "matcap lit", aka "matcap adding" or "multiplying".

    This is an extra pass (or at least an extra texture lookup), and it is far simpler / not as good looking result.

    It can of course be used in conjunction with UV mapping and textures, but I am not interested in that.

    I am interested in a genuine Matcap Shader!

    As simple as the one I showed above.

    Just a Matcap simple shader! Like known from for example Blender and Zbrush editors.

    Second problem is unfortunately that your "matcap lit shader" does exactly not take into account the "curved world", as was my original question :)

    So a flat surface, that is bend by your Curved World efx is still as flat lit as a flat surface. And that is the problem I had and have.

    Let me try and explain with 2 images:

    Here's your "Matcap Lit" in function. The ugly Yellow is to make sure we know what we are testing here.
    Note how there is a big flat area which is obviously Curved, but NO gradient from Matcap.

    Note how there is inserted a standard Sphere, and because the ORIGINAL mesh is curved, there is matcap gradient.

    We want the surface bend by Curved World Efx to display Gradient. The big flat area should have gradient. Because it is supposed to look as if it is bend.

    So we need to pass on "info of curvature" to shader. You have not done this in your shader. It is flat when original is flat.

    And your shader is not "Real matcap" to use some wording made up to decipher, it is "a texture that is matcap lit", so it is very poor color dynamics and an extra pass or calculation / texture.

    noGradient.png

    Here's a chaotic screenshot from game WIP.

    This is all Matcap (apart from the background that is other hacks.)

    Note how the "golden bubbles" clearly has more "dynamic color range" than what can be done by your more complex shader (the yellow sphere above).

    This is 100% the shader I showed you above.

    And one texture for every surface. It is cheap as f*** on mobile.

    realMatcap.png


    However, back to the actual and original problem:

    Look at the very monotonous green grass at the button part of the screenshot.

    NO GRADIENT!

    But it is curved by your efx!

    I do not know how to pass on "curved info" to this shader, instead of just "normals" as it is using.
    Looking into your shader would not help, obviously, since it does not provide any gradient.

    I cannot look into your closed source, so I am asking for help.

    So, with this more lengthy, but hopefully more clearly formulated post, can I ask you for help on how to pass on "curvy" into the shader.

    Thank you :)
     
  30. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    So you need curved normal too, and not just only vertex? In that case transform both of them using V_CW_TransformPointAndNormal() method.

    Code (CSharp):
    1. v2f vert (appdata_tan v)
    2. {
    3.     V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    4.  
    5.     v2f o;
    6.     o.pos = UnityObjectToClipPos (v.vertex);
    7.     ...
    8.     ...
    9.     ...
    10.     return o;
    11. }


    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: May 2, 2018
  31. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    Hmm.. Thanks again, this works. But for some reason only when there's UV data on the mesh, if not I get some funny results. That does not appear optimized, as I have nothing to use UV data for, would rather not unwrap everything, so is there a way to avoid this need for UV?
     
  32. sarathzz

    sarathzz

    Joined:
    May 2, 2018
    Posts:
    6
    Hello @Arkhivrag,

    I'm quite new here in Unity. My Unity version is 2017.3.1f1.

    I brought your asset last night and tried to applied to to my project. I have a couple of question to asking you.

    1.) how can i apply First Person Character into my scene? I don't know is it the right way to do or not but when I drag your 'Standard Assets' folder into my project, but when i tried to play it shown "All compiler errors have to be fixed before you can enter playmode!"

    2.) how can I apply "curve world controller" which make everything bending to my terrain?

    Thank you
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    V_CW_TransformPointAndNormal() uses only vertex, normal and tangent. No need of UV.


    And what errors do you have? Unity prints error details inside Console window.
    For terrain bending import Terrain and Nature shaders from the Curved World settings window and use that shader within terrain material.



    VacuumShaders - Facebook Twitter YouTube
     
  34. sarathzz

    sarathzz

    Joined:
    May 2, 2018
    Posts:
    6


    This happened when i tried it with the example scene. Maybe Im just very noob with the tool so if you can explain me in detail, it would be extreamly appreciate

    cheers!
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Example scenes are using Unity scripts. Seems you already had those script in your project before importing Curved World, or scripts with similar names.
    Solution: Remove Curved World example folder completely from the project or if you are newbie try importing package into new empty project.



    VacuumShaders - Facebook Twitter YouTube
     
  36. sarathzz

    sarathzz

    Joined:
    May 2, 2018
    Posts:
    6


    Ok, this is what happend with new empty project.I also removed Curved World example folder already.

    I found that every time I import your curved world STANDARD ASSETS, it got error with namespace name `CrossPlatformInputManager'. Then what should I do?

    Thank you so much for the help!
     
  37. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    As I told you above - "Example scenes are using Unity's scripts. Seems you already had those scripts in your project before importing Curved World, or had scripts with similar names."
    Do not import those example scripts from Curved World's package or if you are newbie try importing package into new empty project and you will not have script compilation conflicts.



    VacuumShaders - Facebook Twitter YouTube
     
  38. sarathzz

    sarathzz

    Joined:
    May 2, 2018
    Posts:
    6
    Sorry but I dont understand. From above i told u that I started in NEW EMPTY PROJECT and also removed EXAMPLE SCENE in standard assets folder but still got that problem.

    I tried to removed STANDARD ASSETS and leaved only VACCUM SHADER FOLDER in my empty project and it work properly, but when I tried to import your FIRST CHARACTER FOLDER into my project it shown the same problem. This problem rised again.

    To repeat, I tried it with empty project (start from zero).

    Best,
     
  39. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    @Arkhivrag ; Sorry, since you are obviously a genius, and since I saw "gradients" on Matcap colored FLAT objects, I just assumed you where right, that the math was correct.

    Unfortunately that is not the case, and I am sorry, but I have to ask you again. I'm sure it's something simple for someone like you ;)

    It appears that when using your code, the math somehow is "inverted"; Instead of using the center of the Matcap Image, the very sides are used, and then as the sides should be used, it appears the center is used.

    To try and make my point clear, I have produced this "extreme bending" and bend it to the sides, so nothing vanishes in the horizon.

    Then I used the exact same shader, but with none of your code, on a mesh I carefully bend and matched to "hard code" what your effect does.

    And then I slided one over the other, where they should look fairly much like each other.

    But they do not! Not at all. I have also tried with color-checkers and the like, it's pretty consistent, your math is somehow "upside down" or "inverted".

    Can you try again and pass me the code so the matcap shader will show the same (approximately) on a "real bend mesh" and a mesh that is "simulated to bend" with your effect?

    This is what I have been trying to ask you all the time, not sure if you did not understand me, or the math just played you a trick ;)

    Thanks!

    Skærmbillede 2018-05-05 kl. 16.15.57.png

    This is the shader with your math that has the problem:

    Code (CSharp):
    1. Shader "MatCaps/Vertex/Plain_Curved"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
    6.         _MatCap ("MatCap (RGB)", 2D) = "white" {}
    7.     }
    8.    
    9.     Subshader
    10.     {
    11.         Tags
    12.         {
    13.         "RenderType"="Opaque"
    14.         "PreviewType" = "Skybox"
    15.         }
    16.        
    17.         Pass
    18.         {
    19.             Tags { "LightMode" = "Always" }
    20.            
    21.             CGPROGRAM
    22.                 #pragma vertex vert
    23.                 #pragma fragment frag
    24.                 #pragma multi_compile_fog
    25.                 #pragma fragmentoption ARB_precision_hint_fastest
    26.                 #include "UnityCG.cginc"
    27.                 #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    28.                
    29.                 uniform float4 _Color;
    30.                 uniform sampler2D _MatCap;
    31.  
    32.                 struct v2f
    33.                 {
    34.                     float4 pos    : SV_POSITION;
    35.                     float2 cap    : TEXCOORD0;
    36.                     UNITY_FOG_COORDS(1)
    37.                 };
    38.  
    39.        // Your math here - somehow "inverted", I am not sure how you planned it to work?!
    40.                 v2f vert (appdata_tan v)
    41.                 {
    42.                     V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    43.                    
    44.                     v2f o;
    45.                     o.pos = UnityObjectToClipPos (v.vertex);
    46.                    
    47.                     float3 normalW = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
    48.                     normalW = mul((float3x3)UNITY_MATRIX_V, normalW);
    49.                    
    50.                     o.cap.xy = normalW.xy * 0.5 + 0.5;
    51.                     UNITY_TRANSFER_FOG(o, o.pos);
    52.  
    53.                     return o;
    54.                 }
    55.                
    56.                 float4 frag (v2f i) : COLOR
    57.                 {
    58.                     float4 matCapCol = tex2D(_MatCap, i.cap);
    59.                     matCapCol = _Color * matCapCol * 2.0;
    60.                     UNITY_APPLY_FOG(i.fogCoord, matCapCol);
    61.  
    62.                     return matCapCol;
    63.                 }
    64.             ENDCG
    65.         }
    66.     }
    67.     Fallback "VertexLit"
    68. }
     
    Last edited: May 6, 2018
  40. hamd95

    hamd95

    Joined:
    Nov 30, 2016
    Posts:
    6
    thanks for your awesome shaders
    I used your curved world asset with my runner game
    I used camera follow script to make the camera follow the player
    the problem is the camera follow the game object and not the mesh
    can u lead to the solution please
    the following images show the case
    I'm sorry for my bad english
    https://ibb.co/khJBr7

     
  41. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    You need to set the "Pivot Point"
    Skærmbillede 2018-05-06 kl. 09.45.14.png
    - try setting it to your Player, or an empty child of your player, then move the child till you get the desired effect ;)
     
    hamd95 likes this.
  42. davidosullivan

    davidosullivan

    Joined:
    Jun 9, 2015
    Posts:
    385
    I just bought this and it looks very impressive :)

    I have two questions kind of assetBundle related:

    1) Can I have different scenes use different 'Bend Types'? By setting the project 'Bend Type' maybe and duplicating the shaders it generates and then changing to another 'Bend Type' and duplicating those perhaps? My app loads scenes from assetbundles which get added to all the time, and I'd like if possible to have different scenes with different bend types...

    2) I was hoping to be able to push out the scene I am working on right now without having to re-submit the app to the app stores. Trouble is you can have shaders in assetBundles but not scripts, so what I was wondering is, can I hack the generated code of the generated shader so that the 'Curved World Controller' settings are part of the shaders rather than requiring a new script to be added to my executable?

    Thanks in advance and great work!
     
  43. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    1): Yes, you can even change it at runtime for effects, we do that (earth shatter and shake efx) Look in the very short documentation ;)

    2): As far as I understand everything, the answer would be a no. I do not think you understand how the system is build up, have a closer look.

    Disclaimer: I have nothing to do with the Curved World product, I am merely waiting for reply myself, figured I might as well answer those I can as I get the inbox notifications of activity in the forum ;)
     
  44. davidosullivan

    davidosullivan

    Joined:
    Jun 9, 2015
    Posts:
    385
    Thanks man :) I had read the docs actually, but all I could see was that 'Changing project bend type is available from blah window' and 'Click ‘Update Shaders’ button after changing shader settings. Required shaders will be recompiled' so it just sounded like changing the 'Bend Type' compiles different shaders... All I can see in the API readme is about changing the size and bias, not the type.

    Regards my point 2) Cos the code for 'CurvedWorld_Controller' is in a dll, I cant actually tell what its doing to/for the generated shaders, but I'm guessing it must be doing some kind of calculation based on the pivot transform and settings in the 'Curved_World_Controller' and passing the result to some property on the shader for the V_CW_TransformPointAndNormal to use...

    I already have code in my app that could likely perform this calculation (if its not too complex) and set some shader properties on update, so I was hoping that with some small insight into the 'secret sauce' I could do away with the new 'CurvedWorld_Controller' script...
     
  45. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185
    OH! Sorry, we are NOT changing "Type", only using the API to set "strength" etc.
     
  46. davidosullivan

    davidosullivan

    Joined:
    Jun 9, 2015
    Posts:
    385
    ok adding these properties to a hacked shader seems to be getting me somewhere with my point 2)

    Code (CSharp):
    1. _V_CW_PivotPoint_Position("Pivot Position", Vector) = (0, 0, 0, 0)
    2. _V_CW_Bend("Bend", Vector) = (0, 0, 0, 0)
    3. _V_CW_Bias("Bias", Vector) = (0, 0, 0, 0)
    By adding those I can use an existing script I have in my app to modify those shader values

    This only working per instance tho rather than globally (ideally I'd like to be able to set the values in the inspector for one objects material and affect all objects that use the same shader, to replicate the functionality of the 'CurvedWorld_Controller'- hopefully I can figure that out- I dont know anything about shaders lol- but basically its looking possible....)
     
    Last edited: May 7, 2018
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    There are only two methods in Curved World that can be implemented into custom shader:
    1. V_CW_TransformPoint(...) - Transforms mesh vertex.
    2. V_CW_TransformPointAndNormal(...) - Transforms mesh vertex and normal.
    You can try both of them and decide which one is the best for you. Both of them transform vertex and normal correctly.
    Code (CSharp):
    1.  
    2. Shader "Debug Normals"
    3. {
    4.     SubShader
    5.     {
    6.         Pass
    7.         {
    8.             CGPROGRAM
    9.             #pragma vertex vert
    10.             #pragma fragment frag
    11.        
    12.             #include "UnityCG.cginc"
    13.  
    14.             #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    15.  
    16.  
    17.             struct v2f
    18.             {
    19.                 float3 normal : TEXCOORD0;
    20.                 float4 vertex : SV_POSITION;
    21.             };
    22.          
    23.             v2f vert (appdata_full v)
    24.             {
    25.                 V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    26.  
    27.  
    28.                 v2f o;
    29.                 o.vertex = UnityObjectToClipPos(v.vertex);
    30.                 o.normal = UnityObjectToWorldNormal(v.normal);
    31.  
    32.                 return o;
    33.             }
    34.        
    35.             fixed4 frag (v2f i) : SV_Target
    36.             {
    37.                 return float4(i.normal, 1);
    38.             }
    39.             ENDCG
    40.         }
    41.     }
    42. }
    43.  


    VacuumShaders - Facebook Twitter YouTube
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    Curved World is shader and can only modify mesh objects using materials to be rendered. If you need non-mesh object (e.g. point light, collider, etc) to follow curvature you need to update their position manually from the script.
    Check 3. Little Planet (Follow script) example scene.



    VacuumShaders - Facebook Twitter YouTube
     
  49. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,193
    CurvedWorld_Base.cginc file on line 24 is defined bend type used by all shaders:
    You can remove that line and define bend type per-shader or use #pragma shader_feature to have multiple bend types per shader.

    CurvedWorld_Controller script just updates 3 variables from the same .cginc file


    VacuumShaders - Facebook Twitter YouTube
     
  50. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    185