Thank to Adrian Boeing I was inspired this morning to hack together a ripple shader for Unity3D. Thanks for the math Adrian. You can see the animated effect here.
Shader "DM/Ripple Shader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_Scale ("Scale", Range(0.5,500.0)) = 3.0
_Speed ("Speed", Range(-50,50.0)) = 1.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
half4 _Color;
half _Scale;
half _Speed;
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half2 uv = (IN.uv_MainTex - 0.5) * _Scale;
half r = sqrt (uv.x*uv.x + uv.y*uv.y);
half z = sin (r+_Time[1]*_Speed) / r;
o.Albedo = _Color.rgb * tex2D (_MainTex, IN.uv_MainTex+z).rgb;
o.Alpha = _Color.a;
o.Normal = (z, z, z);
}
ENDCG
}
FallBack "Diffuse"
}
1 comment:
Nice. Actually I was looking for a way to make a texture and a normal map spin around center of a plane.. or maybe even better to scroll from outer edges of the plane towards the center point (or opposite direction).
I do mean a seamless texture - and not swirling while scrolling to center.
I am making water and want to use transparent to see through the water. My texture is bit special, not regular earthling water by all means. It does not look right just scrolling from side to other, because the areas where the water is are ring shaped around a center. So it really would need to look like its arriving from out to in.
I am by no means someone to understand scripting. I know bit about textures - and am hoping to use my own textures to make an imaginative slice of some world with Unity. It all is really confusing the scripts part - lol - I could ask a hundred things at once.. How do I put reflective to transparent... and so on. But first things first.
So how do I make a texture arrive from outer edges of a plane to the center. My plane is huge so the changes to the texture near the center of the plane would happen under the ground.
I really hope someone knew an answer to this.. because I am newbie and it is very hard to even recognize if some thread has an answer already and if suggested scripts on those would do this in some way.
Post a Comment