lighting

How does this faking the light work on aerotwist?

余生颓废 提交于 2019-11-26 04:55:54
问题 I am trying to read up this tutorial: https://aerotwist.com/tutorials/an-introduction-to-shaders-part-2/ but I am not able to follow up. Basically the code creates a directional light by using shaders that run directly on the GPU. This is the code: // same name and type as VS varying vec3 vNormal; void main() { // calc the dot product and clamp // 0 -> 1 rather than -1 -> 1 vec3 light = vec3(0.5,0.2,1.0); // ensure it\'s normalized light = normalize(light); // calculate the dot product of //

Normal mapping gone horribly wrong

末鹿安然 提交于 2019-11-26 01:02:31
问题 I tried to implement normal mapping in my opengl application but I can\'t get it to work. This is the diffuse map (which I add a brown color to) and this is the normal map. In order to get the tangent and bitangent (in other places called binormals?) vectors, I run this function for every triangle in my mesh: void getTangent(const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec2 &uv0, const glm::vec2 &uv1, const glm::vec2 &uv2, std::vector<glm::vec3> &vTangents, std:

Normal mapping gone horribly wrong

与世无争的帅哥 提交于 2019-11-25 22:54:17
I tried to implement normal mapping in my opengl application but I can't get it to work. This is the diffuse map (which I add a brown color to) and this is the normal map. In order to get the tangent and bitangent (in other places called binormals?) vectors, I run this function for every triangle in my mesh: void getTangent(const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec2 &uv0, const glm::vec2 &uv1, const glm::vec2 &uv2, std::vector<glm::vec3> &vTangents, std::vector<glm::vec3> &vBiangents) { // Edges of the triangle : postion delta glm::vec3 deltaPos1 = v1-v0;