Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bump Map 1. High Field Function: H(u, v) New Normal : N’

Similar presentations


Presentation on theme: "Bump Map 1. High Field Function: H(u, v) New Normal : N’"— Presentation transcript:

1 Bump Map 1

2 High Field Function: H(u, v) New Normal : N’

3 Modify Normal 3 Original Surface normal Bump Map ∂H ∂u Gradient T N N’ Modified Normal

4 Tangent 4 World Space : R 3 Texture Space : R 2 T B U V

5 5 World Space :∆PTexture Space : (∆u, ∆v) ∆u ∆v T B ∆P Assume Surface is a Plane

6 Solve The Vector: T, B Triangle vertex position: P 0, P 1, P 2 Triangle vertex texture coordinates : C 0 (U 0, V 0 ), C 1 (U 1, V 1 ), C 2 (U 2, V 2 ) Let vec3 P 10 = P 1 - P 0 vec3 P 20 = P 2 – P 0 vec2 C 10 = C 1 - C 0 = (U 1 -U 0, V 1 -V 0 ) = ( U 10,V 10 ) vec2 C 20 = C 2 – C 0 = (U 2 -U 0, V 2 -V 0 ) = ( U 20,V 20 ) Solve P 10 = U 10 T + V 10 B P 20 = U 20 T + V 20 B

7 =>

8 The Code void ComputeTangentBasis( const vec3& P1, const vec3& P2, const vec3& P3, const vec2& UV1, const vec2& UV2, const vec2& UV3, vec3 &tangent, vec3 &bitangent ) { vec3 Edge1 = P2 - P1; vec3 Edge2 = P3 - P1; vec2 Edge1uv = UV2 - UV1; vec2 Edge2uv = UV3 - UV1; float cp = Edge1uv.x * Edge2uv.y – Edge2uv.x * Edge1uv.y; if ( cp != 0.0f ) { float mul = 1.0f / cp; tangent = (Edge1 * Edge2uv.y + Edge2 * -Edge1uv.y) * mul; bitangent = (Edge1 * -Edge2uv.x + Edge2 * Edge1uv.x) * mul; }


Download ppt "Bump Map 1. High Field Function: H(u, v) New Normal : N’"

Similar presentations


Ads by Google