• 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 Diamonddoggames · Dec 24, 2019 at 04:46 AM · shadows

Is there a way to change the shadows to blue?

I don't know how to change the shadows to blue. I just don't know where to lookalt text

dsalfjdaslkfjs.png (168.6 kB)
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

3 Replies

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

Answer by denish_gabani · Dec 24, 2019 at 05:41 AM

This might help you.

https://medium.com/@EightyLevel/7-tips-for-better-lighting-in-unity-686694892ece

Comment
Add comment · Show 1 · 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 Diamonddoggames · Dec 24, 2019 at 06:17 AM 0
Share

thank you I was trying to find this for hours

avatar image
0

Answer by xibanya · Dec 24, 2019 at 06:30 AM

There are three main ways to do this, and the one to use depends on your rendering path. The default is forward, so that's the one you are probably using, but you can confirm which one by going to Edit > Project Settings and looking at the Graphics section. You'll find your Rendering Path indicated where I've underlined in pink in this screenshot.

alt text

In Forward rendering, you can change the shadow color by writing a shader that uses a custom lighting function. Here's a shader I've written with toon lighting: https://github.com/Xibanya/ShaderTutorials/blob/master/Assets/Shaders/Toon/SimpleToonThreshold.shader

There are two parts that make up the shadow being used in the lighting function

         inline half4 LightingToon(SurfaceOutput s, half3 lightDir, half atten)
         {
         #ifndef USING_DIRECTIONAL_LIGHT
             lightDir = normalize(lightDir);
         #endif
             half shadowDot = pow(dot(s.Normal, lightDir) * 0.5 + 0.5, _Threshold);
             float threshold = smoothstep(0.5, _ShadowSoftness, shadowDot);
             half3 diffuseTerm = saturate(threshold * atten);
             half3 diffuse = lerp(_ShadowColor, _LightColor0.rgb, diffuseTerm);
             return half4(s.Albedo * diffuse, 1);
         }

Those are atten and the value being written to threshold. Atten fed into this lighting function from Unity sampling the shadow map behind the scenes, so will have the info you need to have cast shadows from other objects onto this one. The threshold value calculated is the "self shadow," or the shadow that should be on the sides of this object that are facing away from the light. Multiply them together and we have the value of light and shadow - it'll be highest for the light areas, and lowest for the dark areas. If we multiplied that by albedo directly, we'd get toon shading, but the darkest colors could be black. So instead we will use it as the third argument in a lerp between our shadow color and the light color, that way we can guarantee that _ShadowColor will be the darkest color multiplied by our albedo color.

alt text

If your rendering path is deferred, you have two main options. One is to create your own replacement for the internal deferred shader, and replace the existing CalculateLight function with one that does something like this

 half4 CalculateLight (unity_v2f_deferred i)
 {
     float3 wpos;
     float2 uv;
     float atten, fadeDist;
     UnityLight light;
     UNITY_INITIALIZE_OUTPUT(UnityLight, light);
     UnityDeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist);
  
     light.color = _LightColor.rgb;  //<-- note how unlike the official shader,
                                     // we're not multiplying by atten yet!
  
     // unpack Gbuffer
     half4 gbuffer0 = tex2D (_CameraGBufferTexture0, uv);
     half4 gbuffer1 = tex2D (_CameraGBufferTexture1, uv);
     half4 gbuffer2 = tex2D (_CameraGBufferTexture2, uv);
     UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
  
     half shadowDot = pow(dot(data.normalWorld, light.dir) * 0.5 + 0.5, _Threshold);
     float threshold = smoothstep(0.5, _ShadowSoftness, shadowDot);
     half3 diffuseTerm = threshold * atten;
     half3 diffuse = lerp(_ShadowColor, light.color, diffuseTerm);
     return half4(gbuffer0.rgb * diffuse, 1);
 }

since you can't modify the internal-deferred shader on a per-object basis, you'd need to set the shadow color as a global shader variable.

If you go this route, you once again go to Edit > Project Settings > Graphics and scroll down to the Built-in Shader Settings section and change the deferred drop down to Custom Shader, then drag your own shader in from your assets.

The third method of coloring shadows also uses the deferred rendering path, and it involves putting a command buffer on the main directional light to write screen space shadows to a global shader texture, then using that in a post processing effect. You unpack the gbuffers in the post processing effect and use the gbuffer albedo and normal data along with the screen space shadows texture to tint the shadows only. But going into that is probably out of the scope of this question!


graphics-settings.jpg (175.2 kB)
screenhunter-4659.png (522.0 kB)
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 Lhiowynh · Jan 02, 2020 at 03:20 AM

If you're using one of the pre-built scriptable rendering pipelines, you might try adding a "BakingSky" component to your volume. I'm assuming that by blue, you mean for it to reflect the lighting provided by the skybox. This is ambient indirect light. You can also bake the lighting in your scene to achieve more detailed lighting.

If you aren't going for photorealism, you might use a shader that renders parts of the surface facing away from the lights as a controllable color.

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

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

121 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

Related Questions

Android game, no shadows... 2 Answers

Camera custom matrix, shadows not working anymore - Unity5 1 Answer

Strange "shadows" with Unity 5 1 Answer

Shadows do not work on iOS device - metal api 0 Answers

Realtime light doesn't work in Game window when shadows enabled, works fine in Scene view 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