Phillipes_Fablab/Assets/Materials/Hologram.shader
2023-01-13 11:44:29 +01:00

58 lines
1.8 KiB
Plaintext

Shader "Cg shading in world space" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// uniform float4x4 unity_ObjectToWorld;
// automatic definition of a Unity-specific uniform parameter
struct vertexInput {
float4 vertex : POSITION;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 position_in_world_space : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput 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;
}
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).
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
}
}
}