Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Waz · Jul 28, 2011 at 12:27 AM · shader3.4fallback

Shader Fallback changed in 3.4?

In 3.3, this shader would fallback to Diffuse when the camera was VertexLit, but now with 3.4 it doesn't (and gives a black result). What exactly determines when the Fallback is taken?

(sorry about the formatting, it is Strumpy Shader Editor generated)

 Shader "DiffuseRimEmission"
 {
     Properties 
     {
 _MainTex("Main Texure", 2D) = "white" {}
 _RimColor("Rim Color", Color) = (0,0,0,1)
 _RimPower("Rim Power", Range(0.1,3) ) = 1.8
 _SpecPower("Spec Power", Range(0.1,1) ) = 0.9
 
     }
     
     SubShader 
     {
         Tags
         {
 "Queue"="Geometry"
 "IgnoreProjector"="False"
 "RenderType"="Opaque"
 
         }
 
         
 Cull Back
 ZWrite On
 ZTest LEqual
 ColorMask RGBA
 Fog{
 }
 
 
         CGPROGRAM
 #pragma surface surf BlinnPhongEditor  vertex:vert
 #pragma target 2.0
 
 
 sampler2D _MainTex;
 float4 _RimColor;
 float _RimPower;
 float _SpecPower;
 
             struct EditorSurfaceOutput {
                 half3 Albedo;
                 half3 Normal;
                 half3 Emission;
                 half3 Gloss;
                 half Specular;
                 half Alpha;
             };
             
             inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
             {
 float4 Multiply1=float4(s.Albedo, 1.0) * light;
 float4 Splat0=light.w;
 float4 Multiply0=float4(s.Gloss, 1.0) * Splat0;
 float4 Multiply2=light * Multiply0;
 float4 Add2=Multiply1 + Multiply2;
 float4 Mask1=float4(Add2.x,Add2.y,Add2.z,0.0);
 float4 Luminance1= float4( Luminance( Multiply0.xyz ) );
 float4 Add0=Luminance1 + float4(s.Albedo, 1.0);
 float4 Mask0=float4(0.0,0.0,0.0,Add0.w);
 float4 Add1=Mask1 + Mask0;
 return Add1;
 
             }
 
             inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
             {
                 half3 h = normalize (lightDir + viewDir);
                 
                 half diff = max (0, dot (s.Normal, lightDir));
                 
                 float nh = max (0, dot (s.Normal, h));
                 float spec = pow (nh, s.Specular*128.0);
                 
                 half4 res;
                 res.rgb = _LightColor0.rgb * diff * atten * 2.0;
                 res.w = spec * Luminance (_LightColor0.rgb);
 
                 return LightingBlinnPhongEditor_PrePass( s, res );
             }
             
             struct Input {
                 float2 uv_MainTex;
 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;
                 
 float4 Sampled2D0=tex2D(_MainTex,IN.uv_MainTex.xy);
 float4 Fresnel0_1_NoInput = float4(0,0,1,1);
 float4 Fresnel0=float4( 1.0 - dot( normalize( float4(IN.viewDir, 1.0).xyz), normalize( Fresnel0_1_NoInput.xyz ) ) );
 float4 Pow0=pow(Fresnel0,_RimPower.xxxx);
 float4 Multiply0=_RimColor * Pow0;
 float4 Master0_1_NoInput = float4(0,0,1,1);
 float4 Master0_5_NoInput = float4(1,1,1,1);
 float4 Master0_6_NoInput = float4(1,1,1,1);
 o.Albedo = Sampled2D0;
 o.Emission = Multiply0;
 o.Specular = _SpecPower.xxxx;
 o.Gloss = float4( Sampled2D0.a);
 
                 o.Normal = normalize(o.Normal);
             }
         ENDCG
     }
     Fallback "Diffuse"
 }
Comment
Add comment · Show 3
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 Peter G · Jul 28, 2011 at 01:58 AM 0
Share

I'm curious, is the a Strumpy Shader Editor shader

avatar image Waz · Jul 28, 2011 at 02:57 AM 0
Share

Not sure what you've mistyped there. It is generated by a past version of the Strumpy Shader Editor.

avatar image Peter G · Jul 28, 2011 at 03:00 AM 0
Share

Ok thanks. That is what I was trying to ask, I need to proofread a little before I post :)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Waz · Nov 03, 2011 at 05:21 AM

The answer appears to be that previously, Unity did not care if the Properties of the Fallback shader were a subset of the main shader. Now it does. So, in the above case, adding:

 _Color ("Main Color", Color) = (1,1,1,1)

Fixes the problem (even though the main shader does not use _Color). This of course makes perfect sense, as it ensures properties are passed to the fallback shader.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem with custom shader on ios 0 Answers

Android shader (transparency) problem with 3.4 1 Answer

Does setting several Fallbacks in shaders have any effect? 1 Answer

Vertex displacement shader not working 2 Answers

Fallback shaders not working in Asset Bundle? 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