Shader "RGB Keys" {
   SubShader {
      Pass {
         CGPROGRAM

         #pragma vertex vert  
         #pragma fragment frag 
 
         #include "UnityCG.cginc"

         // uniform float4x4 unity_ObjectToWorld; 
            // automatic definition of a Unity-specific uniform parameter

         struct vertexInput {
            float4 vertex : POSITION;
            UNITY_VERTEX_INPUT_INSTANCE_ID
         };
         struct vertexOutput {
            float4 pos : SV_POSITION;
            float4 position_in_world_space : TEXCOORD0;
            UNITY_VERTEX_OUTPUT_STEREO
         };

         vertexOutput vert(vertexInput input) 
         {
            vertexOutput output; 
            UNITY_SETUP_INSTANCE_ID(input);
            UNITY_INITIALIZE_OUTPUT(vertexOutput, output);
            UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
            output.pos =  UnityObjectToClipPos(input.vertex);
            output.position_in_world_space = 
               mul(unity_ObjectToWorld, input.vertex);
               // transformation of input.vertex from object 
               // coordinates to world coordinates;
            return output;
         }
         UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
         float3 ApplyHue(float t)
         {
             float3 result;

             result.r = sin(t * 6.283185307179586476925286766559 + 0.0) * 0.5 + 0.5;
             result.g = sin(t * 6.283185307179586476925286766559 + 2.0943951023931954923084289221863) * 0.5 + 0.5;
             result.b = sin(t * 6.283185307179586476925286766559 + 4.1887902047863909846168578443727) * 0.5 + 0.5;

             return result;
         }

         float4 frag(vertexOutput input) : COLOR 
         {
               // computes the distance between the fragment position 
               // and the origin (the 4th coordinate should always be 
               // 1 for points).
             UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
             // fixed4 col = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, input.position_in_world_space);
             //col = (ApplyHue(_Time.x*4.), 1.0);
             return float4(ApplyHue(_Time.x*4.), 1.0);
            //return float4(fmod(input.position_in_world_space.x,1), input.position_in_world_space.y % 1, input.position_in_world_space.z % 1, 1.0);
         }

         
 
         ENDCG  
      }
   }
}