Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Feb 22, 2019 at 09:56 AM by lawlzilla.
avatar image
0
Question by lawlzilla · Feb 21, 2019 at 01:03 PM · shadershadersshader programming

Shader error when updating shader.

Whenever I try to update the script this(undeclared identifier 'v' at line 70 (on d3d11)) error pops up and breaks the shader turning everything pink.

The code:

     Shader "Custom/celShader"
 {
     Properties
     {
         _MainTex("Texture", 2D) = "white" {}
         _RampTex("Ramp", 2D) = "white" {}
         _Color("Color", Color) = (1, 1, 1, 1)
         _OutlineExtrusion("Outline Extrusion", float) = 0
         _OutlineColor("Outline Color", Color) = (0, 0, 0, 1)
     }
         SubShader
         {
             Pass
             {
                 Tags
                 {
                     "LightMode" = "ForwardBase"
                 }
 
 
             Stencil
             {
                 Ref 4
                 Comp always
                 Pass replace
                 ZFail keep
             }
 
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fwdbase 
             #include "AutoLight.cginc"
             #include "UnityCG.cginc"
 
             
             sampler2D _MainTex;
             sampler2D _RampTex;
             float4 _Color;
             float4 _LightColor0;
 
             struct vertexInput
             {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float3 texCoord : TEXCOORD0;
             };
 
             struct vertexOutput
             {
                 float4 pos : SV_POSITION;
                 float3 normal : NORMAL;
                 float3 texCoord : TEXCOORD0;
                 LIGHTING_COORDS(1,2) 
             };
 
             vertexOutput vert(vertexInput input)
             {
                 vertexOutput output;
 
                 
                 output.pos = UnityObjectToClipPos(input.vertex);
                 float4 normal4 = float4(input.normal, 0.0);
                 output.normal = normalize(mul(normal4, unity_WorldToObject).xyz);
 
                 output.texCoord = input.texCoord;
 
                 TRANSFER_VERTEX_TO_FRAGMENT(output); 
                 return output;
             }
 
             float4 frag(vertexOutput input) : COLOR
             {
                 
                 float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
 
                 
                 float ramp = clamp(dot(input.normal, lightDir), 0, 1.0);
                 float3 lighting = tex2D(_RampTex, float2(ramp, 0.5)).rgb;
 
                 
                 float4 albedo = tex2D(_MainTex, input.texCoord.xy);
 
                 float attenuation = LIGHT_ATTENUATION(input); 
                 float3 rgb = albedo.rgb * _LightColor0.rgb * lighting * _Color.rgb * attenuation;
                 return float4(rgb, 1.0);
             }
 
             ENDCG
         }
 
             
             Pass
             {
                 Tags
                 {
                     "LightMode" = "ShadowCaster"
                 }
 
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma multi_compile_shadowcaster
 
                 #include "UnityCG.cginc"
 
                 struct v2f {
                     V2F_SHADOW_CASTER;
                 };
 
                 v2f vert(appdata_base v)
                 {
                     v2f o;
                     TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
                     return o;
                 }
 
                 float4 frag(v2f i) : SV_Target
                 {
                     SHADOW_CASTER_FRAGMENT(i)
                 }
                 ENDCG
             }
 
             
                 Pass
                 {
                     
                     Cull OFF
                     ZWrite OFF
                     ZTest ON
                     Stencil
                     {
                         Ref 4
                         Comp notequal
                         Fail keep
                         Pass replace
                     }
 
                     CGPROGRAM
                     #pragma vertex vert
                     #pragma fragment frag
 
                 
                     uniform float4 _OutlineColor;
                     uniform float _OutlineSize;
                     uniform float _OutlineExtrusion;
                     sampler2D _MainTex;
 
                     struct vertexInput
                     {
                         float4 vertex : POSITION;
                         float3 normal : NORMAL;
                         float3 texCoord : TEXCOORD0;
                         float4 color : TEXCOORD1;
                     };
 
                     struct vertexOutput
                     {
                         float4 pos : SV_POSITION;
                         float4 color : TEXCOORD0;
                     };
 
                     vertexOutput vert(vertexInput input)
                     {
                         vertexOutput output;
 
                         float4 newPos = input.vertex;
 
                 
                         float3 normal = normalize(input.normal);
                         newPos += float4(normal, 0.0) * _OutlineExtrusion;
 
                         output.pos = UnityObjectToClipPos(newPos);
 
                         output.color = tex2Dlod(_MainTex, float4(input.texCoord.xy, 0, 0));
                         output.color *= _OutlineColor;
 
                         return output;
                     }
 
                     float4 frag(vertexOutput input) : COLOR
                     {
                         return input.color;
                     }
 
                     ENDCG
                 }
         }
 }

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

  • Sort: 

Follow this Question

Answers Answers and Comments

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

Related Questions

i wanna draw inside like outside. shader.... 1 Answer

Getting Color Generated from Shader to Script to Shader 0 Answers

How do i get a shader to affect every object with the same material? 0 Answers

Very basic shader problem 0 Answers

Render oject A when behind object B, but not if behind object B and object C 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