Animated normal maps simulating geometry displacement

As promised – application example of Flow Editor‘s new functionality – an animation map.

I created a high-poly model of an alien eyeball in Blender and texture-painted it. Then I baked the color map and normal map onto a regular low-poly sphere.

After loading the generated color map into Flowed, I drew paths along the veins of the eyeball with color gradient going from yellow to white.

In the shader (source code below) I’m using red, green and blue components of the animation map as respectively: amplitude, frequency and phase of a sinusoidal function governing linear interpolation between normal maps and geometry normals. Since there is phase gradient in my animation map, the effect resembles actual flow of blood along the veins.

Watch in HD:

The shader itself is really simple – just extending the regular Bumped Specular shader with interpolation between normals according to the animation map. The visual impression should be even more spectacular with Parallax Specular shader or (preferably) a Relief Mapping shader. I might prepare another vid with the latter when I have time 🙂 In the meantime – enjoy!

Shader "Custom/AnimatedNormals" {
	Properties {
		_MainTex ("Texture (RGB) Gloss (A)", 2D) = "white" {}
		_BumpMap ("Bump Map", 2D) = "bump" {}
		_AnimMap ("Animation", 2D) = "red" {}
		_SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
		_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200

		CGPROGRAM
		#pragma surface surf BlinnPhong
		#pragma target 3.0

		sampler2D _MainTex;
		sampler2D _BumpMap;
		sampler2D _AnimMap;
		float _Shininess;

		struct Input {
			float2 uv_MainTex;

			INTERNAL_DATA
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 c = tex2D (_MainTex, IN.uv_MainTex);
			o.Albedo = c.rgb;
			o.Gloss = c.a;
			o.Specular = _Shininess;
			half4 anim = tex2D(_AnimMap, IN.uv_MainTex);

			half t = 0.5 + anim.r * sin(-anim.g * 5 * 3.14159 * _Time[1] + anim.b * 4 * 3.14159) / 2;

			o.Normal = normalize(lerp(float3(0, 0, 1), UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)), t));
		}
		ENDCG
	}
	FallBack "Bumped Specular"
}

2 Comments

  • nice man if you need anything ask for it i liked your video`s on youtube also try to keep up with the geometry instancing and cuda source api cuda api`s all that,
    would be nice if you
    also i get pretty good benchmarks results lately using the polymorph and gpc units on my gtx480 running dedicated hysX
    things kinda hard in beginnen but starting to understand now
    now try to archieve better results with framesequential 3D and stuff
    i hope i didn`t was`t your time m8

    • It’s always good to hear a positive comment. I will release my GraviBall game soon, then I will probably start a new, more challenging project. Unfortunately this is just my hobby activity so I have but a few hours a week to work on this 3d/gaming stuff, but anyway I will try to come up with something original.


Leave a Reply to johan Cancel reply

Your email address will not be published. Required fields are marked *