I have a spotlight shader which uses the normal, tangent and binormal. I get these from:
Code: Select all
vec3 Tangent = gl_MultiTexCoord1.xyz;
vec3 Binormal = gl_MultiTexCoord2.xyz;
Code: Select all
irr::scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
createMeshWithTangents(mesh->getMesh(0));
Anyway, if i use tangents and binormals as gl_MultiTexCoordX then i get a lot of artifacts like here (picture2):
https://sites.google.com/site/damakukamely/home
However, if i chose to calculate the tangent and binormal inside the shader using:
Code: Select all
vec3 rm_Tangent;
vec3 Binormal;
vec3 c1 = cross(gl_Normal, vec3(0.0, 0.0, 1.0));
vec3 c2 = cross(gl_Normal, vec3(0.0, 1.0, 0.0));
if(length(c1)>length(c2))
{
Tangent = c1;
}
else
{
Tangent = c2;
}
Tangent = normalize(Tangent);
Binormal = cross(gl_Normal, Tangent);
Binormal = normalize(Binormal);
But even this one does have some artifacts at some angles. I guess the problem is around if(length(c1)>length(c2)) or something like that.
The question is, it seems irrlicht has a bug and cannot properly calculate tangent and binormal. These should be very easy to calculate, they are just X products of the normals.
Second, how can i make irrLicht to load normals, and not recalculate them ?