© Kyle Halladay 2019
Kyle HalladayPractical Shader Developmenthttps://doi.org/10.1007/978-1-4842-4457-9_19

Important Code Snippets

Kyle Halladay1 
(1)
Bristol, UK
 

There are two code snippets referenced in the text that are essential to being able to follow along with the examples on your own. In case you’re reading this book without access to the online code examples, I’ve included these two snippets here.

Calculating a Mesh’s Tangents

Listing A-1 contains the code necessary to calculate the tangent vectors for a mesh and store these vectors in the mesh’s vertex color.
void calcTangents(ofMesh& mesh){
      using namespace glm;
      std::vector<vec4> tangents;
      tangents.resize(mesh.getNumVertices());
      uint indexCount = mesh.getNumIndices();
      const ...

Get Practical Shader Development: Vertex and Fragment Shaders for Game Developers now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.