BUG?? Problem with shaders: crappy Binormal and Tangent
BUG?? Problem with shaders: crappy Binormal and Tangent
Hi!
I've got a problem and i think it may be a bug in irrlicht!
I'm writing HLSL shaders and now i use the BINORMAL and TANGENT Input semantics from the vertex streams for one of my shaders...
the vertex streams i used before (NORMAL, POSITION, COLOR and TEXCOORD) work fine... but BINORMAL and TANGENT don't!
Irrlicht gives them completly messy to the shaders! I don't think it's a problem of my mesh - because in RenderMonkey it's working fine!
Has anyone an idea how to fix that?
thx!
I've got a problem and i think it may be a bug in irrlicht!
I'm writing HLSL shaders and now i use the BINORMAL and TANGENT Input semantics from the vertex streams for one of my shaders...
the vertex streams i used before (NORMAL, POSITION, COLOR and TEXCOORD) work fine... but BINORMAL and TANGENT don't!
Irrlicht gives them completly messy to the shaders! I don't think it's a problem of my mesh - because in RenderMonkey it's working fine!
Has anyone an idea how to fix that?
thx!
I found something strange trying to figure out how irrlicht uses the pixel shader information. In the file CD3D9Driver.cpp inside of the function "void CD3D9Driver::setVertexShader(E_VERTEX_TYPE newType)" there are two lines in the "case EVT_TANGENTS:" statement. The exact wording is:
D3DFVF_TEXCOORDSIZE2(0) | // real texture coord
D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent
D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal
Now I'm not exactly sure what Irrlicht is doing at this point in the code since this is the advanced stuff we use the engine to avoid, but the comments for it disturb me. Can anyone explain if this might be a problem or if it is something that should be fixed?
D3DFVF_TEXCOORDSIZE2(0) | // real texture coord
D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent
D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal
Now I'm not exactly sure what Irrlicht is doing at this point in the code since this is the advanced stuff we use the engine to avoid, but the comments for it disturb me. Can anyone explain if this might be a problem or if it is something that should be fixed?
It's standard practice. The easiest way to get per-vertex varying parameters to a shader is stuff them in the texture coords, since there are usually more texture coords available than are actually needed for textures
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
Found this too looking through some code. In CMeshManipulator.cpp I found in the function "void CMeshManipulator::recalculateNormals(IMeshBuffer* buffer) const" this comment:
case video::EVT_TANGENTS:
{
// TODO: recalculate tangent and binormal
}
I guess my question that I have is, does Irrlicht actual do any real computation for the binormals and tangents? Because some of the functions seem to be missing the important stuff.
case video::EVT_TANGENTS:
{
// TODO: recalculate tangent and binormal
}
I guess my question that I have is, does Irrlicht actual do any real computation for the binormals and tangents? Because some of the functions seem to be missing the important stuff.
And besides the above, I have found out that binormals and tangents are indeed computed, but strangely they are stored in TEXCOORD2 and TEXCOORD3. These are what you would use instead of the standardized BINORMAL and TANGENT. Why are they not stored in the standard BINORMAL and TANGENT slots for HLSL? If we ever needed more that 2 textures this would become a problem wouldn't it?
I've searched through the source code, but I can't find the exact place where the code is placing these in TEXCOORD2 and TEXCOORD3 instead of BINORMAL and TANGENT settings. I would assume that it is in the driver files, but nothing comes up with a search through the files. Does anyone know where the code is at? If I knew where the error was I would fix it myself, get it working, and post the fixed code.