I’m really new to shaders, and I found some shaders that were just pure code…
//
// Shader: "FX/Force Field 3"
// Version: v1.0
// Written by: Thomas Phillips
//
// Anyone is free to use this shader for non-commercial or commercial projects.
//
// Description:
// Generic force field effect.
// Play with color, opacity, and rate for different effects.
// This shader has been adapted for use in particle systems.
//
Shader "FX/Force Field 3" {
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_Rate ("Oscillation Rate", Range (1, 300)) = 300
}
SubShader {
ZWrite Off
Tags { "Queue" = "Transparent" }
Blend One One
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#include "UnityCG.cginc"
float4 _Color;
float _Rate;
struct v2f {
V2F_POS_FOG;
float4 texcoord : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.texcoord = v.texcoord;
return o;
}
half4 frag (v2f i) : COLOR
{
float3 color;
float m;
m = _Time[0]*_Rate + ((i.texcoord[0]+i.texcoord[1])*5000000*_Color.a*_Color.a);
m = sin(m) * 0.5;
color = float3(m*_Color.r, m*_Color.g, m*_Color.b);
color *= 1 - clamp(2*distance(i.texcoord.xy, float2(0.5, 0.5)), 0, 1);
return half4( color, 1 );
}
ENDCG
}
}
Fallback "Transparent/Diffuse"
}
But I don’t know how to get it into unity. I’ve tried creating a shader and pasting the code, but I can’t put it on my sphere. Any ideas?