Oct
25
2012
25
2012
Radar Shader
Converted this shader to Unity. (again didnt came out the same as the original..but almost)
Webplayer:
http://unitycoder.com/upload/demos/radar_shader_unity/
Shader Source:
// original shader: http://glsl.heroku.com/e#4190.1
// converted to unity - mgear - http://unitycoder.com/blog
Shader "mShaders/Radar1"
{
Properties {
tex ("Texture (RGB)", 2D) = "white" {}
resolution("resolution", Vector) = (1,1,0,0)
//mouse("mouse", Vector) = (1,1,0,0)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Lambert
#define GRID_SIZE 32
#define PI 3.1416
uniform float2 resolution;
//uniform float2 mouse;
//uniform float time;
//uniform sampler2D tex;
struct Input {
float2 uvtex;
};
float3 color(float d) {
return d * float3(0, 1, 0);
}
int mod(int a, int b) {
return a - ((a / b) * b);
}
void surf (Input IN, inout SurfaceOutput o)
{
float time = _Time.x*10;
float2 p = (-1.0 + 2.0 * ((IN.uvtex.xy) / resolution.xy));
//p -= (2.0 * mouse.xy) - vec2(1.0);
p.x *= (resolution.x / resolution.y);
float2 uv;
float a = (atan2(p.y,p.x) + time);
float r = sqrt(dot(p,p));
uv.x = 0.1/r;
uv.y = a/(PI);
float len = dot(p,p);
float3 col = color(pow(frac(uv.y / -2.0), 15.0));
if (len > 0.7) col = float3(0.8,0.8,0.8);
if (len > 0.73) col = float3(0,0,0);
bool grid_x = mod(int(IN.uvtex.x) - int(resolution.x / 2.0), GRID_SIZE) == 0;
bool grid_y = mod(int(IN.uvtex.y) - int(resolution.y / 2.0), GRID_SIZE) == 0;
if (len < 0.7)
{
if (grid_x || grid_y)
col += color(0.1);
if (grid_x && grid_y)
col += color(1.0);
}
half4 c = float4(col, 1.0);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Related Posts
Leave a comment
Recent posts
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
Support my work at Bags.fm:
Coin:
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
Subscribe to Blog via Email
Tag Cloud
2d
3D
AI
algorithm
android
asset
build
color
custom
demo
editor
effect
error
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tutorial
ui
unity
vertex
visibility
water
waves
webgl
An article by












