Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ciaravoh · May 15, 2020 at 09:04 AM · iosshader programmingdevice

Shader question for ios - not working on the device

Hello, I'm building a POC to build a terrain with a surface shader I get from a tutorial. the shader is working fine in the editor but it is not correct on the device on in the simulator. I'm lost with the configuration and I would like to understand what's wrong with this shader.

 Shader "Custom/Terrain"
 {
     Properties {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Terrain Texture Array", 2DArray) = "white" {}
         _GridTex ("Grid Texture", 2D) = "white" {}
         _Glossiness ("Smoothness", Range(0,1)) = 0.5
         _Specular ("Specular", Color) = (0.2, 0.2, 0.2)
         _BackgroundColor ("Background Color", Color) = (0,0,0)
         [Toggle(SHOW_MAP_DATA)]_ShowMapData ("Show Map Data", Float) = 0
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         
         CGPROGRAM
         #pragma surface surf StandardSpecular  vertex:vert
         #pragma target 3.5
 
         #pragma multi_compile _ GRID_ON
         #pragma multi_compile _ HEX_MAP_EDIT_MODE
 
         #pragma shader_feature SHOW_MAP_DATA
 
         #include "../HexMetrics.cginc"
         #include "../HexCellData.cginc"
 
         UNITY_DECLARE_TEX2DARRAY(_MainTex);
 
         sampler2D _GridTex;
 
         half _Glossiness;
         fixed3 _Specular;
         fixed4 _Color;
         half3 _BackgroundColor;
 
         struct Input {
             float4 color : COLOR;
             float3 worldPos;
             float3 terrain;
             float4 visibility;
 
             #if defined(SHOW_MAP_DATA)
                 float mapData;
             #endif
         };
 
         void vert (inout appdata_full v, out Input data) {
             UNITY_INITIALIZE_OUTPUT(Input, data);
 
             float4 cell0 = GetCellData(v, 0);
             float4 cell1 = GetCellData(v, 1);
             float4 cell2 = GetCellData(v, 2);
 
             data.terrain.x = cell0.w;
             data.terrain.y = cell1.w;
             data.terrain.z = cell2.w;
 
             data.visibility.x = cell0.x;
             data.visibility.y = cell1.x;
             data.visibility.z = cell2.x;
             data.visibility.xyz = lerp(0.25, 1, data.visibility.xyz);
             data.visibility.w =
                 cell0.y * v.color.x + cell1.y * v.color.y + cell2.y * v.color.z;
 
             #if defined(SHOW_MAP_DATA)
                 data.mapData = cell0.z * v.color.x + cell1.z * v.color.y +
                     cell2.z * v.color.z;
             #endif
         }
 
         float4 GetTerrainColor (Input IN, int index) {
             float3 uvw = float3(
                 IN.worldPos.xz * (2 * TILING_SCALE),
                 IN.terrain[index]
             );
             float4 c = UNITY_SAMPLE_TEX2DARRAY(_MainTex, uvw);
             return c * (IN.color[index] * IN.visibility[index]);
         }
 
         void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
             fixed4 c =
                 GetTerrainColor(IN, 0) +
                 GetTerrainColor(IN, 1) +
                 GetTerrainColor(IN, 2);
 
             fixed4 grid = 1;
             #if defined(GRID_ON)
                 float2 gridUV = IN.worldPos.xz;
                 gridUV.x *= 1 / (4 * 8.66025404);
                 gridUV.y *= 1 / (2 * 15.0);
                 grid = tex2D(_GridTex, gridUV);
             #endif
 
             float explored = IN.visibility.w;
             o.Albedo = c.rgb * grid * _Color * explored;
             #if defined(SHOW_MAP_DATA)
                 o.Albedo = IN.mapData * grid;
             #endif
             o.Specular = _Specular * explored;
             o.Smoothness = _Glossiness;
             o.Occlusion = explored;
             o.Emission = _BackgroundColor * (1 -  explored);
             o.Alpha = c.a;
         }
         ENDCG
     }
     FallBack "Diffuse"
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ciaravoh · May 15, 2020 at 01:59 PM

alt text


img-0084.jpeg (121.7 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

238 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to detect iPhone X or iPad using iOS.DeviceGeneration? 1 Answer

Custom Shader IOS Build 0 Answers

Is it possible to select any iOS Device in Editor Settings 0 Answers

CG shader functions behaving oddly on iPad Pro 0 Answers

Display reflection on iOS 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges