User Tools

Site Tools


public:t-vien-07-1:lab_9_materials

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

public:t-vien-07-1:lab_9_materials [2007/03/09 11:16]
hannes
public:t-vien-07-1:lab_9_materials [2008/01/03 11:05] (current)
hannes
Line 16: Line 16:
  
   * Download and unzip the [[http://www.ru.is/kennarar/hannes/classes/ve2007/Lab9Assets.zip|Lab 9 Asset File]] into your working directory   * Download and unzip the [[http://www.ru.is/kennarar/hannes/classes/ve2007/Lab9Assets.zip|Lab 9 Asset File]] into your working directory
 +
  
  
Line 40: Line 41:
 </code> Once this new transformation matrix has been created inside the vertex shader, both the View Vector and the Light Vector should be projected into tangent space through a simple multiplication with this matrix.  Once these vectors arrive inside the fragment shader, they should already be in tangent space and the third important component in our lighting calculations, namely the normal, should now be looked up in the normal map accessed through **tex_0_n** (note however that the texture stores components in the 0-1 range but we want them in the -1-1 range, so you need to correct the value when you look it up like this **tex2D(normalmap, texturecoordinate)*2-1**).  Since the normal that we're reading from the normal map is already in tangent space (that's how they're stored in normal maps - and that explains why we needed to transform the other vectors), we can now proceed with the lighting calculations, just like we did in model space.  See if you can make this work. </code> Once this new transformation matrix has been created inside the vertex shader, both the View Vector and the Light Vector should be projected into tangent space through a simple multiplication with this matrix.  Once these vectors arrive inside the fragment shader, they should already be in tangent space and the third important component in our lighting calculations, namely the normal, should now be looked up in the normal map accessed through **tex_0_n** (note however that the texture stores components in the 0-1 range but we want them in the -1-1 range, so you need to correct the value when you look it up like this **tex2D(normalmap, texturecoordinate)*2-1**).  Since the normal that we're reading from the normal map is already in tangent space (that's how they're stored in normal maps - and that explains why we needed to transform the other vectors), we can now proceed with the lighting calculations, just like we did in model space.  See if you can make this work.
  
---- 
- 
-You can take a look at a {{public:t-vien-07-1:lab9solution.zip|solution}} to parts 2 - 5 once you've given it a try yourself. 
/var/www/ailab/WWW/wiki/data/pages/public/t-vien-07-1/lab_9_materials.txt ยท Last modified: 2008/01/03 11:05 by hannes