## 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" }

## Project Euler #311

Yay! It’s finally getting hard again! The thrill of many hours of computing and being uncertain whether the result will be correct to the last digit… I love it ;D Now I have to figure out the _correct_ (i.e. non semi-brute-force with smart-ass pruning and nifty little optimizations) method of solving this before I start reading others posts. Some of those guys solved it in mere hours… with code running in minutes or less. I wonder what it could be ;D

ABCD is a convex, integer sided quadrilateral with 1 <= AB < BC < CD < AD.

BD has integer length. O is the midpoint of BD. AO has integer length.

We’ll call ABCD a biclinic integral quadrilateral if AO = CO BO = DO.For example, the following quadrilateral is a biclinic integral quadrilateral:

AB = 19, BC = 29, CD = 37, AD = 43, BD = 48 and AO = CO = 23.Let B(N) be the number of distinct biclinic integral quadrilaterals ABCD that satisfy AB

^{2}+BC^{2}+CD^{2}+AD^{2}<= N.

We can verify that B(10 000) = 49 and B(1 000 000) = 38239.Find B(10 000 000 000).

As a side note – PE #310 was really easy after reading some of the “Winning Ways For Your Mathematical Plays”. I promised to write a review of the book but I’ve been pretty busy lately so it will have to wait. For sure it is a worthwhile publication though, that much I can tell already.

## Project Euler #309

Oh… GOD! This time I was SO close, soooo close :/ Precision issues played tricks on me again. Long double just doesn’t seem to be good enough with PE problems most of the time. Anyway, crossed ladders problem is a classic (a very fascinating classic nonetheless) and you will figure it out in no time, just implement it correctly ðŸ˜‰

In the classic “Crossing Ladders” problem, we are given the lengths x and y of two ladders resting on the opposite walls of a narrow, level street. We are also given the height h above the street where the two ladders cross and we are asked to find the width of the street (w).

Here, we are only concerned with instances where all four variables are positive integers.

For example, if x = 70, y = 119 and h = 30, we can calculate that w = 56.In fact, for integer values x, y, h and 0 < x < y < 200, there are only five triplets (x,y,h) producing integer solutions for w:

(70, 119, 30), (74, 182, 21), (87, 105, 35), (100, 116, 35) and (119, 175, 40).For integer values x, y, h and 0 < x < y < 1 000 000, how many triplets (x,y,h) produce integer solutions for w?

## Recent Comments