diff --git a/main b/main index b0ac335204b69b8753125002a40ff341e826a33f..02c378767719f17b8bf327401a9b792d0e8a7a0b 100644 Binary files a/main and b/main differ diff --git a/main.cpp b/main.cpp index bc50479af6f9fda8ce172a7e7e680768adf55a7c..978005575cf2f9ead167cc4d6b6dc43cd22d3ee0 100644 --- a/main.cpp +++ b/main.cpp @@ -182,8 +182,8 @@ void init(void) //m = LoadModel("groundsphere.obj"); - texID1 = LoadTexture("Substance_Normal92df.jpg", 1); // Flipped. Klipper?! FIXAD! - //texID1 = LoadTexture("normal.jpg", 1); // Flipped. Klipper?! FIXAD! + //texID1 = LoadTexture("Substance_Normal92df.jpg", 1); // Flipped. Klipper?! FIXAD! + texID1 = LoadTexture("normal.jpg", 1); // Flipped. Klipper?! FIXAD! // Defaults to unit 0 glUniform1i(glGetUniformLocation(program,"texUnit"),0); diff --git a/shaders/ray.frag b/shaders/ray.frag index 72ea88b89ffbd451b0398a933d4764f4edb64d8a..858644a9277dd2ed70ab80c6cbef83bbad00301f 100644 --- a/shaders/ray.frag +++ b/shaders/ray.frag @@ -62,7 +62,7 @@ vec3 CameraRay(float fieldOfViewY, float aspectRatio, vec2 point) vec2 UV(vec3 intersection, int ID) { vec3 d = normalize(intersection - object_descriptor[ID]); - float U = 0.5 + atan(d.x, d.z)/(2.0*3.141592); + float U = 0.5 + atan(d.z, d.x)/(2.0*3.141592); float V = 0.5 + asin(d.y)/3.141592; return vec2(U,V); } @@ -76,7 +76,7 @@ float thetaSphere(vec3 intersection, int ID) vec3 theta_hat(float theta) { - vec3 theta_hat = vec3(-cos(theta),-sin(theta), 0); + vec3 theta_hat = vec3(-cos(theta),sin(theta), 0); return theta_hat; } @@ -207,6 +207,11 @@ vec3 CalculateNormal(vec3 intersection_point, int id) mat3 tbn = TBN(N,B,T); vec2 uv = UV(intersection_point, id); vec3 normal = normalize(texture(texUnit, uv).rgb*2.0 - 1.0); + normal = tbn * normal; + //if (dot(N, normal) < 0) + //{ + // normal = -normal; + //} return normal; } @@ -320,7 +325,7 @@ void main(void) if ((closest_id>=0) && (closest_distance<1500)) { - int nr_reflections = 3; + int nr_reflections = 5; int reflections = 0; int closest_id_temp = -1; for (int i = 0; i<nr_reflections; i++)