Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Messing with the Sprite Diffuse shader's normals

Discussion in 'Shaders' started by Ishkur, Jul 10, 2014.

  1. Ishkur

    Ishkur

    Joined:
    Nov 18, 2011
    Posts:
    26
    Hello all,

    Can anybody suggest a solution to my problem shown in the video below? I've never programmed a shader before, but I have a best guess and would like to ask for your advice before proceeding with what I expect to be something quite painful for a noob.



    I'm thinking I should write a shader that makes 3 passes, each time changing the calculated normal to be facing a different direction, or would that make my sprite way too bright? I seriously have no idea what I'm doing, but I'll teach myself.

    I'd really appreciate getting pointed in the right direction, though!
     
  2. Ishkur

    Ishkur

    Joined:
    Nov 18, 2011
    Posts:
    26
    Well, I ended up modifying this here line in the Sprite Diffuse shader...

    Code (CSharp):
    1. void vert (inout appdata_full v, out Input o)
    2.         {
    3.             #if defined(PIXELSNAP_ON) && !defined(SHADER_API_FLASH)
    4.             v.vertex = UnityPixelSnap (v.vertex);
    5.             #endif
    6.             v.normal = float3(0,0,-1); /// ...changing this into float3(0.5, 1, 0.5)
    7.            
    8.             UNITY_INITIALIZE_OUTPUT(Input, o);
    9.             o.color = v.color * _Color;
    10.         }
    ...and that mostly took care of the shadowy lighting issues when the billboarding sprite oriented itself edgewise to the lighting source.