Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Parallax Terrain Shader Problem

Discussion in 'Shaders' started by TerraUnity, Nov 11, 2013.

  1. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Latest package: https://www.dropbox.com/s/k2rk0okhrwbboe3/ParallaxTerrain.unitypackage

    I'm trying to add parallax effect to default terrain shader "TerrBumpFirstPass" which comes with Unity 4. Here's the current code:

    Code (csharp):
    1. Shader "Custom/Simple Terrain Parallax" {
    2.     Properties {
    3.         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    4.         _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
    5.         _Parallax ("Height", Range (0.005, 0.108)) = 0.02
    6.    
    7.         // set by terrain engine
    8.         [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
    9.         [HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
    10.         [HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
    11.         [HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
    12.         [HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
    13.         [HideInInspector] _Normal3 ("Normal 3 (A)", 2D) = "bump" {}
    14.         [HideInInspector] _Normal2 ("Normal 2 (B)", 2D) = "bump" {}
    15.         [HideInInspector] _Normal1 ("Normal 1 (G)", 2D) = "bump" {}
    16.         [HideInInspector] _Normal0 ("Normal 0 (R)", 2D) = "bump" {}
    17.         // used in fallback on old cards  base map
    18.         [HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
    19.         [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
    20.     }
    21.    
    22.     SubShader {
    23.         Tags {
    24.             "SplatCount" = "4"
    25.             "Queue" = "Geometry-100"
    26.             "RenderType" = "Opaque"
    27.         }
    28.        
    29.         CGPROGRAM
    30.         #pragma surface surf BlinnPhong vertex:vert
    31.         #pragma target 3.0
    32.        
    33.         sampler2D _Control;
    34.         sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
    35.         sampler2D _Normal0,_Normal1,_Normal2,_Normal3;
    36.         half _Shininess;
    37.         float _Parallax;
    38.        
    39.         struct Input {
    40.             float2 uv_Control : TEXCOORD0;
    41.             float2 uv_Splat0 : TEXCOORD1;
    42.             float2 uv_Splat1 : TEXCOORD2;
    43.             float2 uv_Splat2 : TEXCOORD3;
    44.             float2 uv_Splat3 : TEXCOORD4;
    45.             float3 viewDir;
    46.         };
    47.        
    48.         void vert (inout appdata_full v, out Input o)
    49.         {
    50.             o.uv_Control = v.texcoord;
    51.             o.uv_Splat0 = v.texcoord1;
    52.             o.uv_Splat1 = v.texcoord1;
    53.             o.uv_Splat2 = v.texcoord1;
    54.             o.uv_Splat3 = v.texcoord1;
    55.        
    56.             v.tangent.xyz = cross(v.normal, float3(0,0,1));
    57.             v.tangent.w = -1;
    58.            
    59.             o.viewDir = WorldSpaceViewDir(v.vertex);
    60.         }
    61.        
    62.         void surf (Input IN, inout SurfaceOutput o) {
    63.             fixed4 splat_control = tex2D (_Control, IN.uv_Control);
    64.             fixed4 col;
    65.            
    66.             // Parallax
    67.             half h;
    68.             float2 offset;
    69.            
    70.             h = tex2D (_Splat0, IN.uv_Splat0).w;
    71.             offset = ParallaxOffset (h, _Parallax, IN.viewDir);
    72.             IN.uv_Splat0 += offset;
    73.            
    74.             h = tex2D (_Splat1, IN.uv_Splat1).w;
    75.             offset = ParallaxOffset (h, _Parallax, IN.viewDir);
    76.             IN.uv_Splat1 += offset;
    77.            
    78.             h = tex2D (_Splat2, IN.uv_Splat2).w;
    79.             offset = ParallaxOffset (h, _Parallax, IN.viewDir);
    80.             IN.uv_Splat2 += offset;
    81.            
    82.             h = tex2D (_Splat3, IN.uv_Splat3).w;
    83.             offset = ParallaxOffset (h, _Parallax, IN.viewDir);
    84.             IN.uv_Splat3 += offset;
    85.            
    86.             col  = splat_control.r * tex2D (_Splat0, IN.uv_Splat0);
    87.             col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1);
    88.             col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2);
    89.             col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3);
    90.             o.Albedo = col.rgb;
    91.        
    92.             fixed4 nrm;
    93.             nrm  = splat_control.r * tex2D (_Normal0, IN.uv_Splat0);
    94.             nrm += splat_control.g * tex2D (_Normal1, IN.uv_Splat1);
    95.             nrm += splat_control.b * tex2D (_Normal2, IN.uv_Splat2);
    96.             nrm += splat_control.a * tex2D (_Normal3, IN.uv_Splat3);
    97.            
    98.             fixed splatSum = dot(splat_control, fixed4(1,1,1,1));
    99.             fixed4 flatNormal = fixed4(0.5,0.5,1,0.5);
    100.             nrm = lerp(flatNormal, nrm, splatSum);
    101.             o.Normal = UnpackNormal(nrm);
    102.            
    103.             o.Gloss = col.a * splatSum;
    104.             o.Specular = _Shininess;
    105.        
    106.             o.Alpha = 0.0;
    107.         }
    108.         ENDCG
    109.     }
    110.    
    111.     Dependency "AddPassShader" = "Hidden/Nature/Terrain/Bumped Specular AddPass"
    112.     Dependency "BaseMapShader" = "Specular"
    113.    
    114.     Fallback "Nature/Terrain/Diffuse"
    115. }
    As I need to get terrain's vetex data such as camera distance in surf part, so I need to calculate needed data in vert including out parameters. But you may see that there is a problem with the View Direction "viewDir" or maybe tangents in different terrain angles when you increase "Height" value of the parallax in shader. I've also noticed that if you change the name of "viewDir" to something else in shader, the results will vary as it's a predefined variable in Unity.

    I'm really stuck at this part and I'm no expert at shaders. I'm sure solving this issue will help many others and this shader will be useful for many.

    I've attached sample Diffuse Normal textures. Displacement data is in the alpha channel of the diffuse texture. Add textures to your terrain in Unity and check the shader for yourself.

    View attachment $Pavement.zip
     
    Last edited: Jan 31, 2016
  2. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Better results in some cases, but still have problems!

    Code (csharp):
    1. Shader "Custom/Simple Terrain Parallax" {
    2.     Properties {
    3.         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    4.         _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
    5.         _Parallax ("Height", Range (0.005, 0.108)) = 0.02
    6.    
    7.         // set by terrain engine
    8.         [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
    9.         [HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
    10.         [HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
    11.         [HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
    12.         [HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
    13.         [HideInInspector] _Normal3 ("Normal 3 (A)", 2D) = "bump" {}
    14.         [HideInInspector] _Normal2 ("Normal 2 (B)", 2D) = "bump" {}
    15.         [HideInInspector] _Normal1 ("Normal 1 (G)", 2D) = "bump" {}
    16.         [HideInInspector] _Normal0 ("Normal 0 (R)", 2D) = "bump" {}
    17.         // used in fallback on old cards  base map
    18.         [HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
    19.         [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
    20.     }
    21.    
    22.     SubShader {
    23.         Tags {
    24.             "SplatCount" = "4"
    25.             "Queue" = "Geometry-100"
    26.             "RenderType" = "Opaque"
    27.         }
    28.        
    29.         CGPROGRAM
    30.         #pragma surface surf BlinnPhong vertex:vert
    31.         #pragma target 3.0
    32.        
    33.         sampler2D _Control;
    34.         sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
    35.         sampler2D _Normal0,_Normal1,_Normal2,_Normal3;
    36.         half _Shininess;
    37.         float _Parallax;
    38.        
    39.         struct Input {
    40.             float2 uv_Control : TEXCOORD0;
    41.             float2 uv_Splat0 : TEXCOORD1;
    42.             float2 uv_Splat1 : TEXCOORD2;
    43.             float2 uv_Splat2 : TEXCOORD3;
    44.             float2 uv_Splat3 : TEXCOORD4;
    45.             float3 eye;
    46.         };
    47.        
    48.         void vert (inout appdata_full v, out Input o)
    49.         {
    50.             o.uv_Control = v.texcoord;
    51.             o.uv_Splat0 = v.texcoord1;
    52.             o.uv_Splat1 = v.texcoord1;
    53.             o.uv_Splat2 = v.texcoord1;
    54.             o.uv_Splat3 = v.texcoord1;
    55.            
    56.             float4 pos = float4(v.vertex.xyz, 1.0);
    57.             float3x3 world2Tangent;
    58.            
    59.             float3x3 normalMatrix;
    60.             normalMatrix[0] = UNITY_MATRIX_MV[0];
    61.             normalMatrix[0] = UNITY_MATRIX_MV[0];
    62.             normalMatrix[1] = UNITY_MATRIX_MV[1];
    63.             normalMatrix[2] = UNITY_MATRIX_MV[2];
    64.            
    65.             float3 N = v.normal;
    66.             float3 T = float3(1,0,0) - N * dot(N, float3(1,0,0));
    67.            
    68.             v.tangent.xyz = T;
    69.        
    70.             float tangentDir = dot(cross(N, float3(-1,0,0)), float3(0,0,1));
    71.             if(tangentDir <= 0)
    72.                 v.tangent.w = -1.0;
    73.             else
    74.                 v.tangent.w = 1.0;
    75.        
    76.             float3 B = cross(T, N) * v.tangent.w;
    77.            
    78.             N = normalize(mul(normalMatrix, N));
    79.             T = normalize(mul(normalMatrix, T));
    80.             B = normalize(mul(normalMatrix, B));
    81.        
    82.             world2Tangent = float3x3(T, B, N);
    83.            
    84.             float3 vpos = mul(UNITY_MATRIX_MV, pos).xyz;
    85.             o.eye = mul(world2Tangent, vpos.xyz);
    86.         }
    87.        
    88.         void surf (Input IN, inout SurfaceOutput o) {
    89.             fixed4 splat_control = tex2D (_Control, IN.uv_Control);
    90.             fixed4 col;
    91.            
    92.             // Parallax
    93.             half h;
    94.             float2 offset;
    95.            
    96.             h = tex2D (_Splat0, IN.uv_Splat0).w;
    97.             offset = ParallaxOffset (h, _Parallax, IN.eye);
    98.             IN.uv_Splat0 += offset;
    99.            
    100.             h = tex2D (_Splat1, IN.uv_Splat1).w;
    101.             offset = ParallaxOffset (h, _Parallax, IN.eye);
    102.             IN.uv_Splat1 += offset;
    103.            
    104.             h = tex2D (_Splat2, IN.uv_Splat2).w;
    105.             offset = ParallaxOffset (h, _Parallax, IN.eye);
    106.             IN.uv_Splat2 += offset;
    107.            
    108.             h = tex2D (_Splat3, IN.uv_Splat3).w;
    109.             offset = ParallaxOffset (h, _Parallax, IN.eye);
    110.             IN.uv_Splat3 += offset;
    111.            
    112.             col  = splat_control.r * tex2D (_Splat0, IN.uv_Splat0);
    113.             col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1);
    114.             col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2);
    115.             col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3);
    116.             o.Albedo = col.rgb;
    117.        
    118.             fixed4 nrm;
    119.             nrm  = splat_control.r * tex2D (_Normal0, IN.uv_Splat0);
    120.             nrm += splat_control.g * tex2D (_Normal1, IN.uv_Splat1);
    121.             nrm += splat_control.b * tex2D (_Normal2, IN.uv_Splat2);
    122.             nrm += splat_control.a * tex2D (_Normal3, IN.uv_Splat3);
    123.            
    124.             fixed splatSum = dot(splat_control, fixed4(1,1,1,1));
    125.             fixed4 flatNormal = fixed4(0.5,0.5,1,0.5);
    126.             nrm = lerp(flatNormal, nrm, splatSum);
    127.             o.Normal = UnpackNormal(nrm);
    128.            
    129.             o.Gloss = col.a * splatSum;
    130.             o.Specular = _Shininess;
    131.        
    132.             o.Alpha = 0.0;
    133.         }
    134.         ENDCG
    135.     }
    136.    
    137.     Dependency "AddPassShader" = "Hidden/Nature/Terrain/Bumped Specular AddPass"
    138.     Dependency "BaseMapShader" = "Specular"
    139.    
    140.     Fallback "Nature/Terrain/Diffuse"
    141. }
    Any ideas?
     
  3. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    That's funny. You have to answer your own questions. It appeared to me that the parallax diffuse shader wasn't working, which I posted about a couple of days ago: http://forum.unity3d.com/threads/211211-Parallax-Diffuse-Texturing

    I'm glad I found your post. I'll take a look at it and report back any findings I may have at a later time. I'm sorry I cannot promise anything specific because this is getting queued up with my other problems. Hopefully though I'll get back to this in a few days.
     
  4. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    I totally agree, Unity's community is always active and answers your questions most of the time but whenever there comes a problem with shaders it's so quiet and unfortunately devs and experts don't give any supports usually.

    Actually the default parallax diffuse shader works as expected but there are 2 main factors about it:
    • It's hard to create a good displacement map out of a diffuse/normal without a lot of proper tweakings in the settings whether by CrazyBump or other programs.
    • Unity's built-in Parallax shader uses a cheap and simple technique to achieve the effect and thus the results are not fine and even not usable most of the times. You have to implement a better technique such as Steep Parallax mapping which is quite heavier too. Also some people believe that as gpus support DX11 nowadays, Parallax effect has been shadowed by DX11's Tessellation which is a newer technique and removes some existing artifacts as it generates real geometries, However, I've never seen such a shader in Unity until now which takes displacement data for tessellation.

    About your issue, I've heard that all 4 channels of normal maps are reserved in Unity and you can't add other data in their alpha channel. But you can put displacement data in the alpha channel of the diffuse texture. Attached files in the first post uses this method and I simply did this using Photoshop. Below is the tweaked Parallax Diffuse shader which doesn't need a Heightmap texture slot and takes the displacement data from diffuse's alpha channel. Check them with this shader:


    Code (csharp):
    1. Shader "Custom/Parallax Diffuse" {
    2.     Properties {
    3.         _Color ("Main Color", Color) = (1,1,1,1)
    4.         _Parallax ("Height", Range (0.005, 0.08)) = 0.02
    5.         _MainTex ("Base (RGB)", 2D) = "white" {}
    6.         _BumpMap ("Normalmap", 2D) = "bump" {}
    7.     }
    8.    
    9.     SubShader {
    10.         Tags { "RenderType"="Opaque" }
    11.         LOD 500
    12.    
    13.         CGPROGRAM
    14.         #pragma surface surf Lambert
    15.        
    16.         sampler2D _MainTex;
    17.         sampler2D _BumpMap;
    18.         fixed4 _Color;
    19.         float _Parallax;
    20.        
    21.         struct Input {
    22.             float2 uv_MainTex;
    23.             float2 uv_BumpMap;
    24.             float3 viewDir;
    25.         };
    26.        
    27.         void surf (Input IN, inout SurfaceOutput o) {
    28.             half h = tex2D (_MainTex, IN.uv_BumpMap).w;
    29.             float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir);
    30.             IN.uv_MainTex += offset;
    31.             IN.uv_BumpMap += offset;
    32.            
    33.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    34.             o.Albedo = c.rgb;
    35.             o.Alpha = c.a;
    36.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    37.         }
    38.         ENDCG
    39.     }
    40.     FallBack "Bumped Diffuse"
    41. }
    This works as expected using a simple technique to distort uvs of textures to achieve the illusion but I still got problems implementing viewDir in a terrain shader correctly. Break the silence guys!
     
  5. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    247
    Just add a viewDir property in your Input struct and Unity will fill it.

    Code (csharp):
    1. struct Input {
    2.     float3 viewDir:TEXCOORD0
    3. }
    ...etc, as per the builtin variables listed here if you're curious ---
    http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaders.html


    So just add that to your input struct and use it in your parallax function and happy days.

    EDIT: Exactly like the diffuse shader above :p
    EDIT: Actually, not sure if you can use the alpha channel of the terrain textures... may need to use separate displacement textures.
     
    Last edited: Nov 20, 2013
  6. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Thanks for the answer spraycanmansam, Did you ever check the shader for yourself on a terrain? It's a little more complicated than this and doesn't work with default settings.


    Yes, I'm aware of the built-in variables and if you look at the first shader I posted, you'll see that I've used viewDir in struct input and temporary filled it in the vert part to compeletly initialize SurfaceOutput o. In the link you mentioned it is stated that:
    so there might be a simple solution for the issue I'm facing.


    That shader doesn't have a vert function and as I said you have to temporary fill in all variables from struct input in the vert part. I think the correct way to fill viewDir is to write this line: o.viewDir = WorldSpaceViewDir(v.vertex); as advised in forums.


    I've already tested it on terrain and it works so i modified the shader and posted here, use the Pavement.zip attachment in the first post for sample textures.


    Look at this picture to have better understanding of the issue:

    $Parallax_viewDir.jpg

    Notice the circular line at the bottom and incorrect distortions around it which finally ruins the parallax effect.
     
  7. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    247
    Don't have to, I've already converted Unity's terrain shader to parallax.



    No you dont have to fill it manually. Remove this ---

    Code (csharp):
    1.  o.viewDir = WorldSpaceViewDir(v.vertex);
    ..and it will be populated automatically when it's compiled. I can't remember off the top of my head right now, but Unity assigns different values depending on what it needs. The issue above looks like a 'space' issue to me.. like the shader is expecting viewDir in tangent or object space.


    [EDIT]For reference, this is all I have in my vertex program of my parallax terrain shader ---

    Code (csharp):
    1.  
    2. struct Input {
    3.     float2 uv_Splat0 : TEXCOORD1;
    4.     float2 uv_Splat1 : TEXCOORD2;
    5.     float2 uv_Splat2 : TEXCOORD3;
    6.     float2 uv_Splat3 : TEXCOORD4;
    7.     float3 viewDir   : TEXCOORD5;
    8. };
    9.  
    10. void vert (inout appdata_full v)
    11. {
    12.     v.tangent.xyz = cross(v.normal, float3(0,0,1));
    13.     v.tangent.w = -1;
    14. }
    15.  

    If you really want to do it manually, I would imagine you will need to do something like this in your vertex program ---
    Code (csharp):
    1.  
    2.  
    3. ...
    4.  
    5. TANGENT_SPACE_ROTATION;
    6. o.viewDir = mul (rotation, ObjSpaceViewDir(v.vertex));
    7.  
    8. // TANGENT_SPACE_ROTATION is a Unity helper function that calculates below..
    9. // float3 binormal = cross( v.normal, v.tangent.xyz ) * v.tangent.w;
    10. // float3x3 rotation = float3x3( v.tangent.xyz, binormal, v.normal );
    11.  
    That will get your viewDir into tangent space, which I suspect it needs. But like I said above, none of that should be necessary.
     
    Last edited: Nov 21, 2013
  8. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Thanks a lot for the detailed response. To my limited knowledge about shaders, I always thought that shader warnings will ruin the rendering and causes to fail compiling. With your help I've prepared a package containing of both terrain and mesh parallax shaders and a sample scene for anyone who's also looking for it. As already said it uses Unity's default parallax method and shaders are tweaked to use displacement data from the alpha channel of the diffuse texture. You will get some warnings but it's ok.

    Simple Parallax Terrain: https://www.dropbox.com/s/k2rk0okhrwbboe3/ParallaxTerrain.unitypackage

    Actually, we could write a custom terrain shader which uses steep parallax mapping technique plus some extra features but unfortunately even using spraycanmansam's solution, there are still viewing issues. Anyway, here are some screenshots of what we have done so far:



    $24.jpg


    $2.jpg


    $23.jpg


    $48.jpg


    $UltimateTerrain.jpg



    Terrain Shader Features:
    • 8192 resolution colormap (2x2 grid of 4 Satellite Images in 4096 resolution)
    • Unlimited detail textures painting on terrain all with normalmaps and heightmaps
    • Blending between colormap layer and detail textures based on specified distance and blending amount
    • Blending between far viewing and close up normalmaps
    • Steep Parallax Mapping with amount and quality modifiers
    • POM self shadowing with amount and quality modifiers
    • Lighten/Darken Scattering for more natural visuals on detail textures
    • Global tileable Normalmap for boosting far viewing distance details
    • Terrain Specular Shininess
    • Brightness modifier for the whole terrain rendering
    • More realistic rendering of images textures colors
    • Procedural Snow layer with slope detection and starting height option
    • Snow Fader for smooth gradient transition density
    • Satellite Image Correction to add snow to detected snow parts in satellite images
    • Normals Strength modifier

    This shader will be included in our TerraLand package as soon as the version 2 comes out.
     
    Alverik likes this.
  9. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,503
    Nice looking screenshots. More terrain assets/shaders are always welcome!
     
  10. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Thanks jc :)
     
  11. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    247
    Happy to help.
    Results look good :)
     
  12. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Thank you again spray, will let you know about the updates.
     
  13. William White

    William White

    Joined:
    Nov 7, 2013
    Posts:
    4
  14. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Is it me or it's not just what it's meant to be the Parallax Effect man!
     
  15. Tomas-smith

    Tomas-smith

    Joined:
    Nov 8, 2013
    Posts:
    9
    I try to use your shader but I had this error: Shader warning in 'Custom/Simple Terrain Parallax': Program 'vert_surf', 'vert': output parameter 'o' not completely initialized (compiling for d3d11) at line 47

    Could you help?
     
  16. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
  17. Tomas-smith

    Tomas-smith

    Joined:
    Nov 8, 2013
    Posts:
    9
    Well am sorry to tell you this but it doesn't works for me :(
     
  18. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Is "Use Direct3D 11" enabled in Unity's Player Settings? if that is so the terrain shader won't get the Parallax effect. As said before these shaders are so simple using Unity's internal Parallax technique and there is no reason for them not to work.

    Simply play with "Height" slider in the 2 materials and see if there are any effects!
     
  19. ioFlow

    ioFlow

    Joined:
    May 30, 2014
    Posts:
    13
    Hey there TerraUnity,

    I downloaded your shader package, put it in a brand new project and got this:

    I'm using Unity 4.5.1 (pro), is the shader not compatible with this version?
     
  20. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    It will run ok in any Unity version,

    Just make sure that Unity is not in Direct3D 11 mode by going to Edit => Project Settings => Player and uncheck "Use Direct3D 11"
    Simply add this line at the beginning of the vert function:

    Code (CSharp):
    1. UNITY_INITIALIZE_OUTPUT(Input, o);
    and then find the shader "ParallaxTerrain" in Shaders folder in project, right click on it and select "Reimport". Now the terrain is back with this cheap parallax effect :)
     
    Last edited: Oct 27, 2014
  21. ioFlow

    ioFlow

    Joined:
    May 30, 2014
    Posts:
    13

    It's working :)
     
  22. MahaGaming

    MahaGaming

    Joined:
    Feb 25, 2014
    Posts:
    80
    not working for me latest unity free
     
  23. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
  24. MahaGaming

    MahaGaming

    Joined:
    Feb 25, 2014
    Posts:
    80
  25. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    735
    Anytime ;)
     
    MahaGaming likes this.