glsl - OpenGL Shaders - Normals in Gouraud and Phong shading? -


i can't seem understand opengl pipeline process vertex pixel.

can tell me how important vertex normals on these 2 shading techinques? far know, in gouraud, lighting calculated @ each vertex, result color interpolated across polygon between vertices (is done in fragment operations, before rasterizing?), , phong shading consists of interpolating first vertices normals , calculating illumination on each of these normals.

another thing when bump mapping applied lets plane (2 triangles) , brick texture diffuse respect bump map, of gouraud shading. bump mapping consist on altering normals gradient depending on bump map. normals alter , when (at fragment shader?) if there 4 normals (4 vertices = plane), , 4 same. in gouraud interpolate color of each vertex after illumination calculation, calculation done after altering normals.

how lighting work?

normal mapping, 1 of techniques simulate bumped surfaces perturbs per-pixel normals before compute light equation on pixel.

for example, 1 way implement requires interpolate surface normals , binormal (2 of tangent space basis) , compute third per-pixel (2+1 vectors tangent basis). technique requires interpolate light vector. 3 (2+1 computed) vectors (named tagent space basis) have way change light vector object space tagent space. because these 3 vectors can arranged 3x3 matrix can used change basis of light direction vector.

then matter of using tagent-space light vector , compute light equation per pixel, basic form dot product between tagent-space light vector , normal map (your bump texture).

this how normal maps looks (the normal component stored in each channel of texture , in tangent space):

enter image description here

this 1 way, can compute things in view space above more easy understand.

old bump mapping way simpler , kind of fake effect.

all bump mapping techniques operate @ pixel level, perturb in 1 way or other, how surface rendered. old emboss bump mapping did computation per pixel.

edit: added few more clarifications, when have spare minutes try add math , examples. although there great resources out there explain in great detail.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -