Search Unity

► Curved World ◄

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

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It's written how to fix - Please rebuild lightning for this scene.


    Add Curved World VertexLit shaders into Always Included Shaders array, in Graphics Settings window.



    VacuumShaders - Facebook Twitter YouTube
     
    virtueone likes this.
  2. virtueone

    virtueone

    Joined:
    Jun 15, 2015
    Posts:
    12
    Thank you!!!! ;)
     
  3. Lad-Ty

    Lad-Ty

    Joined:
    May 7, 2013
    Posts:
    61
    For everyone who loves prototyping their own shaders using ShaderForge, I made a simple tool, that can easily add the CurvedWorld functionality! You have to use this after every modification to your shaders, which is still no fun, but better than opening and modifying these by hand for sure.

    It's quite a naive implementation I would say, but it does the job for me, maybe it will help some of you too. Feel free to modify (and share) as you like.

    Just edit the path to a folder you will be using for ShaderForge shaders you want to easily modify at the start of the class, in my case:
    Code (CSharp):
    1. private const string shadersFolderToCurvify = "Assets\\Shaders\\ShaderForge";
    And than use "Tools/Curvify ShaderForge Shaders" and "Tools/Decurvify ShaderForge Shaders" from the Unity menu. I made keyboard shortcuts to these to Ctrl+Shift+Alt+C (%#&c - curvify) and Ctrl+Shift+Alt+D (%#&d - decurvify), if you are using these for different functionality, modify accordingly.

    Also for me it's great that using this, I can easily turn on and off the CurvedWorld functionality for everything in the scene as long as it uses my custom shaders, by toggling Curvify/Decurvify on them. So I can see the world round (to see the final result) or flat (for level building) depending on what task I am currently performing.

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor;
    3. using UnityEngine;
    4. using System.IO;
    5. using System.Collections.Generic;
    6.  
    7.  
    8. /**
    9. * (LadTy, 092016)
    10. *
    11. * Tools to easily enable CurvedWorld functionality in shaders made using ShaderForge (v1.28, in case the syntax of its output will change in time)
    12. * Also provides functionality to remove the added CurvedWorld functionality, which allows for easy toggling between Curved and NonCurved variants for easier prototyping
    13. */
    14. public class CurvifyShaderForgeShaders {
    15.  
    16.     /* change to where you save your ShaderForge shaders */
    17.     private const string shadersFolderToCurvify = "Assets\\Shaders\\ShaderForge";
    18.  
    19.     [MenuItem("Tools/Curvify ShaderForge Shaders %#&c")]
    20.     static void CurvifyFunc() {
    21.         int numShadersAltered = 0;
    22.         foreach(string shaderFilePath in Directory.GetFiles(shadersFolderToCurvify)) {
    23.             if(!shaderFilePath.ToLower().EndsWith(".shader"))
    24.                 continue;
    25.  
    26.             List<string> lines = new List<string>(File.ReadAllLines(shaderFilePath));
    27.             int numLinesPre = lines.Count;
    28.  
    29.             if(lines.FindIndex(x => x.Contains("CurvedWorld_Base.cginc")) < 0) {
    30.                 int inclUnityCGLine = lines.FindIndex(x => x.Contains("#include \"UnityCG.cginc\""));
    31.                 if(inclUnityCGLine >= 0) {
    32.                     lines.Insert(inclUnityCGLine+1, "\t\t\t#include \"Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc\"");
    33.                 }
    34.             }
    35.  
    36.             if(lines.FindIndex(x => x.Contains("V_CW_TransformPoint")) < 0) {
    37.                 // for shaders working with normals
    38.                 if(lines.FindIndex(x => x.Contains(": NORMAL;")) >= 0 || lines.FindIndex(x => x.Contains(": TANGENT;")) >= 0) {        // shader uses normals or tangents
    39.                     if(lines.FindIndex(x => x.Contains(": TANGENT;")) < 0) {        // for correct working of CurvedWorld transformation, tangent seems to be needed even when not used by the shader directly
    40.                         int normalDefLine = lines.FindIndex(x => x.Contains(": NORMAL;"));
    41.                         if(normalDefLine >= 0) {
    42.                             lines.Insert(normalDefLine+1, "\t\t\t\tfixed4 tangent : TANGENT;");
    43.                         }
    44.                     }
    45.                     if(lines.FindIndex(x => x.Contains(": NORMAL;")) < 0) {        // in case of a shader not using normals but only tangents - include normals for CurvedWorld transform
    46.                         int tangentDefLine = lines.FindIndex(x => x.Contains(": TANGENT;"));
    47.                         if(tangentDefLine >= 0) {
    48.                             lines.Insert(tangentDefLine+1, "\t\t\t\tfixed3 normal : NORMAL;");
    49.                         }
    50.                     }
    51.  
    52.                     int vertStartLine = lines.FindIndex(x => x.Contains("VertexOutput vert (VertexInput v) {"));
    53.                     lines.Insert(vertStartLine+1, "\t\t\t\tV_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);");
    54.                 } else {        // for shaders not working with normals or tangents
    55.                     int vertStartLine = lines.FindIndex(x => x.Contains("VertexOutput vert (VertexInput v) {"));
    56.                     lines.Insert(vertStartLine+1, "\t\t\t\tV_CW_TransformPoint(v.vertex);");
    57.                 }
    58.             }
    59.  
    60.             if(lines.FindIndex(x => x.Contains("CurvedWorld_Opaque")) < 0) {
    61.                 int renderTypeLine = lines.FindIndex(x => x.Contains("\"RenderType\"=\"Opaque\""));
    62.                 if(renderTypeLine >= 0) {
    63.                     lines.RemoveAt(renderTypeLine);
    64.                     lines.Insert(renderTypeLine, "\t\t\t\"RenderType\"=\"CurvedWorld_Opaque\"");
    65.                 }
    66.             }
    67.  
    68.             lines.RemoveAll(x => x.Contains("FallBack"));
    69.  
    70.             if(lines.Count != numLinesPre) {
    71.                 File.WriteAllLines(shaderFilePath, lines.ToArray());
    72.                 numShadersAltered++;
    73.             }
    74.         }
    75.  
    76.         Debug.Log("Shaders Curvified: "+numShadersAltered);
    77.  
    78.         if(numShadersAltered > 0) {        // reimport altered shaders
    79.             AssetDatabase.Refresh();
    80.         }
    81.     }
    82.  
    83.     [MenuItem("Tools/Decurvify ShaderForge Shaders %#&d")]
    84.     static void DecurvifyFunc() {
    85.         int numShadersAltered = 0;
    86.         foreach(string shaderFilePath in Directory.GetFiles(shadersFolderToCurvify)) {
    87.             if(!shaderFilePath.ToLower().EndsWith(".shader"))
    88.                 continue;
    89.  
    90.             List<string> lines = new List<string>(File.ReadAllLines(shaderFilePath));
    91.             int numLinesPre = lines.Count;
    92.  
    93.             lines.RemoveAll(x => x.Contains("CurvedWorld_Base.cginc"));
    94.             lines.RemoveAll(x => x.Contains("V_CW_TransformPoint"));        // also removes V_CW_TransformPointAndNormal
    95.             if(lines.FindIndex(x => x.Contains("\"RenderType\"=\"Opaque\"")) < 0) {
    96.                 int renderTypeLine = lines.FindIndex(x => x.Contains("\"RenderType\"=\"CurvedWorld_Opaque\""));
    97.                 if(renderTypeLine >= 0) {
    98.                     lines.RemoveAt(renderTypeLine);
    99.                     lines.Insert(renderTypeLine, "\t\t\t\"RenderType\"=\"Opaque\"");
    100.                 }
    101.             }
    102.  
    103.             if(lines.Count != numLinesPre) {
    104.                 File.WriteAllLines(shaderFilePath, lines.ToArray());
    105.                 numShadersAltered++;
    106.             }
    107.         }
    108.  
    109.         Debug.Log("Shaders Decurvified: "+numShadersAltered);
    110.  
    111.         if(numShadersAltered > 0) {        // reimport altered shaders
    112.             AssetDatabase.Refresh();
    113.         }
    114.     }
    115. }
    116.  
    Save as "CurvifyShaderForgeShaders.cs" and place in Assets/Editor folder
     
    Last edited: Sep 6, 2016
    Drago28 and Arkhivrag like this.
  4. Sam-Kim

    Sam-Kim

    Joined:
    Oct 27, 2014
    Posts:
    6
    Hello, Thanks for your great asset :)

    I just wonder what is the name of below asset.
    Can I know where should I buy these?

     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Cartoon Town and Farm by Manufactura K4.



    VacuumShaders - Facebook Twitter YouTube
     
  6. PsychoPsam

    PsychoPsam

    Joined:
    Aug 1, 2012
    Posts:
    34
    Screen Shot 2016-09-16 at 10.18.59 PM.png I am using Curve World 2 on an endless road game. I have a question that I hope you can answer please...

    1. In the pic the yellow blocks are bullets and as they are using the Curve Shader they curve with the world. They collide with the other cars as expected because the colliders are in the same world space (un-curved) however it looks wrong having bullets curve away down the road like that. So I will draw the bullets without the curve shader but how do I then convert their world position and compare it with the bent positions of the cars? I was thinking perhaps I need to know where in screen space the cars are bent to and then I can work out if they are in the same screen space as the un-bent bullets. Or is there another way?
    Hope you can help :D
     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    You do not need bullets to be in the Curved World space (do not use CurvedWorld shader).
    Update colliders position using TransformPoint function (check API.pdf file and FollowScript example scene) and just shoot bullets toward that colliders. TADAAAM.



    VacuumShaders - Facebook Twitter YouTube
     
  8. PsychoPsam

    PsychoPsam

    Joined:
    Aug 1, 2012
    Posts:
    34
    Awesome thanks :D
     
  9. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I have one problem ,

    Here is how it looks with no bend- opaque shader


    Here is how it looks in no bend with transparent,


    Here is how it looks with bend -opaque,


    Here is how it looks in bend transparant ,





    Here is world view perspective of scene in opaque,


    Here is world scene in transparant,



    Sorry about lots of images, but I do not know how else I could have explained this issue,

    What opaque and transparant I am refering is to Big plane which act as skybox....It gets override by whatever "Solid Color" camera has......In this case its black...In opaque it works properly....


    What I tried :
    Tried setting egale eye, mesh bound corrector script...Sadly neither is working....Also tried increasing camera FOV and Far clipping plane.Still issue persists.

    I am on Unity 5.4 and Curve world 2.31

    Plz help in.
     
  10. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    Hello,
    I am having trouble getting the alpha to control the reflection strength/gloss with the VacuumShader/CurvedWorld/OneDirectionalLight shader.
    I took the diffuse and made a grayscale image then used RGB-A merge in Substance Designer to place grayscale image in the alpha channel of the diffuse.
    In Unity I set the texture to use alpha as grayscale.
    it doesnt seem to be masking the reflection based on the alpha channel though.
    Any idea what I am doing wrong?
    Thanks
     
  11. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    Hello,
    Maybe try this:

    1.Place Skybox Plane in its own layer.

    2.Make a second camera in same location as other camera and set culling mask to only the Skybox Plane layer.

    3.Remove the Skybox Plane layer from the other cameras culling mask.

    4.Set the depth of the Skybox Camera higher than the other cameras depth.

    5.Set clear flags of the cameras until you get desired result.
    *Set Primary Cameras clear flags to Skybox.
    *Set Skybox Cameras clear flags to DontClear.


    This site will explain what different clear flags do and more information on multiple cameras if the result from above steps doesn't look right.
    http://blog.theknightsofunity.com/using-multiple-unity-cameras-why-this-may-be-important/

    Let me know if this helps with your issue,

    Shawn
     
    Last edited: Sep 21, 2016
    idurvesh likes this.
  12. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    You will have to send support request to vacuumshaders@gmail.com with included purchase invoice.

    Just tested, works perfect.
    Check textures alpha channel.
    Untitled.png


    VacuumShaders - Facebook Twitter YouTube
     
  13. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    Ok, I figured it out. The Alpha Offset on shader was set to 1, after returning it to 0 it is working correctly.
    Thanks
     
  14. drolak

    drolak

    Joined:
    Jan 21, 2014
    Posts:
    49
    Hi,
    I'm trying do write an unlit shader that recieves shadows, but can't get it working.
    This is my modified unlit shader with shadows. It works in the Editor but cant get shadows on the device (your lit shaders do work fine).

    Any idea what's wrong with this code?

    Code (CSharp):
    1. Shader "Curved/Unlit/With Shadows"
    2. {
    3.     Properties{
    4.         _MainTex("Base (RGB)", 2D) = "white" {}
    5.     }
    6.         SubShader{
    7.         Tags{ "Queue" = "Geometry" "RenderType" = "Opaque" }
    8.  
    9.         Pass{
    10.         Tags{ "LightMode" = "ForwardBase" }
    11.         CGPROGRAM
    12.         #pragma vertex vert
    13.         #pragma fragment frag
    14.         #pragma multi_compile_fwdbase
    15.         #pragma fragmentoption ARB_fog_exp2
    16.         #pragma fragmentoption ARB_precision_hint_fastest
    17.  
    18.         #include "UnityCG.cginc"
    19.         #include "AutoLight.cginc"
    20.         #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    21.  
    22.         struct v2f
    23.         {
    24.             float4 pos : SV_POSITION;
    25.             float2 uv : TEXCOORD0;
    26.             LIGHTING_COORDS(1, 2)
    27.         };
    28.  
    29.         float4 _MainTex_ST;
    30.  
    31.         v2f vert(appdata_tan v)
    32.         {
    33.             v2f o;
    34.             //CurvedWorld vertex transform
    35.             V_CW_TransformPoint(v.vertex);
    36.             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    37.             o.uv = TRANSFORM_TEX(v.texcoord, _MainTex).xy;
    38.             TRANSFER_VERTEX_TO_FRAGMENT(o);
    39.             return o;
    40.         }
    41.  
    42.         sampler2D _MainTex;
    43.  
    44.         fixed4 frag(v2f i) : COLOR
    45.         {
    46.             //fixed atten = LIGHT_ATTENUATION(i); // Light attenuation + shadows.
    47.             fixed atten = SHADOW_ATTENUATION(i); // Shadows ONLY.
    48.             return tex2D(_MainTex, i.uv) * atten;
    49.         }
    50.         ENDCG
    51.         }
    52.  
    53.         Pass{
    54.         Tags{ "LightMode" = "ForwardAdd" }
    55.         Blend One One
    56.         CGPROGRAM
    57.         #pragma vertex vert
    58.         #pragma fragment frag
    59.         #pragma multi_compile_fwdadd_fullshadows
    60.         #pragma fragmentoption ARB_fog_exp2
    61.         #pragma fragmentoption ARB_precision_hint_fastest
    62.  
    63.         #include "UnityCG.cginc"
    64.         #include "AutoLight.cginc"
    65.         #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    66.  
    67.         struct v2f
    68.         {
    69.             float4 pos : SV_POSITION;
    70.             float2 uv : TEXCOORD0;
    71.             LIGHTING_COORDS(1, 2)
    72.         };
    73.  
    74.         float4 _MainTex_ST;
    75.  
    76.         v2f vert(appdata_tan v)
    77.         {
    78.             v2f o;
    79.             //CurvedWorld vertex transform
    80.             V_CW_TransformPoint(v.vertex);
    81.             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    82.             o.uv = TRANSFORM_TEX(v.texcoord, _MainTex).xy;
    83.             TRANSFER_VERTEX_TO_FRAGMENT(o);
    84.             return o;
    85.         }
    86.  
    87.         sampler2D _MainTex;
    88.  
    89.         fixed4 frag(v2f i) : COLOR
    90.         {
    91.             fixed atten = SHADOW_ATTENUATION(i); // Shadows ONLY.
    92.             return tex2D(_MainTex, i.uv) * atten;
    93.         }
    94.         ENDCG
    95.     }
    96.     }
    97.     FallBack "Hidden/VacuumShaders/Curved World/VertexLit/Diffuse"
    98. }

    EDIT: for anyone interested: solved it by adding an explicit shadow caster pass (funny thing is that I had to add it to my surface shaders also - shouldn't it be working out of the box?)
     
    Last edited: Sep 26, 2016
  15. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    Is it possible to make the decal on the VacuumShaders/Curved World/One Directional Light/Opaque/Decal not be affected by the Albedo Color Property?
    If so could you please explain how as I have no experience with coding shaders.

    Thanks
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Add shaders from Curved World\Shaders\VertexLit to the Always Include Shaders array in Edit/Project Settings/Graphics



    VacuumShaders - Facebook Twitter YouTube
     
  17. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    I found a shader script that has the result I was looking for here that I have slightly altered/added upon to allow for another tint color.
    https://forum.unity3d.com/threads/customize-multiple-colors-on-material.376779/
    The problem I am having now is the shader is not allowing the curve world effect. I have tried including what the above post mentioned.
    Another thing I am having trouble with is getting the alpha of the albedo to mask where i want the reflections.

    Code (CSharp):
    1. Shader "Custom/ColorVariationVacuumShader" {
    2.     Properties {
    3.           //_Color ("Color", Color) = (1,1,1,1)
    4.         _MainTex ("Albedo (RGB) (A) Ref Mask", 2D) = "white" {}
    5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    6.         _Metallic ("Metallic", Range(0,1)) = 0.0
    7.         _TintColorA("Tint Color R", Color) = (1, 1, 1, 1)
    8.         _TintColorB("Tint Color G", Color) = (1, 1, 1, 1)
    9.         _TintColorC("Tint Color B", Color) = (1, 1, 1, 1)
    10.         _TintMask("Tint Mask", 2D) = "black"
    11.         }
    12.  
    13.         SubShader{
    14.           Tags { "RenderType"="Opaque" }
    15.           LOD 200
    16.  
    17.         CGPROGRAM
    18.         #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    19.         // Physically based Standard lighting model, and enable shadows on all light types
    20.         #pragma surface surf Standard fullforwardshadows
    21.         // Use shader model 3.0 target, to get nicer looking lighting
    22.         #pragma target 3.0
    23.         sampler2D _MainTex;
    24.         sampler2D _TintMask;
    25.         struct Input {
    26.             float2 uv_MainTex;
    27.             float2 uv_TintMask;
    28.         };
    29.         half _Glossiness;
    30.         half _Metallic;
    31.         fixed4 _Color;
    32.         fixed4 _TintColorA;
    33.         fixed4 _TintColorB;
    34.         fixed4 _TintColorC;
    35.         void surf (Input IN, inout SurfaceOutputStandard o) {
    36.             // Albedo comes from a texture tinted by color
    37.             //fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    38.             fixed4 albedo = tex2D(_MainTex, IN.uv_MainTex);
    39.             fixed4 mask = tex2D(_TintMask, IN.uv_TintMask);
    40.             fixed maskA = mask.r; // red channel is the first mask
    41.             fixed maskB = mask.g; // green channel is the second mask
    42.             fixed maskC = mask.b; // blue channel is the third mask
    43.             fixed3 tint = fixed3(1.0, 1.0, 1.0);
    44.             tint = lerp(tint, _TintColorC, maskC);
    45.             tint = lerp(tint, _TintColorB, maskB);
    46.             tint = lerp(tint, _TintColorA, maskA);
    47.             albedo.rgb *= tint;
    48.             o.Albedo = albedo.rgb;
    49.             // Metallic and smoothness come from slider variables
    50.             o.Metallic = _Metallic;
    51.             o.Smoothness = _Glossiness;
    52.             o.Alpha = albedo.a;
    53.         }
    54.  
    55.         ENDCG
    56.       }
    57.     Fallback "Hidden/VacuumShaders/Curved World/VertexLit/Diffuse"
    58. }
    59.  
    Any help would be appreciated.
    Thanks
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It is a texture mix mode same as Legacy Shaders/Decal.



    VacuumShaders - Facebook Twitter YouTube
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Support does not covers custom shaders, but here is exception:
    Code (CSharp):
    1. Shader "Custom/ColorVariationVacuumShader" {
    2.     Properties{
    3.         //_Color ("Color", Color) = (1,1,1,1)
    4.         _MainTex("Albedo (RGB) (A) Ref Mask", 2D) = "white" {}
    5.     _Glossiness("Smoothness", Range(0,1)) = 0.5
    6.         _Metallic("Metallic", Range(0,1)) = 0.0
    7.         _TintColorA("Tint Color R", Color) = (1, 1, 1, 1)
    8.         _TintColorB("Tint Color G", Color) = (1, 1, 1, 1)
    9.         _TintColorC("Tint Color B", Color) = (1, 1, 1, 1)
    10.         _TintMask("Tint Mask", 2D) = "black"
    11.     }
    12.  
    13.         SubShader{
    14.         Tags{ "RenderType" = "Opaque" }
    15.         LOD 200
    16.  
    17.         CGPROGRAM
    18. #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    19.         // Physically based Standard lighting model, and enable shadows on all light types
    20. #pragma surface surf Standard fullforwardshadows vertex:vert addshadow
    21.         // Use shader model 3.0 target, to get nicer looking lighting
    22. #pragma target 3.0
    23.  
    24.  
    25.         //CurvedWorld shader API
    26. #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    27.  
    28.  
    29.         sampler2D _MainTex;
    30.     sampler2D _TintMask;
    31.     struct Input {
    32.         float2 uv_MainTex;
    33.         float2 uv_TintMask;
    34.     };
    35.     half _Glossiness;
    36.     half _Metallic;
    37.     fixed4 _Color;
    38.     fixed4 _TintColorA;
    39.     fixed4 _TintColorB;
    40.     fixed4 _TintColorC;
    41.  
    42.     void vert(inout appdata_full v, out Input o)
    43.     {
    44.         UNITY_INITIALIZE_OUTPUT(Input, o);
    45.  
    46.         //CurvedWorld vertex transform
    47.         V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    48.     }
    49.  
    50.     void surf(Input IN, inout SurfaceOutputStandard o) {
    51.         // Albedo comes from a texture tinted by color
    52.         //fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    53.         fixed4 albedo = tex2D(_MainTex, IN.uv_MainTex);
    54.         fixed4 mask = tex2D(_TintMask, IN.uv_TintMask);
    55.         fixed maskA = mask.r; // red channel is the first mask
    56.         fixed maskB = mask.g; // green channel is the second mask
    57.         fixed maskC = mask.b; // blue channel is the third mask
    58.         fixed3 tint = fixed3(1.0, 1.0, 1.0);
    59.         tint = lerp(tint, _TintColorC, maskC);
    60.         tint = lerp(tint, _TintColorB, maskB);
    61.         tint = lerp(tint, _TintColorA, maskA);
    62.         albedo.rgb *= tint;
    63.         o.Albedo = albedo.rgb;
    64.         // Metallic and smoothness come from slider variables
    65.         o.Metallic = _Metallic;
    66.         o.Smoothness = _Glossiness;
    67.         o.Alpha = albedo.a;
    68.     }
    69.  
    70.     ENDCG
    71.     }
    72.         Fallback "Hidden/VacuumShaders/Curved World/VertexLit/Diffuse"
    73. }


    VacuumShaders - Facebook Twitter YouTube
     
  20. IDreamofIndie

    IDreamofIndie

    Joined:
    Dec 24, 2014
    Posts:
    38
    Okay, I can understand.
    Thanks for the help though it is much appreciated.
     
  21. jaraen

    jaraen

    Joined:
    Jul 28, 2016
    Posts:
    21
    Just added Curved world to a new project, and I can not change the Bend Type. I've restarted Unity several times with no success (using version 5.4.1f1 Personal). I've never had this problem before. Any suggestion?
     

    Attached Files:

  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Seams you are using version for Unity 5.3 and need version for Unity 5.4.x

    Take note that there are two versions of the CW on the Asset Store. One for Unity 5.3.6 and another for Unity 5.4
    Which version will be downloaded depends on Unity editor version itself, but some times Unity does not do it correctly.

    Solution:
    1) Remove CW asset from the project.
    2) Clean Asset Store cache:
    PC - C:\Users\[Your Profile Name]\AppData\Roaming\Unity\Asset Store
    MAC - "~/Library/Unity/Asset\ Store".
    3) Now, download package from the Asset Store.

    When doing clean download Unity will recognize correct version of the asset.



    VacuumShaders - Facebook Twitter YouTube
     
  23. jaraen

    jaraen

    Joined:
    Jul 28, 2016
    Posts:
    21
    Fixed. Thanks!
     
  24. RakshithAnand

    RakshithAnand

    Joined:
    Jun 30, 2013
    Posts:
    56
    Hi ,

    I just purchased your asset a while back. Thank you, the example shader does its job perfectly but
    I am not able to get bending working on this shader below. I have literally too little knowledge on Shaders so please help me out here.

    Also is the "Example_Surface" shader mobile friendly? I just need a directional light lit colored shader.

    Many thanks.

    Code (CSharp):
    1. Shader "Mobile/Diffuse Color"
    2. {
    3.     Properties
    4.     {
    5.         _Color("Color",COLOR)=(0.5,0.5,0.5,1.0)
    6.         _MainTex ("Base (RGB)", 2D) = "white" {}
    7.     }
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" }
    11.         LOD 150
    12.         CGPROGRAM
    13.         #pragma surface surf Lambert noforwardadd
    14.         #include "Assets/VacuumShaders/Curved World/Shaders/cginc/CurvedWorld_Base.cginc"
    15.         sampler2D _MainTex;
    16.         fixed4 _Color;
    17.         struct Input
    18.         {
    19.             float2 uv_MainTex;
    20.         };
    21.  
    22.         void vert (inout appdata_full v, out Input o)
    23.         {
    24.             UNITY_INITIALIZE_OUTPUT(Input,o);
    25.  
    26.             //CurvedWorld vertex transform
    27.             V_CW_TransformPointAndNormal(v.vertex, v.normal, v.tangent);
    28.         }
    29.  
    30.         void surf (Input IN, inout SurfaceOutput o)
    31.         {          
    32.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    33.             o.Albedo = c.rgb;
    34.             o.Alpha = c.a;
    35.         }
    36.         ENDCG
    37.     }
    38.    // Fallback "Mobile/VertexLit"
    39.    FallBack "Hidden/VacuumShaders/Curved World/VertexLit/Diffuse"
    40. }
     
  25. RakshithAnand

    RakshithAnand

    Joined:
    Jun 30, 2013
    Posts:
    56
    Never mind I solved it.. I had to include reference to Vert function in pragma. :)
    One more question though.. is the given shader for particles mobile friendly?
     
  26. _Simit_

    _Simit_

    Joined:
    Apr 28, 2015
    Posts:
    2
    Hi Davit,
    Thanks for bringing this wonderful asset to the store.

    I just purchased the ‘Curved World’ shader but struggling to get it working in my endless runner game. Have tried the below steps to use the ‘Controller’ shader:

    Added the CurvedWorld_Controller script to one of an Empty GameObject
    Also, tried adding the CurvedWorld_Controller script to my Terrain but that throws an error :
    There is more than one CurvedWorld Global Controller in the scene.

    Please tell me how exactly can I get it working (Excuse my little knowledge on Shaders), is there anything that I am missing here ?
     
  27. Arkhivrag

    Arkhivrag

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

    Use CurvedWorld shaders on meshes you want to be bent. Check example scenes.



    VacuumShaders - Facebook Twitter YouTube
     
    RakshithAnand likes this.
  28. amalvj123

    amalvj123

    Joined:
    Dec 5, 2012
    Posts:
    7
    how can i change the bend size value in run time using another script
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    CurvedWorld_Controller script. Check example scenes. Check ReadMe file.



    VacuumShaders - Facebook Twitter YouTube
     
  30. bhayward_incrowd

    bhayward_incrowd

    Joined:
    Nov 3, 2015
    Posts:
    9
    Having an issue in 5.5 beta 7 - it seems the options have disappeared (such as Rim lighting, specular, bump etc). Anyone know how to solve this? Thanks in advance!

     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Unity 5.5 will be supported after it is finally released.



    VacuumShaders - Facebook Twitter YouTube
     
  32. bhayward_incrowd

    bhayward_incrowd

    Joined:
    Nov 3, 2015
    Posts:
    9
    Thanks for your reply Arkhivrag. What I find strange is that it WAS working perfectly fine and then suddenly I clicked onto the material and the options had disappeared. I wonder whether I could have accidentally done something to make them disappear??
     
  33. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Thank you so much..That worked like a charm..
     
  34. _Simit_

    _Simit_

    Joined:
    Apr 28, 2015
    Posts:
    2
    Hi Arkhivrag,

    How can I use the shader for an endless runner game in which the Player is moving and the chunk is instantiated when the Player reaches a certain point on the chunk so that he has a consistent road.

    Currently, my Player is flying at y=10 and the chunks are generated at y=0 and I am using X axis bend Size = 1 but as the Player moves the gap between the Player and the Road Chunk keeps on increasing and after some time the Road Chunk is not even visible on the screen. Please refer to the attached screenshot.

    CurvedWorld.png

    I have applied the Curved World Shader to the Player and Chunk and attached the 'Curved World_Controller' Script to a GameObject.
    How can I achieve this bend effect when the Player is moving, Please help.
     
  35. SetsuneW

    SetsuneW

    Joined:
    Jun 28, 2015
    Posts:
    2


    Any thoughts on why this may be happening? Model was built in MagicaVoxel, imported as an Obj. The rotation and texture aren't the culprit. It doesn't happen with the normal U5 shader, only the Curved version. (And yes, the shader is on the chest, so it curves with the world.)

    It works with Unlit, but any other normal shader, even One Directional Light, has some kind of flickering or bug.
     
    Last edited: Oct 14, 2016
  36. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    Maybe a shadow issue? I notice the object's shadow is also flickering.
     
  37. SetsuneW

    SetsuneW

    Joined:
    Jun 28, 2015
    Posts:
    2
    Turning off options for both casting and receiving Shadows doesn't seem to fix it.
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Inside CurvedWorld_Controller script define pivot point - in your case Player gameobject.
    If there is not defined pivot point - (0, 0, 0) is used instead.



    VacuumShaders - Facebook Twitter YouTube
     
  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    For light calculation Curved World shader needs Normal and Tangent. Make sure your meshes have both.



    VacuumShaders - Facebook Twitter YouTube
     
  40. vjungsand

    vjungsand

    Joined:
    Sep 30, 2016
    Posts:
    1
    Does Curved World support WebGL builds?
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Yes



    VacuumShaders - Facebook Twitter YouTube
     
  42. iYorda

    iYorda

    Joined:
    Oct 26, 2016
    Posts:
    2
    Hello Arkhivrag
    I'm planning to make a FPS game in a curved world using your asset, but before buying I just want to confirm one thing:
    While your script make the flat world become curved, how would it affect crosshair and shooting accuracy? Would it curve the camera and shooting line too?
    Thank you for this awesome asset.
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It is not a script, but a shader that does vertex transformation during rendering.
    Only renderable meshes that use material (with Curved World shader) are effected.

    However package includes CPU side API that can transform vertex in the same way as shader does. It is used for updating non-mesh objects like: point lights and projector, colliders positions.

    As for shooting - you will have to update mesh collider separately using included API to catch Raycast hit.
    Accuracy - If collider catching Raycast is a simple sphere or cube updating only position is enough. Otherwise you can just modify all vertex of the collider and accuracy will be 100%, but depend on vertex count may be slow.
    Camera is not curved, only meshes appear to be curved.


    It's very difficult for me to answer whether you can use Curved World in your FPS game or not.




    VacuumShaders - Facebook Twitter YouTube
     
  44. iYorda

    iYorda

    Joined:
    Oct 26, 2016
    Posts:
    2
    Thank you for your answer, I just bought the asset and unfortunately I can't find the API that could update mesh collider to the curved world's location
    Could you give me an example or just a small tutorial?
    Thanks for the help
     
  45. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Check 3. Little Planet (Follow script) example scene, some of objects position there are updated with Follow script, using TransformPoint function. Check API.pdf file in the Doc folder too.



    VacuumShaders - Facebook Twitter YouTube
     
  46. MDarkwing

    MDarkwing

    Joined:
    Jul 30, 2013
    Posts:
    2
    Hello @Arkhivrag, first let me say CurvedWorld is a top notch SSS class asset, keep up the good work!

    Now to the problem at hand: In my previous studio we used this shader for runner games and I think it was the old version of the package, and I bought the new one for myself and I'm not sure how to achieve following things:



    1. Notice how in this example the world is bent along z-axis. I'm using ProjectBendType as Universal and have the control over z curvature but it seems to move the meshes up and down instead of bending them around z-axis?



    2. I think that the old package had ability to create fog for objects that are far and I'm not sure how to do it with new package (like the greenish spooky fog in the example above)? Is this even possible in the new version?

    Thank you in advance mate!
     
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    1. Try Classic Runner bend type.
    2. Use Unity built-in fog.



    VacuumShaders - Facebook Twitter YouTube
     
  48. Sam-Kim

    Sam-Kim

    Joined:
    Oct 27, 2014
    Posts:
    6
    Hi. I'm using outline > unlit shader in android project. but it's not working on android device.
    on Unity editor, it's okay. but try build and run, everything using outline > unlit shader are shown just pink.

    Screenshot_2016-11-03-21-50-07.png

    It's not happens when i use just unlit or one directional.
    do i miss some settings? is there any options for it?

    I also tried new project without import anything but curved world.
    open sample scene, open "Curved world setting" Click the Unlit(outline) button to import
    change material's shader to outline > unlit.

    Screenshot_2016-11-03-22-39-59.png

    when i tested outline > one directional shader, not working too.
    but legacy is working.

    I use unity version 5.4.1f personal edition on windows 10.
    I need help. TT
     
  49. Sam-Kim

    Sam-Kim

    Joined:
    Oct 27, 2014
    Posts:
    6
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Required shaders are inside Resources folder, that is considered to be added into the build automatically by Unity. Strange that it does not happen.



    VacuumShaders - Facebook Twitter YouTube
     
    Sam-Kim likes this.