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 swordGaru · May 08, 2015 at 08:12 PM · unity 5shadermobile

Help Fixing Error in this Shader?

I do not know the shader well.

And the following error.

I would like to modify.

In addition, the shader code would like this performance in the mobile?

 Shader "Custom/Custom_Shader"
 {
     Properties 
     {
 _Diffuse("_Diffuse", 2D) = "black" {}
 _Normal("_Normal", 2D) = "black" {}
 _Spec_int("_Spec_int", Float) = 0
 _Gloss_int("_Gloss_int", Float) = 0
 _Fresnel_int("_Fresnel_int", Float) = 0.5
 _Fresnel_ratio("_Fresnel_ratio", Float) = 3
 _Fresnel_Color("_Fresnel_Color", Color) = (1,1,1,1)
 _Half_Lambert("_Half_Lambert", Float) = 0.5
 _Half_Lambert2("_Half_Lambert2", Float) = 0.5
 
     }
     
     SubShader 
     {
         Tags
         {
 "Queue"="Geometry"
 "IgnoreProjector"="False"
 "RenderType"="Opaque"
 
         }
 
         
 Cull Back
 ZWrite On
 ZTest LEqual
 ColorMask RGBA
 Fog{
 }
 
 
 CGPROGRAM
 #pragma surface surf BlinnPhongEditor  vertex:vert
 
 #ifndef SHADER_API_D3D11
     #pragma target 3.0
 #else
     #pragma target 4.0
 #endif
 
 sampler2D _Diffuse;
 sampler2D _Normal;
 float _Spec_int;
 float _Gloss_int;
 float _Fresnel_int;
 float _Fresnel_ratio;
 float4 _Fresnel_Color;
 float _Half_Lambert;
 float _Half_Lambert2;
 
             struct EditorSurfaceOutput {
                 half3 Albedo;
                 half3 Normal;
                 half3 Emission;
                 half3 Gloss;
                 half Specular;
                 half Alpha;
                 half4 Custom;
             };
             
             inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
             {
 float4 Multiply0=light * _Half_Lambert2.xxxx;
 float4 Add0=Multiply0 + _Half_Lambert.xxxx;
 float4 Multiply1=Add0 * Add0;
 float4 Multiply2=float4( s.Albedo.x, s.Albedo.y, s.Albedo.z, 1.0 ) * Multiply1;
 float4 Splat0=light.w;
 float4 Multiply5=float4( s.Gloss.x, s.Gloss.y, s.Gloss.z, 1.0 ) * Splat0;
 float4 Multiply4=light * Multiply5;
 float4 Add1=Multiply2 + Multiply4;
 float4 Mask0=float4(Add1.x,Add1.y,Add1.z,0.0);
 float4 Luminance0= Luminance( Multiply5.xyz ).xxxx;
 float4 Add2=Luminance0 + float4( s.Albedo.x, s.Albedo.y, s.Albedo.z, 1.0 );
 float4 Mask1=float4(0.0,0.0,0.0,Add2.w);
 float4 Add3=Mask0 + Mask1;
 return Add3;
 
             }
 
             inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
             {
                 half3 h = normalize (lightDir + viewDir);
                 
                 half diff = max (0, dot ( lightDir, s.Normal ));
                 
                 float nh = max (0, dot (s.Normal, h));
                 float spec = pow (nh, s.Specular*128.0);
                 
                 half4 res;
                 res.rgb = _LightColor0.rgb * diff;
                 res.w = spec * Luminance (_LightColor0.rgb);
                 res *= atten * 2.0;
 
                 return LightingBlinnPhongEditor_PrePass( s, res );
             }
             
             struct Input {
                 float2 uv_Diffuse;
 float2 uv_Normal;
 float3 viewDir;
 
             };
 
             void vert (inout appdata_full v, out Input o) {                
                 float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
                 float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
                 float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
                 float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
 
 
             }
             
 
             void surf (Input IN, inout EditorSurfaceOutput o) {
                 o.Normal = float3(0.0,0.0,1.0);
                 o.Alpha = 1.0;
                 o.Albedo = 0.0;
                 o.Emission = 0.0;
                 o.Gloss = 0.0;
                 o.Specular = 0.0;
                 o.Custom = 0.0;
                 
 float4 Tex2D0=tex2D(_Diffuse,(IN.uv_Diffuse.xyxy).xy);
 float4 Tex2DNormal0=float4(UnpackNormal( tex2D(_Normal,(IN.uv_Normal.xyxy).xy)).xyz, 1.0 );
 float4 Multiply3=Tex2D0.aaaa * _Spec_int.xxxx;
 float4 Fresnel0_1_NoInput = float4(0,0,1,1);
 float4 Fresnel0=(1.0 - dot( normalize( float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ).xyz), normalize( Fresnel0_1_NoInput.xyz ) )).xxxx;
 float4 Pow0=pow(Fresnel0,_Fresnel_ratio.xxxx);
 float4 Multiply4=_Fresnel_Color * Pow0;
 float4 Multiply1=Multiply4 * _Fresnel_int.xxxx;
 float4 Multiply2=Multiply3 * Multiply1;
 float4 Master0_5_NoInput = float4(1,1,1,1);
 float4 Master0_7_NoInput = float4(0,0,0,0);
 float4 Master0_6_NoInput = float4(1,1,1,1);
 o.Albedo = Tex2D0;
 o.Normal = Tex2DNormal0;
 o.Emission = Multiply2;
 o.Specular = _Gloss_int.xxxx;
 o.Gloss = Multiply3;
 
                 o.Normal = normalize(o.Normal);
             }
         ENDCG
     }
     Fallback "Diffuse"
 }
Comment
Add comment · Show 1
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
avatar image tanoshimi · May 08, 2015 at 08:51 PM 0
Share

What error? And what mobile? That seems an awful lot of shader instructions for a mobile device, but whether it's acceptable performance or not is only for you to tell by actually testing it on a target device.

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

2 People are following this question.

avatar image avatar image

Related Questions

Mobile Shader with Albedo Color and Normal Map 0 Answers

Reflect Fresnel Mobile VR 0 Answers

Mali-G76 ShaderGraph PBR Shader,when shadervariant missing cause crash 0 Answers

U5 shader coming out solid black on newer iOS devices (iPad 2 Air / iPhone 6) 1 Answer

Do our company need a Facebook business account for integrating our unity game? 1 Answer


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