• 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
1
Question by DROP_THERAPY · Jan 27, 2017 at 10:10 AM · vertex shader

How do I get vertex shading to work in unity 5.5?

I can't seem to get it to work after getting my project from a USB drive. It was made using 5.4 and I don't know why it won't work.

it says the following: 'MainLight': no matching 1 parameter function Compiling Vertex program with DIRECTIONAL Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA as well as 'MainLight': no matching 1 parameter function Compiling Vertex program with DIRECTIONAL FOG_EXP _EMISSION Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA and I don't know what it means.

here is the code:

 #ifndef UNITY_VC_INCLUDED
 #define UNITY_VC_INCLUDED
 
 struct VertexInput_VC
 {
     float4 vertex    : POSITION;
     fixed4 color    : COLOR;
     half3 normal    : NORMAL;
     float2 uv0        : TEXCOORD0;
     float2 uv1        : TEXCOORD1;
 #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
     float2 uv2        : TEXCOORD2;
 #endif
 #ifdef _TANGENT_TO_WORLD
     half4 tangent    : TANGENT;
 #endif
 };
 
 float4 TexCoords_VC(VertexInput_VC v)
 {
     float4 texcoord;
     texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
     texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
     return texcoord;
 }
 
 //Forward Pass
 struct VertexOutputForwardBase_VC
 {
     float4 pos                            : SV_POSITION;
     float4 tex                            : TEXCOORD0;
     half3 eyeVec                         : TEXCOORD1;
     half4 tangentToWorldAndParallax[3]    : TEXCOORD2;    // [3x3:tangentToWorld | 1x3:viewDirForParallax]
     half4 ambientOrLightmapUV            : TEXCOORD5;    // SH or Lightmap UV
     SHADOW_COORDS(6)
     UNITY_FOG_COORDS(7)
 
     fixed4 color                        : COLOR;
     // next ones would not fit into SM2.0 limits, but they are always for SM3.0+
     #if UNITY_SPECCUBE_BOX_PROJECTION
         float3 posWorld                    : TEXCOORD8;
     #endif
 };
 
 VertexOutputForwardBase_VC vertForwardBase_VC (VertexInput_VC v)
 {
     VertexOutputForwardBase_VC o;
     UNITY_INITIALIZE_OUTPUT(VertexOutputForwardBase_VC, o);
 
     float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
     #if UNITY_SPECCUBE_BOX_PROJECTION
         o.posWorld = posWorld.xyz;
     #endif
     o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
     o.tex = TexCoords_VC(v);
     o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
     float3 normalWorld = UnityObjectToWorldNormal(v.normal);
     #ifdef _TANGENT_TO_WORLD
         float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
 
         float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
         o.tangentToWorldAndParallax[0].xyz = tangentToWorld[0];
         o.tangentToWorldAndParallax[1].xyz = tangentToWorld[1];
         o.tangentToWorldAndParallax[2].xyz = tangentToWorld[2];
     #else
         o.tangentToWorldAndParallax[0].xyz = 0;
         o.tangentToWorldAndParallax[1].xyz = 0;
         o.tangentToWorldAndParallax[2].xyz = normalWorld;
     #endif
     //We need this for shadow receving
     TRANSFER_SHADOW(o);
 
     // Static lightmaps
     #ifndef LIGHTMAP_OFF
         o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
         o.ambientOrLightmapUV.zw = 0;
     // Sample light probe for Dynamic objects only (no static or dynamic lightmaps)
     #elif UNITY_SHOULD_SAMPLE_SH
         #if UNITY_SAMPLE_FULL_SH_PER_PIXEL
             o.ambientOrLightmapUV.rgb = 0;
         #elif (SHADER_TARGET < 30)
             o.ambientOrLightmapUV.rgb = ShadeSH9(half4(normalWorld, 1.0));
         #else
             // Optimization: L2 per-vertex, L0..L1 per-pixel
             o.ambientOrLightmapUV.rgb = ShadeSH3Order(half4(normalWorld, 1.0));
         #endif
         // Add approximated illumination from non-important point lights
         #ifdef VERTEXLIGHT_ON
             o.ambientOrLightmapUV.rgb += Shade4PointLights (
                 unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
                 unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
                 unity_4LightAtten0, posWorld, normalWorld);
         #endif
     #endif
 
     #ifdef DYNAMICLIGHTMAP_ON
         o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
     #endif
     
     #ifdef _PARALLAXMAP
         TANGENT_SPACE_ROTATION;
         half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
         o.tangentToWorldAndParallax[0].w = viewDirForParallax.x;
         o.tangentToWorldAndParallax[1].w = viewDirForParallax.y;
         o.tangentToWorldAndParallax[2].w = viewDirForParallax.z;
     #endif
 
     o.color = v.color;
 
     UNITY_TRANSFER_FOG(o,o.pos);
     return o;
 }
 
 half4 fragForwardBase_VC (VertexOutputForwardBase_VC i) : SV_Target
 {
     FRAGMENT_SETUP(s)
     UnityLight mainLight = MainLight (s.normalWorld);
     half atten = SHADOW_ATTENUATION(i);
 
     half occlusion = Occlusion(i.tex.xy);
     UnityGI gi = FragmentGI (
         s.posWorld, occlusion, i.ambientOrLightmapUV, atten, s.oneMinusRoughness, s.normalWorld, s.eyeVec, mainLight);
 
     half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect);
 
         c *= i.color;
 
     c.rgb += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, occlusion, gi);
     c.rgb += Emission(i.tex.xy);
 
     UNITY_APPLY_FOG(i.fogCoord, c.rgb);
     return OutputForward (c, s.alpha * i.color.a);
 }
 
 //Deferred Pass
 struct VertexOutputDeferred_VC
 {
     float4 pos                            : SV_POSITION;
     fixed4 color                        : COLOR;
     float4 tex                            : TEXCOORD0;
     half3 eyeVec                         : TEXCOORD1;
     half4 tangentToWorldAndParallax[3]    : TEXCOORD2;    // [3x3:tangentToWorld | 1x3:viewDirForParallax]
     half4 ambientOrLightmapUV            : TEXCOORD5;    // SH or Lightmap UVs            
     #if UNITY_SPECCUBE_BOX_PROJECTION
         float3 posWorld                        : TEXCOORD6;
     #endif
 };
 
 VertexOutputDeferred_VC vertDeferred_VC (VertexInput_VC v)
 {
     VertexOutputDeferred_VC o;
     UNITY_INITIALIZE_OUTPUT(VertexOutputDeferred_VC, o);
 
     float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
     #if UNITY_SPECCUBE_BOX_PROJECTION
         o.posWorld = posWorld;
     #endif
     o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
     o.tex = TexCoords_VC(v);
     o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
     float3 normalWorld = UnityObjectToWorldNormal(v.normal);
     #ifdef _TANGENT_TO_WORLD
         float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
 
         float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
         o.tangentToWorldAndParallax[0].xyz = tangentToWorld[0];
         o.tangentToWorldAndParallax[1].xyz = tangentToWorld[1];
         o.tangentToWorldAndParallax[2].xyz = tangentToWorld[2];
     #else
         o.tangentToWorldAndParallax[0].xyz = 0;
         o.tangentToWorldAndParallax[1].xyz = 0;
         o.tangentToWorldAndParallax[2].xyz = normalWorld;
     #endif
 
     #ifndef LIGHTMAP_OFF
         o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
         o.ambientOrLightmapUV.zw = 0;
     #elif UNITY_SHOULD_SAMPLE_SH
         #if (SHADER_TARGET < 30)
             o.ambientOrLightmapUV.rgb = ShadeSH9(half4(normalWorld, 1.0));
         #else
             // Optimization: L2 per-vertex, L0..L1 per-pixel
             o.ambientOrLightmapUV.rgb = ShadeSH3Order(half4(normalWorld, 1.0));
         #endif
     #endif
     
     #ifdef DYNAMICLIGHTMAP_ON
         o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
     #endif
     
     #ifdef _PARALLAXMAP
         TANGENT_SPACE_ROTATION;
         half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
         o.tangentToWorldAndParallax[0].w = viewDirForParallax.x;
         o.tangentToWorldAndParallax[1].w = viewDirForParallax.y;
         o.tangentToWorldAndParallax[2].w = viewDirForParallax.z;
     #endif
     o.color = v.color;
 
     return o;
 }
 
 void fragDeferred_VC (
     VertexOutputDeferred_VC i,
     out half4 outDiffuse : SV_Target0,            // RT0: diffuse color (rgb), occlusion (a)
     out half4 outSpecSmoothness : SV_Target1,    // RT1: spec color (rgb), smoothness (a)
     out half4 outNormal : SV_Target2,            // RT2: normal (rgb), --unused, very low precision-- (a) 
     out half4 outEmission : SV_Target3            // RT3: emission (rgb), --unused-- (a)
 )
 {
     #if (SHADER_TARGET < 30)
         outDiffuse = 1;
         outSpecSmoothness = 1;
         outNormal = 0;
         outEmission = 0;
         return;
     #endif
 
     FRAGMENT_SETUP(s)
 
     // no analytic lights in this pass
     UnityLight dummyLight = DummyLight (s.normalWorld);
     half atten = 1;
 
     // only GI
     half occlusion = Occlusion(i.tex.xy);
     UnityGI gi = FragmentGI (
         s.posWorld, occlusion, i.ambientOrLightmapUV, atten, s.oneMinusRoughness, s.normalWorld, s.eyeVec, dummyLight);
 
     half3 color = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect).rgb;
         color *= i.color;
     color += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, occlusion, gi);
 
     #ifdef _EMISSION
         color += Emission (i.tex.xy);
     #endif
 
     #ifndef UNITY_HDR_ON
         color.rgb = exp2(-color.rgb);
     #endif
 
     outDiffuse = half4(s.diffColor * i.color.rgb, occlusion);
     outSpecSmoothness = half4(s.specColor * i.color.rgb, s.oneMinusRoughness);
     outNormal = half4(s.normalWorld*0.5+0.5,1);
     outEmission = half4(color, 1);
 }
 
 #endif
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Mass billboarding systems BEFORE geometry shaders - GPU instancing under DirectX 9? 2 Answers

Quaternion Multiplication in a shader. 1 Answer

Rotate a vertex about "u" Axis 1 Answer

What are vertices (vertex shaders) on mobile? 1 Answer

Blinn-Phong shader (vertex lit) from scratch. 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