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 /
avatar image
0
Question by Willard720 · Dec 09, 2018 at 04:42 AM · lightingshadersshadowstoonshadingtoon shader

How to stop shadows on shader from depending on camera angle

EDIT:

So I found out that the error was coming from the fact that ToonShader gets it's toony effect by using an image in the cube map slot, which is where reflection data is supposed to go, reflection data being dependent on camera angle. This seems like a bad way to do it. Any other better ways?

My shader:

 Shader "Toon/Basic" 
 {
     Properties 
     {
         _Color ("Main Color", Color) = (0.5, 0.5, 0.5, 1)
         _MainTex ("Base (RGB)", 2D)  = "white" { }
         _ToonShade ("ToonShader Cubemap(RGB)", CUBE) = "" { }
     }
     SubShader 
     {
         Tags { "LightMode" = "ForwardBase" }
         Pass 
         {
             Name "BASE"
             Cull Off
         
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fog
             #include "UnityCG.cginc"

             samplerCUBE _ToonShade;
             sampler2D _MainTex;
             float4 _MainTex_ST;
             float4 _Color;

             struct appdata 
             {
                 float4 vertex   : POSITION;
                 float2 texcoord : TEXCOORD0;
                 float3 normal   : NORMAL;
                 fixed4 col      : COLOR0;
             };
             struct v2f 
             {
                 float4 pos        : SV_POSITION;
                 float2 texcoord   : TEXCOORD0;
                 float3 cubenormal : TEXCOORD1;

                 UNITY_FOG_COORDS(2)
             };
             v2f vert (appdata v)
             {
                 v2f o;

                 o.pos        = UnityObjectToClipPos(v.vertex);
                 o.texcoord   = TRANSFORM_TEX(v.texcoord, _MainTex);
                 o.cubenormal = mul (UNITY_MATRIX_MV - 0.2, float4(v.normal, 0));

                 UNITY_TRANSFER_FOG(o, o.pos);
             
                 return o;
             }
             fixed4 frag (v2f i) : SV_Target
             {
                 fixed4 col  = _Color * tex2D(_MainTex, i.texcoord);
                 fixed4 cube = texCUBE(_ToonShade, i.cubenormal);
                 fixed4 c    = fixed4(2.0f * cube.rgb * col.rgb, col.a);
                 UNITY_APPLY_FOG(i.fogCoord, c);
             
                 return c;
             }
             ENDCG            
         }
     } 

     Fallback "VertexLit"
 }

This is a modified version of the ToonBasic script. The issue I'm having is that when the camera angle changes so do all the shadows and highlights using this shader.

It's incredibly unrealistic and looks horrible especially when going over hills. I can't see anything in here that involves camera angles so I'm really stuck. I have no idea about shaders, I work in C# not whatever language this is so I have no idea how to solve this.

Any ideas?

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

1 Reply

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

Answer by Willard720 · Dec 09, 2018 at 11:04 PM

Found the answer. Because they were using a reflection for that effect, it depending on the camera angle. So I found this shader instead.


It doesn't change on the camera angle, and I can choose how many levels I want.

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

196 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

Related Questions

Remove circular shadow from object 1 Answer

Receive Shadow Mesh Renderer - Weird Effect 0 Answers

Shadows work on a scene but not on another scene. Is driving me nuts. 0 Answers

How to adjust self-shadows 1 Answer

Need Ideas for optimizing lighting for a mobile game 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