Hello, i started working with shaders last week and managed to do something like this
And now im trying to add more radius within the same shader, is that possible? and how?
Heres the code for my shader.
**Shader “FenrirTests/SaWarudo5” {
Properties {
_Color (“Color”, Color) = (1,1,1,1)
_MainTex (“Albedo (RGB)”, 2D) = “white” {}
_Center(“Center”, Vector) = (0,0,0,0)
_Radius(“Radius”, Float) = 0.5
_RadiusColor(“RadiusColor”, Color) = (1,0,0,1)
_RadiusWidth(“Radius Width”, Float) = 2
_ScrollXSpeed(“X Scroll Speed”, Range(0,10)) = 2
_ScrollYSpeed(“Y Scroll Speed”, Range(0,10)) = 2
}
SubShader {
Tags { “RenderType”=“Opaque” }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float3 worldPos;
};
fixed _ScrollXSpeed;
fixed _ScrollYSpeed;
float3 _Center;
float _Radius;
fixed4 _RadiusColor;
float _RadiusWidth;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
fixed2 scrolledUV = IN.uv_MainTex;
// Albedo comes from a texture tinted by color
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
float d = distance(_Center, IN.worldPos);
fixed xScrollValue = _ScrollXSpeed * _Time;
fixed yScrollValue = _ScrollYSpeed * _Time;
scrolledUV += fixed2(xScrollValue, yScrollValue);
c = tex2D(_MainTex, scrolledUV) * _Color;
if (d > _Radius)
{
float maxColor;
if(c.r > c.g && c.r > c.b)
{
maxColor = c.r;
}
else if(c.g > c.r && c.g > c.b)
{
maxColor = c.g;
}
else if(c.b > c.r && c.b > c.g)
{
maxColor = c.b;
}
o.Albedo = float3(maxColor, maxColor, maxColor);
}
else
{
o.Albedo = c.rgb;
}
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
**