Last active
March 17, 2017 02:12
-
-
Save thelucre/889ee4cd257ea5f79580f27246455785 to your computer and use it in GitHub Desktop.
Color Shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/Color" { | |
Properties { | |
_Color ("Color", Color) = (1,1,1,1) | |
} | |
SubShader { | |
Pass { | |
CGPROGRAM | |
// Our two programs | |
#pragma vertex vert | |
#pragma fragment frag | |
// vertex shader | |
float4 vert (float4 vertex : POSITION) : SV_POSITION | |
{ | |
return mul(UNITY_MATRIX_MVP, vertex); | |
} | |
// color from the material | |
fixed4 _Color; | |
// pixel shader, no inputs needed | |
fixed4 frag () : SV_Target | |
{ | |
return _Color; // just return it | |
} | |
ENDCG | |
} | |
} | |
FallBack "Diffuse" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ColorShaderScript : ShaderBaseScript { | |
void Update() | |
{ | |
mat.SetColor("_Color", Color.white * new Vector4( | |
0.5f * Mathf.Sin(Time.timeSinceLevelLoad) + 0.5f, | |
0.5f * -Mathf.Sin(Time.timeSinceLevelLoad) + 0.5f, | |
0.5f * Mathf.Cos(Time.timeSinceLevelLoad) + 0.5f, | |
1) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment