Oct
25
2012
25
2012
Radar Shader
An article by mgear
No Comments
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
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
Recent Comments
@unitycoder_com
My TweetsSubscribe 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