• 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
-2
Question by theshadowmage · Feb 11, 2014 at 06:40 PM ·

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much

/\/\old script cast shadows is the issue if turned off its fixed but no shadows. why is it not the receive shadow.btw the leaves are not effected by the sky box?only by mesh?alt text

alt text here is my new script I still want to know how to fix add _Shadow Strength thats why i left it on this new script .I can delete add _Shadow Strength np and it will stay the same.

 Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255)
     _Cutoff ("Alpha cutoff", Range(0.25,0.9)) = 0.5
     _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.5
     _ShadowStrength("Shadow Strength", Range(0,1)) = 1.0
     _MainTex ("Main Texture", 2D) = "white" {  }
     
     // These are here only to provide default values
     _Scale ("Scale", Vector) = (1,1,1,1)
     _SquashAmount ("Squash", Float) = 1
 }
 
 SubShader { 
         UsePass "VertexLit/SHADOWCOLLECTOR"
         UsePass "VertexLit/SHADOWCASTER"
     Tags {
         "Queue"="Transparent-99"
         "IgnoreProjector"="True"
         "RenderType" = "TreeTransparentCutout"
     }
     LOD 200
     Cull Off
         
     Pass {
         Tags { "LightMode" = "Always" }
         Name "Always"
 
     CGPROGRAM
         #include "TreeVertexLit.cginc"
 
         #pragma vertex VertexLeaf
         #pragma fragment FragmentLeaf
         #pragma exclude_renderers flash
         #pragma multi_compile_fwdbase nolightmap
         
         sampler2D _MainTex;
         float4 _MainTex_ST;
 
         fixed _Cutoff;
         sampler2D _ShadowMapTexture;
 
         struct v2f_leaf {
             float4 pos : SV_POSITION;
             fixed4 diffuse : COLOR0;
         #if defined(SHADOWS_SCREEN)
             fixed4 mainLight : COLOR1;
         #endif
             float2 uv : TEXCOORD0;
         #if defined(SHADOWS_SCREEN)
             float4 screenPos : TEXCOORD1;
         #endif
         };
 
         v2f_leaf VertexLeaf (appdata_full v)
         {
             v2f_leaf o;
             TreeVertLeaf(v);
             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
 
             fixed ao = v.color.a;
             ao += 0.1; ao = saturate(ao * ao * ao); // emphasize AO
                         
             fixed3 color = v.color.rgb * _Color.rgb * ao;
             
             float3 worldN = mul ((float3x3)_Object2World, SCALED_NORMAL);
 
             fixed4 mainLight;
             mainLight.rgb = ShadeTranslucentMainLight (v.vertex, worldN) * color;
             mainLight.a = v.color.a;
             o.diffuse.rgb = ShadeTranslucentLights (v.vertex, worldN) * color;
             o.diffuse.a = 1;
         #if defined(SHADOWS_SCREEN)
             o.mainLight = mainLight;
             o.screenPos = ComputeScreenPos (o.pos);
         #else
             o.diffuse *= 0.5;
             o.diffuse += mainLight;
         #endif            
             o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
             return o;
         }
 
         fixed4 FragmentLeaf (v2f_leaf IN) : COLOR
         {
             fixed4 albedo = tex2D(_MainTex, IN.uv);
             fixed alpha = albedo.a;
             clip (alpha - _Cutoff);
 
         #if defined(SHADOWS_SCREEN)
             half4 light = IN.mainLight;
             half atten = tex2Dproj(_ShadowMapTexture, UNITY_PROJ_COORD(IN.screenPos)).r;
             light.rgb *= lerp(2.5, 2.5*atten, _ShadowStrength);
             light.rgb += IN.diffuse.rgb;
         #else
             half4 light = IN.diffuse;
             light.rgb *= 2.0;
         #endif
 
             return fixed4 (albedo.rgb * light, 0.0);
         }
 
     ENDCG
     }
 }
 
 FallBack Off
 }


22058-testscreen-1.png (298.3 kB)
testscreen-0.png (235.1 kB)
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 Benproductions1 · Feb 12, 2014 at 10:55 AM 0
Share

So your question is: "Here is my script [go decipher the bad formatting]" What is your actual question? And please format your code.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FuzzyLogic · Feb 17, 2014 at 08:49 AM

I don't see _ShadowStrength defined within your CGPROGRAM

At line 42, add this:

 float _ShadowStrength;
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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

21 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

Related Questions

Multiple Cars not working 1 Answer

Coding Problems, Ok new to this system and coding coming from Visual Communication we did some coding but not much, 1 Answer

UnityEngine.Input.GetMouseButton(1)) issue 1 Answer

'sendMessage' is not a member of 'unityengine.transform' 1 Answer

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges