vector - GLSL - Vertex normals + normal mapping? -


i'm trying create simple shader lighting system. right now, i'm working on adding support normal-mapping right now. without normal-mapping, lighting system works fine. i'm using normals forwarded vertex shader, , work fine. i'm reading normals normal map correctly. without including normal map, lighting works perfectly. i've tried adding vertex normal , normal map's normal, , doesn't work. tried multiplying. here's how i'm reading normal-map:

vec4 normalheight = texture2d(m_normalmap, texcoord); vec3 normals = normalize((normalheight.xyz * vec3(2.0) - vec3(1.0))); 

so have correct vertex normals, , normals normal map. how should combine these correct normals?

it depends on how store normal maps. if in world space begin (this rather rare) , scene never changes, can them way have them. typically, however, in tangent space. tangent space vector space uses object's normal, , rate of change in (s,t) texture coordinates transform normals on surface arbitrary orientation.

tangent space normal maps appear bluish naked eye, whereas world space normal maps every color of rainbow (and need biased , scaled because half of colorspace supposed represent negative vectors) :)

if want understand tangent space better, complete implementation on deriving basis vectors, see this link.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -