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 MicroGSD · Jun 04, 2014 at 09:01 PM · c#shaderdirectxdx11

Unity 4.5 broke shader in DX11 mode

Unity 4.5 broke the below shader while in DX11 mode, causing the following errors:

  • 'vert': function return value missing semantics at line 112

  • 'frag': input parameter 'i' missing semantics at line 122

How can I go about fixing the shader?

 Shader "TestShaders/TransparentWithShadow" { 
 
 Properties 
 { 
      // Usual stuffs
     _Color ("Main Color", Color) = (1,1,1,1)
     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
     _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
     _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
  
     // Bump stuffs
     //_Parallax ("Height", Range (0.005, 0.08)) = 0.02
     //_BumpMap ("Normalmap", 2D) = "bump" {}
     //_ParallaxMap ("Heightmap (A)", 2D) = "black" {}
     
     // Shadow Stuff
     _ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6
 } 
 
 
 SubShader 
 { 
     Tags {
     "Queue"="AlphaTest" 
     "IgnoreProjector"="True" 
     "RenderType"="Transparent"
     }
 
     LOD 300
     Offset -3,-2
 
 
 // Main Surface Pass (Handles Spot/Point lights)
 CGPROGRAM
         #pragma surface surf BlinnPhong alpha vertex:vert fullforwardshadows approxview
         #pragma exclude_renderers d3d11 xbox360
 
         half _Shininess;
 
         sampler2D _MainTex;
         float4 _Color;
         //sampler2D _BumpMap;
         //sampler2D _ParallaxMap;
         //float _Parallax;
         
         struct v2f { 
             V2F_SHADOW_CASTER; 
             float2 uv : TEXCOORD1;
         };
 
         struct Input {
             float2 uv_MainTex;
             //float2 uv_BumpMap;
             //float3 viewDir;
         };
 
         v2f vert (inout appdata_full v) { 
             v2f o; 
             return o; 
         } 
 
         void surf (Input IN, inout SurfaceOutput o) {
             // Comment the next 4 following lines to get a standard bumped rendering
             // [Without Parallax usage, which can cause strange result on the back side of the plane]
 //            /*half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w;
 //            float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir);
 //            IN.uv_MainTex += offset;
 //            IN.uv_BumpMap += offset;*/
  
             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
             o.Albedo = tex.rgb * _Color.rgb;
             o.Gloss = tex.a;
             o.Alpha = tex.a * _Color.a;
 //            clip(o.Alpha - _Cutoff);
             o.Specular = _Shininess;
             //o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
         }
 ENDCG
 
 
 
         // Shadow Pass : Adding the shadows (from Directional Light)
         // by blending the light attenuation
         Pass {
             Blend SrcAlpha OneMinusSrcAlpha 
             Name "ShadowPass"
             Tags {"LightMode" = "ForwardBase"}
 //            ZWrite On ZTest LEqual Cull Off
               
             CGPROGRAM 
             #pragma exclude_renderers d3d11 xbox360
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fwdbase
             #pragma fragmentoption ARB_fog_exp2
             #pragma fragmentoption ARB_precision_hint_fastest
             #include "UnityCG.cginc" 
             #include "AutoLight.cginc" 
  
             struct v2f { 
                 float2 uv_MainTex : TEXCOORD1;
                 float4 pos : SV_POSITION;
                 LIGHTING_COORDS(3,4)
                 float3 lightDir;
             };
  
             float4 _MainTex_ST;
             sampler2D _MainTex;
             float4 _Color;
             float _ShadowIntensity;
  
             v2f vert (appdata_full v)
             {
                 v2f o;
                 o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
                 o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                 o.lightDir = ObjSpaceLightDir( v.vertex );
                 TRANSFER_VERTEX_TO_FRAGMENT(o);
                 return o;
             }
 
             float4 frag (v2f i) : COLOR
             {
                 float atten = LIGHT_ATTENUATION(i);
                 half4 c;
                 c.rgb =  0;
                 c.a = (1-atten) * _ShadowIntensity * (tex2D(_MainTex, i.uv_MainTex).a); 
                 return c;
             }
             ENDCG
         }
     
     
 }
 
 FallBack "Transparent/Specular"
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Scripter05 · Jul 19, 2014 at 07:14 PM

Add : TEXCOORD2 to v2f structure(lightDir)

 struct v2f { 
                 float2 uv_MainTex : TEXCOORD1;
                 float4 pos : SV_POSITION;
                 LIGHTING_COORDS(3,4)
                 float3 lightDir : TEXCOORD2;

Also remove or comment out this lines: #pragma exclude_renderers d3d11 xbox360 This will fix problems with dx11 renderer.

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
avatar image
0

Answer by Aldrick · Sep 30, 2015 at 03:54 AM

it seems unity 5.0+ with dx11 compulsorily requests every struct member returned by vertex function must have a semantic.So you can just assign an unused semantic to it.

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

23 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

Related Questions

Multiple Cars not working 1 Answer

DirectX11 & Unity problem 1 Answer

How to apply a shader to all materials inside a gameobject 1 Answer

Particle System not rendering at times 0 Answers

A node in a childnode? 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