Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by AndreasX12 · Apr 05, 2014 at 08:21 PM · shadermobilewatergrey

Shader grey on Android?

Hi.

I found a water shader here: http://scrawkblog.com/2013/02/24/ocean-renderer-for-unity/

I tried to run it on my Android device but the ocean shader was grey

Screenshot on how it looks on my Android phone: alt text

This is the shader script. (This isn't made by me)

 Shader "Ocean/Indie/OceanShader" 
 {
     Properties 
     {
         _SunPow("SunPow", float) = 256
         _SeaColor("SeaColor", Color) = (1,1,1,1)
         _SkyBox("SkyBox", CUBE) = "" {}
     }
     SubShader 
     {
         Tags { "RenderType"="Opaque" }
         LOD 200
         
         CGPROGRAM
         #pragma surface surf Lambert vertex:vert
         #pragma target 3.0
         #pragma glsl
 
         uniform sampler2D _FresnelLookUp, _Map0, _Map1, _Map2;
         uniform float4 _GridSizes;
         uniform float3 _SunColor, _SunDir;
         uniform float _MaxLod, _LodFadeDist;
         
         float _SunPow;
         float3 _SeaColor;
         samplerCUBE _SkyBox;
 
         struct Input 
         {
             float3 worldPos;
             //float3 viewDir;
             float3 worldRefl;
             INTERNAL_DATA
         };
         
         void vert(inout appdata_full v) 
         {
             v.tangent = float4(1,0,0,1);
             
             float3 worldPos = mul(_Object2World, v.vertex).xyz;
             
             float dist = clamp(distance(_WorldSpaceCameraPos.xyz, worldPos) / _LodFadeDist, 0.0, 1.0);
             float lod = _MaxLod * dist;
             
             float ht = 0.0;
             ht += tex2Dlod(_Map0, float4(worldPos.xz/_GridSizes.x, 0, lod)).x*2.0-1.0;
             ht += tex2Dlod(_Map0, float4(worldPos.xz/_GridSizes.y, 0, lod)).y*2.0-1.0;
             //ht += tex2Dlod(_Map0, float4(worldPos.xz/_GridSizes.z, 0, lod)).z*2.0-1.0;
             //ht += tex2Dlod(_Map0, float4(worldPos.xz/_GridSizes.w, 0, lod)).w*2.0-1.0;
 
             v.vertex.y += ht;
         }
         
         float Fresnel(float3 V, float3 N)
         {
             float costhetai = abs(dot(V, N));
             return tex2D(_FresnelLookUp, float2(costhetai, 0.0)).a * 0.7; //looks better scaled down a little?
         }
         
         float3 Sun(float3 V, float3 N)
         {
             float3 H = normalize(V+_SunDir);
             return _SunColor * pow(abs(dot(H,N)), _SunPow);
         }
 
         void surf(Input IN, inout SurfaceOutput o) 
         {
             float2 uv = IN.worldPos.xz;
             
             float2 slope = float2(0,0);
             slope += tex2D(_Map1, uv/_GridSizes.x).xy*2.0-1.0;
             slope += tex2D(_Map1, uv/_GridSizes.y).zw*2.0-1.0;
             slope += tex2D(_Map2, uv/_GridSizes.z).xy*2.0-1.0;
             slope += tex2D(_Map2, uv/_GridSizes.w).zw*2.0-1.0;
             
             float3 N = normalize(float3(-slope.x, 2.0, -slope.y)); //shallow normal
             float3 N2 = normalize(float3(-slope.x, 0.5, -slope.y)); //sharp normal
             
             float3 V = normalize(_WorldSpaceCameraPos-IN.worldPos);
 
             float fresnel = Fresnel(V, N);
             
             o.Normal = N.xzy;//this is tangent space?
             float3 skyColor = texCUBE(_SkyBox, WorldReflectionVector(IN, o.Normal)*float3(-1,1,1)).rgb;//flip x?
 
             o.Albedo = lerp(_SeaColor, skyColor, fresnel) + Sun(V,N2);
             o.Alpha = 1.0;
             
         }
         ENDCG
     } 
     FallBack "Mobile/Diffuse"
 }


If anyone could make it work on Android it would be awesome!

Thanks in advance.

Andreas.

2014-04-05 20.16.01.png (183.5 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Help with making a water shader receive light 1 Answer

Creating a cup of water using Unity Pro Water 1 Answer

Having trouble to getting the height from an object being displaced by a shader 1 Answer

How to adjust the transparency of the shader? 0 Answers

How do I make a boat that doesn't let water enter?,How do I make a boat that water cant get in to 2 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