Search Unity

Adding Shadow to Rotoated Matrix Texture

Discussion in 'Shaders' started by seanbro, Sep 24, 2013.

  1. seanbro

    seanbro

    Joined:
    Apr 25, 2013
    Posts:
    13
    I have a simple shader to rotate the matrix on the fly, but the shadows are no longer rendered on top of it. I do not need to cast shadows with the object, only receive them. If I change the shader to Mobile/Diffuse, it seems to work fine but I lose the rotation effect. How can I render shadows on top of this rotated texture? I have tried using multiple passes but I haven't been able to make it work. I am using one directional light with hard shadows and the plane I have applied this to receives shadows. Here is the shader:

    Code (csharp):
    1. Shader "Custom/RotateTexture" {
    2.     Properties {
    3.         _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         _Color ("Main Color", Color) = (1,1,1,1) //note: required but not used
    5.     }
    6.     Pass {
    7.         Lighting On
    8.         Material {
    9.             Diffuse (1,1,1,0)
    10.             Ambient (1,1,1,0)
    11.         }
    12.         SetTexture [_MainTex] {
    13.             matrix [_Rotation]
    14.             combine texture * primary double, texture
    15.         }
    16.     }
    17.     Fallback "Mobile/Diffuse", 2
    18. }
     
    Last edited: Sep 24, 2013